[High] [Bug] Enchanting: Discipline perk gating not enforced in design validation #302

Closed
opened 2026-06-07 17:42:17 +02:00 by Anexim · 3 comments
Owner

Spec: docs/specs/attunements/enchanter/systems/enchanting-spec.md §13, AC-13
Severity: Missing feature

Problem: The unlockedEffects store exists in craftingStore.types.ts:26 and discipline perks can unlock effects via gameStore.ts:215-217, but validateDesignEffects() in src/lib/game/crafting-design.ts:22-42 never checks unlockedEffects. Any effect can be used regardless of discipline perks.

Files:

  • src/lib/game/crafting-design.ts:22-42 — validation doesn't check unlockedEffects
  • src/lib/game/crafting-actions/design-actions.ts:33-40 — design start uses the incomplete validation
**Spec:** docs/specs/attunements/enchanter/systems/enchanting-spec.md §13, AC-13 **Severity:** Missing feature **Problem:** The `unlockedEffects` store exists in `craftingStore.types.ts:26` and discipline perks can unlock effects via `gameStore.ts:215-217`, but `validateDesignEffects()` in `src/lib/game/crafting-design.ts:22-42` never checks `unlockedEffects`. Any effect can be used regardless of discipline perks. **Files:** - `src/lib/game/crafting-design.ts:22-42` — validation doesn't check unlockedEffects - `src/lib/game/crafting-actions/design-actions.ts:33-40` — design start uses the incomplete validation
Anexim added the ai:todo label 2026-06-07 17:42:17 +02:00
n8n-gitea was assigned by Anexim 2026-06-07 17:42:17 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-08 11:33:59 +02:00
Author
Owner

Starting investigation of discipline perk gating in enchantment design validation.

Starting investigation of discipline perk gating in enchantment design validation.
Author
Owner

Fix applied for discipline perk gating in design validation (AC-13).

Root cause: validateDesignEffects() in crafting-design.ts:22-42 never checked the unlockedEffects store. Any effect could be used regardless of discipline perks.

Changes:

  1. src/lib/game/crafting-design.ts — Added unlockedEffects: string[] = [] parameter to validateDesignEffects(). Each effect ID is now checked against the unlocked set; locked effects return { valid: false, reason: "Effect X is locked — unlock via discipline perks" }.
  2. src/lib/game/crafting-actions/design-actions.ts — Updated startDesigningEnchantment() to pass state.unlockedEffects to validation.
  3. src/lib/game/stores/craftingStore.ts — Updated the store's own startDesigningEnchantment action to pass state.unlockedEffects.
  4. src/lib/game/__tests__/design-validation-perk-gating.test.ts — Added 8 regression tests covering: locked effects rejected, unlocked effects accepted, partial unlocks, backward compat (default empty array), and interaction with existing validation (unknown effects, wrong category).

Verification: All 761 existing tests pass + 8 new regression tests pass.

**Fix applied for discipline perk gating in design validation (AC-13).** **Root cause:** `validateDesignEffects()` in `crafting-design.ts:22-42` never checked the `unlockedEffects` store. Any effect could be used regardless of discipline perks. **Changes:** 1. `src/lib/game/crafting-design.ts` — Added `unlockedEffects: string[] = []` parameter to `validateDesignEffects()`. Each effect ID is now checked against the unlocked set; locked effects return `{ valid: false, reason: "Effect X is locked — unlock via discipline perks" }`. 2. `src/lib/game/crafting-actions/design-actions.ts` — Updated `startDesigningEnchantment()` to pass `state.unlockedEffects` to validation. 3. `src/lib/game/stores/craftingStore.ts` — Updated the store's own `startDesigningEnchantment` action to pass `state.unlockedEffects`. 4. `src/lib/game/__tests__/design-validation-perk-gating.test.ts` — Added 8 regression tests covering: locked effects rejected, unlocked effects accepted, partial unlocks, backward compat (default empty array), and interaction with existing validation (unknown effects, wrong category). **Verification:** All 761 existing tests pass + 8 new regression tests pass.
Anexim added ai:done and removed ai:in-progress labels 2026-06-08 11:40:23 +02:00
Author
Owner

Fix complete and pushed.

Summary of changes:

  • crafting-design.ts — Added unlockedEffects parameter to validateDesignEffects(); each effect ID is checked against the unlocked set
  • design-actions.ts — Passes state.unlockedEffects from the store to validation
  • craftingStore.ts — Passes state.unlockedEffects from the store to validation
  • design-validation-perk-gating.test.ts — 8 regression tests covering locked/unlocked/partial/unlocked+wrong-category scenarios

All 1051 tests pass (55 files). Pre-commit hooks clean.

**Fix complete and pushed.** Summary of changes: - `crafting-design.ts` — Added `unlockedEffects` parameter to `validateDesignEffects()`; each effect ID is checked against the unlocked set - `design-actions.ts` — Passes `state.unlockedEffects` from the store to validation - `craftingStore.ts` — Passes `state.unlockedEffects` from the store to validation - `design-validation-perk-gating.test.ts` — 8 regression tests covering locked/unlocked/partial/unlocked+wrong-category scenarios All 1051 tests pass (55 files). Pre-commit hooks clean.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#302