Skip to content

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

address review (claude, pass 2): fix the crash pass 1's own fix introduced

[._.]/ Adam Eivy4fc336856f41
diff --git a/client/src/components/games/GameBindings.jsx b/client/src/components/games/GameBindings.jsx
index a84144e17d..5f91e583b5 100644
--- a/client/src/components/games/GameBindings.jsx
+++ b/client/src/components/games/GameBindings.jsx
@@ -194,7 +194,11 @@ export default function GameBindings({
<BindingRow
key={binding.id}
label={track?.title || binding.trackId}
- detail={track?.audioFilename ? 'Audio ready' : 'Audio render required'}
+ // Shown only when the preflight has no verdict for this track,
+ // so it must state what the RECORD says, not claim a
+ // verification result — "Audio ready" here would assert bytes
+ // nobody hashed. The server's own message wins when present.
+ detail={track?.audioFilename ? 'Audio attached' : 'No audio yet'}
health={musicIntegrity.get(binding.id)}
disabled={busy}
onUnbind={() => onUnbindMusic(binding.id)}
diff --git a/client/src/pages/Game.jsx b/client/src/pages/Game.jsx
index 9630843732..19e3f1f10d 100644
--- a/client/src/pages/Game.jsx
+++ b/client/src/pages/Game.jsx
@@ -101,8 +101,14 @@ export default function Game() {
// Only a result carrying THIS game's id counts. Anything else — another
// game's verdict, or nothing fetched yet — reads as "still loading", which
// keeps every gate closed rather than open on a stale `canLaunch`.
- const integrity = integrityFor?.gameId === id ? integrityFor.data : null;
- const integrityLoading = integrityFetching || integrityFor?.gameId !== id;
+ //
+ // `integrityFor && id &&` is load-bearing, not defensive padding: on the index
+ // route `id` is undefined AND there is no result, so a bare
+ // `integrityFor?.gameId === id` compares undefined to undefined, matches, and
+ // dereferences null.
+ const matchesGame = Boolean(integrityFor && id && integrityFor.gameId === id);
+ const integrity = matchesGame ? integrityFor.data : null;
+ const integrityLoading = integrityFetching || !matchesGame;
const game = useMemo(() => games.find((entry) => entry.id === id) || null, [games, id]);
const app = apps.find((entry) => entry.id === game?.appId);
diff --git a/client/src/pages/Game.test.jsx b/client/src/pages/Game.test.jsx
new file mode 100644
index 0000000000..6e2e61a644
--- /dev/null
+++ b/client/src/pages/Game.test.jsx
@@ -0,0 +1,146 @@
+/**
+ * Game studio page — the integrity gate.
+ *
+ * The workspace's whole promise is "a game starts only after its manifest and
+ * every bound asset byte verify," and that promise lives in this component's
+ * state handling. Both cases below are regressions this file exists to catch:
+ * the index route rendering at all, and one game's verdict never being shown
+ * for another game (`/game/A` → `/game/B` reuses this route WITHOUT remounting,
+ * so unkeyed integrity state would enable Start game on an unverified bundle).
+ */
+
+import { render, screen, waitFor } from '@testing-library/react';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const api = vi.hoisted(() => ({
+ integrityByGame: {},
+ integrityCalls: [],
+}));
+
+vi.mock('../services/api.js', () => ({
+ listGames: vi.fn(async () => [
+ {
+ id: 'verified-game',
+ appId: 'app-1',
+ name: 'Verified Game',
+ spriteBindings: [{ spriteId: 'hero' }],
+ musicBindings: [],
+ feedbackHistory: [],
+ compiledManifest: {
+ version: 2,
+ spriteCount: 1,
+ musicCount: 0,
+ verifiedFileCount: 2,
+ builtAt: '2026-07-28T12:00:00.000Z',
+ manifestPath: 'manifests/game-assets-v2.json',
+ },
+ updatedAt: '2026-07-28T12:00:00.000Z',
+ },
+ {
+ id: 'unbuilt-game',
+ appId: 'app-1',
+ name: 'Unbuilt Game',
+ spriteBindings: [],
+ musicBindings: [],
+ feedbackHistory: [],
+ compiledManifest: null,
+ updatedAt: '2026-07-28T12:00:00.000Z',
+ },
+ ]),
+ getApps: vi.fn(async () => [{ id: 'app-1', name: 'Example App' }]),
+ listSpriteRecords: vi.fn(async () => [{ id: 'hero', name: 'Hero', kind: 'character', status: 'ready' }]),
+ listTracks: vi.fn(async () => []),
+ getGameIntegrity: vi.fn(async (id) => {
+ api.integrityCalls.push(id);
+ return api.integrityByGame[id] ?? null;
+ }),
+ getGame: vi.fn(),
+ createGame: vi.fn(),
+ compileGameAssets: vi.fn(),
+ requestGameFeedback: vi.fn(),
+ bindGameSprite: vi.fn(),
+ bindGameMusic: vi.fn(),
+ unbindGameSprite: vi.fn(),
+ unbindGameMusic: vi.fn(),
+ startApp: vi.fn(),
+ launchNativeApp: vi.fn(),
+}));
+
+const { default: Game } = await import('./Game.jsx');
+
+const renderAt = (path) => render(
+ <MemoryRouter initialEntries={[path]}>
+ <Routes>
+ <Route path="/game" element={<Game />} />
+ <Route path="/game/:id" element={<Game />} />
+ </Routes>
+ </MemoryRouter>,
+);
+
+describe('Game page', () => {
+ beforeEach(() => {
+ api.integrityCalls = [];
+ api.integrityByGame = {
+ 'verified-game': {
+ readyToCompile: true,
+ canLaunch: true,
+ bundle: { status: 'current' },
+ issues: [],
+ counts: { spriteReady: 1, spriteTotal: 1, musicReady: 0, musicTotal: 0, verifiedFiles: 2 },
+ assets: { sprites: [], music: [] },
+ },
+ 'unbuilt-game': {
+ readyToCompile: true,
+ canLaunch: false,
+ bundle: { status: 'missing' },
+ issues: [],
+ counts: { spriteReady: 0, spriteTotal: 0, musicReady: 0, musicTotal: 0, verifiedFiles: 0 },
+ assets: { sprites: [], music: [] },
+ },
+ };
+ });
+
+ // The index route has no `:id`, so every id-keyed derivation has to tolerate
+ // an undefined id — including the "is this result for the game on screen?"
+ // comparison, where undefined must NOT read as a match.
+ it('renders the index route, which has no game id', async () => {
+ renderAt('/game');
+ expect(await screen.findByText('Create a Game workspace')).toBeInTheDocument();
+ expect(screen.getByText('Verified Game')).toBeInTheDocument();
+ expect(api.integrityCalls).toEqual([]);
+ });
+
+ it('shows a verified game as launchable', async () => {
+ renderAt('/game/verified-game');
+ expect(await screen.findByText('Verified')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Start game' })).toBeEnabled();
+ });
+
+ it('never offers to launch a game whose bundle was never built', async () => {
+ renderAt('/game/unbuilt-game');
+ expect(await screen.findByText('Not built')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Start game' })).toBeDisabled();
+ });
+
+ it('does not show one game as launchable because another one was', async () => {
+ // The regression: a slow fetch for the unbuilt game, while the verified
+ // game's verdict is already in state. Until this game's own result lands,
+ // Start game must stay shut rather than inherit `canLaunch: true`.
+ let release;
+ const pending = new Promise((resolve) => { release = resolve; });
+ const { getGameIntegrity } = await import('../services/api.js');
+ getGameIntegrity.mockImplementationOnce(async () => {
+ await pending;
+ return api.integrityByGame['unbuilt-game'];
+ });
+
+ renderAt('/game/unbuilt-game');
+ await screen.findByRole('button', { name: 'Start game' });
+ expect(screen.getByRole('button', { name: 'Start game' })).toBeDisabled();
+
+ release();
+ await waitFor(() => expect(screen.getByText('Not built')).toBeInTheDocument());
+ expect(screen.getByRole('button', { name: 'Start game' })).toBeDisabled();
+ });
+});
diff --git a/server/lib/fileUtils.js b/server/lib/fileUtils.js
index a6ae8c8d3a..b0a28a23ca 100644
--- a/server/lib/fileUtils.js
+++ b/server/lib/fileUtils.js
@@ -1431,6 +1431,10 @@ export function assertSafeFilename(filename, { extensions, subject = 'filename',
* separator, anything that isn't already a pure basename, and any extension
* outside `extensions`. The basename equality check is kept alongside the
* separator check so e.g. `subdir\foo.png` is rejected on both counts.
+ *
+ * `extensions` must be dot-prefixed, and unlike `assertSafeFilename` this does
+ * not police that for you — a bare suffix like `png` would also match
+ * `not-an-imagepng`. Pass a module constant, never a caller-supplied list.
*/
export function isSafeFilename(filename, extensions) {
if (!filename || typeof filename !== 'string') return false;