Feature/quest persistence#326
Open
Truphile wants to merge 5 commits into
Open
Conversation
Collaborator
|
Same as PR#325 — conflicts with main. Rebase after PR#322 merges since you share files with it. |
Collaborator
|
Three TS errors to fix:
Also rebase on main first to pull in recent changes to |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



closes #268
Here is a summary of the changes:
• Created the store to manage writing and loading the quests , questStats , and agentXp data structures using the provided JSON format.
• Implemented atomic writes by writing the serialized JSON to .data/quests.json.tmp first, then utilizing fs.renameSync to safely swap it to .data/quests.json .
• Added a fallback mechanism that initializes the store with empty data and emits a console.warn if the parsed JSON is corrupt.
• Included an auto-execution hook using a globalThis flag openStellarQuestStoreLoaded which calls loadQuestStore() exactly once upon the first import of the module.
• Modified hydrateSubTasks in quests.ts to hydrate subtaskDb directly from the stored questStoreData.quests entries on startup.
• Hooked persistQuestStore() into the addSubTask and updateSubTask functions to automatically capture new state when subtasks are progressed.
• Modified xp.ts to hydrate agentXpDb on initialization and persist whenever awardXP updates an agent's experience.
• Added a complete Vitest suite to evaluate the persistence logic.
• The test validates that completing a quest's subtask updates the memory store, correctly serializes the status to string, and successfully restores the "completed" status after deserializing from a simulated restart.
• Included an additional test case to cover the fallback behavior when the JSON is found to be corrupt.
• The functionality has been staged and committed successfully to the new feature/quest-persistence branch.