Data Layer Purity

Files in src/starship-survivors/data/ must not import from ../engine/, ../stores/, ../services/, ../screens/, ../components/, or any browser API at module load. Pure data plus helpers only. Every file in data/ must be importable in a Vitest test environment without a DOM — no window, no document, no localStorage, no navigator, no fetch, no Zustand store imports, no async work at module load.

Data is the leaves of the dependency tree: engine and metagame read from data, never the reverse. If a file in data/ needs to import from engine/ or stores/, the layering is broken and the file belongs in services/ instead. Module-load throws for invariant assertion are encouraged — they catch contract violations before any test or build step touches the data.

Exception

data/run-history.ts is the only data file that touches localStorage. It lives in data/ because the run-history schema is the canonical record shape, not because it performs any game logic. All localStorage access in that file is wrapped in try/catch so storage failures degrade silently rather than crash module load.