packages/core/src/quest/. It is a pure domain module with no database calls and no side effects. All vault operations happen in the repository layer.
State Machine
Quest state transitions are validated bystate-machine.ts. Not all transitions are legal:
Quest Entity
createQuestEntity wraps raw quest data from the database into a domain object with computed properties:
isOverdue: whether the deadline has passednextReset: when a daily/weekly quest resetscurrentObjectiveIndex: for epic/chain questscompletionRate: percentage of objectives done
Completing a Quest
completeObjective(quest, objectiveId) handles partial completion for epic and chain quests. When all objectives are done, the quest status transitions to completed.
For simple quests (daily, weekly, bounty, ritual), a single complete call transitions directly.
Streak Tracking
resetQuestStreak(quest) is called by the scheduler when a daily/weekly quest’s deadline passes without completion. It:
- Decrements the streak counter
- Applies the streak penalty multiplier to the next award
- Consumes a streak shield if one is available
Repository Interface
complete method in the repository orchestrates: proof creation → XP calculation → character XP update → skill XP distribution → streak increment → log entry.