[priority: critical] Legacy store.ts coexists with modular stores/ — incomplete migration #96
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 originalGameStorewith 30+ actionsstores/directory has a complete modular split (gameStore, manaStore, combatStore, prestigeStore, craftingStore, attunementStore, discipline-slice)store.tsis still imported by some modules whilestores/is used by componentscrafting-slice.ts(379 LOC) is a legacy module coexisting with newercrafting-actions/modulesGameStatehas legacy equipment fields (equipment,inventory) alongside the new instance-based systemAffected files:
src/lib/game/store.tssrc/lib/game/stores/gameStore.ts,src/lib/game/stores/manaStore.tssrc/lib/game/crafting-slice.tssrc/lib/game/types/game.tsSuggested fix: Complete the migration: remove
store.tsandcrafting-slice.tsentirely, update all imports to use modular stores, remove legacy fields fromGameState.Confidence: High
Dimension: incomplete_migration / high_level_elegance
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.tsis dead code.crafting-slice.ts — Only imported by
craftingStore.tsforcreateStartingEquipment(). The rest of its exports (processCraftingTick, createCraftingSlice, getSpellsFromEquipment) are unused.Plan:
createStartingEquipment()intocraftingStore.ts(or a helper) and remove thecrafting-slice.tsimportstore.tsentirelycrafting-slice.tsentirelyGameStateintypes/game.ts(equipment,inventory)✅ Completed the legacy store migration.
What was done:
src/lib/game/store.ts(355 LOC monolithic store — zero imports, dead code)src/lib/game/crafting-slice.ts(379 LOC legacy crafting module — onlycreateStartingEquipmentwas used)createStartingEquipment()directly intocraftingStore.tsequipmentandinventoryfields fromGameStateintypes/game.tsEquipmentDefimport fromgame.tsEquipmentSpellStateexport intypes.tsbluePrintIdtypo incraftingStore.ts(pre-existing bug)stores/index.tsto importCraftingState/CraftingActionsfromcraftingStore.typesEquipmentTab.test.tsto test store state instead of deleted modulecrafting-slice.tsResults:
Summary
Successfully completed the migration from legacy
store.tsto the modularstores/architecture.Files Deleted (734 LOC removed)
src/lib/game/store.ts— monolithic 355-line store withuseGameStore,GameStoreinterface,makeInitial(), and 30+ actions. Had zero active imports.src/lib/game/crafting-slice.ts— 379-line legacy module. OnlycreateStartingEquipment()was used (bycraftingStore.ts).Files Modified (15 files)
craftingStore.ts— inlinedcreateStartingEquipment(), fixedbluePrintIdtypostores/index.ts— fixedCraftingState/CraftingActionsimport sourcetypes/game.ts— removed legacyequipment/inventoryfields, removed unusedEquipmentDefimporttypes.ts— removed duplicateEquipmentSpellStateexportEquipmentTab.test.ts— updated to test store state instead of deleted moduleutils/mana-utils.ts— cleaned up stale comment referencing../storeVerification