[priority: critical] Legacy store.ts coexists with modular stores/ — incomplete migration #96

Closed
opened 2026-05-20 10:59:24 +02:00 by Anexim · 3 comments
Owner

Severity: Critical — two parallel store systems create confusion about source of truth, risk of state divergence, and block further refactoring.

Findings:

  • store.ts (355 LOC, monolithic) contains the original GameStore with 30+ actions
  • stores/ directory has a complete modular split (gameStore, manaStore, combatStore, prestigeStore, craftingStore, attunementStore, discipline-slice)
  • Both patterns are active — store.ts is still imported by some modules while stores/ is used by components
  • crafting-slice.ts (379 LOC) is a legacy module coexisting with newer crafting-actions/ modules
  • GameState has legacy equipment fields (equipment, inventory) alongside the new instance-based system

Affected files:

  • src/lib/game/store.ts
  • src/lib/game/stores/gameStore.ts, src/lib/game/stores/manaStore.ts
  • src/lib/game/crafting-slice.ts
  • src/lib/game/types/game.ts

Suggested fix: Complete the migration: remove store.ts and crafting-slice.ts entirely, update all imports to use modular stores, remove legacy fields from GameState.

Confidence: High
Dimension: incomplete_migration / high_level_elegance

**Severity:** Critical — two parallel store systems create confusion about source of truth, risk of state divergence, and block further refactoring. **Findings:** - `store.ts` (355 LOC, monolithic) contains the original `GameStore` with 30+ actions - `stores/` directory has a complete modular split (gameStore, manaStore, combatStore, prestigeStore, craftingStore, attunementStore, discipline-slice) - Both patterns are active — `store.ts` is still imported by some modules while `stores/` is used by components - `crafting-slice.ts` (379 LOC) is a legacy module coexisting with newer `crafting-actions/` modules - `GameState` has legacy equipment fields (`equipment`, `inventory`) alongside the new instance-based system **Affected files:** - `src/lib/game/store.ts` - `src/lib/game/stores/gameStore.ts`, `src/lib/game/stores/manaStore.ts` - `src/lib/game/crafting-slice.ts` - `src/lib/game/types/game.ts` **Suggested fix:** Complete the migration: remove `store.ts` and `crafting-slice.ts` entirely, update all imports to use modular stores, remove legacy fields from `GameState`. **Confidence:** High **Dimension:** incomplete_migration / high_level_elegance
Anexim added the ai:todo label 2026-05-20 10:59:24 +02:00
n8n-gitea was assigned by Anexim 2026-05-20 10:59:24 +02:00
Author
Owner

Starting work on removing legacy store.ts and crafting-slice.ts. Investigation complete:

store.ts — No actual imports anywhere in the codebase (only a comment reference in mana-utils.ts). The modular stores in stores/ are already the source of truth. store.ts is dead code.

crafting-slice.ts — Only imported by craftingStore.ts for createStartingEquipment(). The rest of its exports (processCraftingTick, createCraftingSlice, getSpellsFromEquipment) are unused.

Plan:

  1. Move createStartingEquipment() into craftingStore.ts (or a helper) and remove the crafting-slice.ts import
  2. Delete store.ts entirely
  3. Delete crafting-slice.ts entirely
  4. Remove legacy fields from GameState in types/game.ts (equipment, inventory)
  5. Run tests to verify nothing breaks
Starting work on removing legacy store.ts and crafting-slice.ts. Investigation complete: **store.ts** — No actual imports anywhere in the codebase (only a comment reference in mana-utils.ts). The modular stores in `stores/` are already the source of truth. `store.ts` is dead code. **crafting-slice.ts** — Only imported by `craftingStore.ts` for `createStartingEquipment()`. The rest of its exports (processCraftingTick, createCraftingSlice, getSpellsFromEquipment) are unused. **Plan:** 1. Move `createStartingEquipment()` into `craftingStore.ts` (or a helper) and remove the `crafting-slice.ts` import 2. Delete `store.ts` entirely 3. Delete `crafting-slice.ts` entirely 4. Remove legacy fields from `GameState` in `types/game.ts` (`equipment`, `inventory`) 5. Run tests to verify nothing breaks
Author
Owner

Completed the legacy store migration.

What was done:

  • Deleted src/lib/game/store.ts (355 LOC monolithic store — zero imports, dead code)
  • Deleted src/lib/game/crafting-slice.ts (379 LOC legacy crafting module — only createStartingEquipment was used)
  • Inlined createStartingEquipment() directly into craftingStore.ts
  • Removed legacy equipment and inventory fields from GameState in types/game.ts
  • Removed unused EquipmentDef import from game.ts
  • Fixed duplicate EquipmentSpellState export in types.ts
  • Fixed bluePrintId typo in craftingStore.ts (pre-existing bug)
  • Updated stores/index.ts to import CraftingState/CraftingActions from craftingStore.types
  • Updated EquipmentTab.test.ts to test store state instead of deleted module
  • Cleaned up stale comments referencing crafting-slice.ts

Results:

  • All 285 tests pass (18 test files)
  • Pre-commit checks pass (file sizes, circular deps, project structure)
  • TS errors reduced from 83 → 72 (removed conflicting legacy types)
  • 17 files changed, 104 insertions(+), 781 deletions(-)
✅ Completed the legacy store migration. **What was done:** - Deleted `src/lib/game/store.ts` (355 LOC monolithic store — zero imports, dead code) - Deleted `src/lib/game/crafting-slice.ts` (379 LOC legacy crafting module — only `createStartingEquipment` was used) - Inlined `createStartingEquipment()` directly into `craftingStore.ts` - Removed legacy `equipment` and `inventory` fields from `GameState` in `types/game.ts` - Removed unused `EquipmentDef` import from `game.ts` - Fixed duplicate `EquipmentSpellState` export in `types.ts` - Fixed `bluePrintId` typo in `craftingStore.ts` (pre-existing bug) - Updated `stores/index.ts` to import `CraftingState`/`CraftingActions` from `craftingStore.types` - Updated `EquipmentTab.test.ts` to test store state instead of deleted module - Cleaned up stale comments referencing `crafting-slice.ts` **Results:** - All 285 tests pass (18 test files) - Pre-commit checks pass (file sizes, circular deps, project structure) - TS errors reduced from 83 → 72 (removed conflicting legacy types) - 17 files changed, 104 insertions(+), 781 deletions(-)
Author
Owner

Summary

Successfully completed the migration from legacy store.ts to the modular stores/ architecture.

Files Deleted (734 LOC removed)

  • src/lib/game/store.ts — monolithic 355-line store with useGameStore, GameStore interface, makeInitial(), and 30+ actions. Had zero active imports.
  • src/lib/game/crafting-slice.ts — 379-line legacy module. Only createStartingEquipment() was used (by craftingStore.ts).

Files Modified (15 files)

  • craftingStore.ts — inlined createStartingEquipment(), fixed bluePrintId typo
  • stores/index.ts — fixed CraftingState/CraftingActions import source
  • types/game.ts — removed legacy equipment/inventory fields, removed unused EquipmentDef import
  • types.ts — removed duplicate EquipmentSpellState export
  • EquipmentTab.test.ts — updated to test store state instead of deleted module
  • 6 crafting modules — cleaned up stale "extracted from crafting-slice.ts" comments
  • utils/mana-utils.ts — cleaned up stale comment referencing ../store

Verification

  • 285/285 tests pass
  • All pre-commit checks pass
  • All files under 400-line limit
  • TS errors reduced 83→72
## Summary Successfully completed the migration from legacy `store.ts` to the modular `stores/` architecture. ### Files Deleted (734 LOC removed) - `src/lib/game/store.ts` — monolithic 355-line store with `useGameStore`, `GameStore` interface, `makeInitial()`, and 30+ actions. Had zero active imports. - `src/lib/game/crafting-slice.ts` — 379-line legacy module. Only `createStartingEquipment()` was used (by `craftingStore.ts`). ### Files Modified (15 files) - `craftingStore.ts` — inlined `createStartingEquipment()`, fixed `bluePrintId` typo - `stores/index.ts` — fixed `CraftingState`/`CraftingActions` import source - `types/game.ts` — removed legacy `equipment`/`inventory` fields, removed unused `EquipmentDef` import - `types.ts` — removed duplicate `EquipmentSpellState` export - `EquipmentTab.test.ts` — updated to test store state instead of deleted module - 6 crafting modules — cleaned up stale "extracted from crafting-slice.ts" comments - `utils/mana-utils.ts` — cleaned up stale comment referencing `../store` ### Verification - ✅ 285/285 tests pass - ✅ All pre-commit checks pass - ✅ All files under 400-line limit - ✅ TS errors reduced 83→72
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#96