# Epic 7 - Questing, Narrative, and Faction Reputation

## Source Anchors

- Master epic reference: [`neon_sprawl_vision.plan.md`](../../../neon_sprawl_vision.plan.md) — Core Epic Map, System Modules Epic 7
- Related modules: E7.M1, E7.M2, E7.M3, E7.M4

## Ownership and success (Level 1)

- **Ownership focus:** Narrative Design + Quest Design + Tools
- **Success criteria:** Quest content provides clear progression direction, worldbuilding depth, and durable midgame engagement.

## Objective

Provide a quest state machine and reward routing that ties gathering, crafting, and combat into guided and repeatable content, plus faction reputation and contract generation for midgame durability.

## Module Breakdown

### E7.M1 - QuestStateMachine

- Responsibility: Quest start/step/complete state transitions and persistence.
- Key contracts: `QuestDef`, `QuestStepState`, `QuestStateTransition`
- Dependencies: E3.M2, E5.M1
- Stage target: Prototype

### E7.M2 - RewardAndUnlockRouter

- Responsibility: Route quest outputs to XP, items, unlocks, and reputation.
- Key contracts: `QuestRewardBundle`, `UnlockGrant`, `RewardDeliveryEvent`
- Dependencies: E2.M2, E3.M3, E7.M1
- Stage target: Prototype

### E7.M3 - FactionReputationLedger

- Responsibility: Track faction standing and gate faction-specific contracts/content.
- Key contracts: `FactionStanding`, `ReputationDelta`, `FactionGateRule`
- Dependencies: E7.M1
- Stage target: Pre-production

### E7.M4 - ContractMissionGenerator

- Responsibility: Semi-procedural repeatable contract generation with difficulty/reward bands.
- Key contracts: `ContractTemplate`, `ContractSeed`, `ContractOutcome`
- Dependencies: E4.M1, E5.M3, E7.M3
- Stage target: Pre-production

## Implementation Slices (Backlog-Ready)

### Slice 1 - Quest core and persistence

- Scope: E7.M1 supporting branching steps and failure/reset rules for prototype chain.
- Dependencies: E3.M2, E5.M1
- Acceptance criteria:
  - 3-5 onboarding quests + one chain requiring gather/craft/combat complete without duped rewards.
- Telemetry hooks: `quest_start`, `quest_step_complete`, `quest_complete`, funnel times.

### Slice 2 - Reward and unlock routing

- Scope: E7.M2 delivering XP, items, blueprint unlocks, and flags for world gates.
- Dependencies: E7.M1, E2.M2, E3.M3
- Acceptance criteria:
  - Idempotent reward delivery; replays cannot double-claim.
- Telemetry hooks: `reward_delivery`, `unlock_granted`.

### Slice 3 - Faction ledger (pre-production)

- Scope: E7.M3 gating at least one faction line and mission set.
- Dependencies: E7.M1
- Acceptance criteria:
  - Reputation deltas auditable; gates fail closed on tamper.
- Telemetry hooks: `reputation_delta`, `faction_gate_blocked`.

### Slice 4 - Contract generator (pre-production)

- Scope: E7.M4 emitting repeatable contracts from templates by zone difficulty.
- Dependencies: E4.M1, E5.M3, E7.M3
- Acceptance criteria:
  - Generated contracts validate against economy and parity rules.
- Telemetry hooks: `contract_issued`, `contract_complete`, reward anomalies.

## Risks and Mitigations

- Risk: Quest scripting becomes engineering-heavy for solo dev.
  - Mitigation: Data-first `QuestDef` schema; templates in decomposition tools path.
- Risk: Rewards break parity or economy.
  - Mitigation: Lint bundles against E6.M4 and E3.M5 policies.

## Definition of Done

- Prototype quest counts and integrated chain meet master plan minimums.
- Pre-production adds faction + contracts with validation.
