Repository navigation
fix: Worldbuilding core critical issues (C1, C2, I1, I2) - #161
Merged
Merged
Conversation
…get_id) agent_relations table uses agent_id and target_id, not agent_a_id/agent_b_id. SQL error at runtime prevented relation_currency condition from evaluating.
Needed by eval_scene_completeness for file-system-based narrative checks.
…f DB column The scenes table has no narrative column; narrative content lives in JSON files. Querying a non-existent column caused a runtime SQL error. Now reads scene JSON files to verify narrative is non-empty, using worlds_base_dir for path resolution.
Previously, JSON files were written before DB updates. If the DB update failed, the filesystem was already modified causing persistent inconsistency. Now DB writes happen first, and file writes use tmp + rename for atomicity.
Previously, delete_pending_creation ran before entity creation. If creation failed, a concurrent caller could observe the pending creation as missing during the gap between delete and re-insert. Now deletion happens only after successful creation — no recovery logic needed on failure.
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.
Summary
eval_relation_currencySQL column names (agent_a_id→agent_id,agent_b_id→target_id)eval_scene_completenessto check narrative via filesystem (std::ifstream+nlohmann::json::parse) instead of non-existent DB columnnarrative_json. Injectworlds_base_dirviaset_worlds_base_dir()fromPipelineManager.patch_scene/patch_chapter— DB first, then atomic file write (tmp +fs::rename)delete_pending_creationto after entity creation succeeds; remove catch-block recovery logicFiles Changed
libs/worldbuilding/src/condition_evaluator.cpp— C1 SQL fix + C2 filesystem narrative checklibs/worldbuilding/include/merak/worldbuilding/condition_evaluator.hpp— C2worlds_base_dir_injectionlibs/worldbuilding/src/pipeline_manager.cpp— C2 injectworlds_base_dirinto ConditionEvaluatorlibs/worldbuilding/src/narrative_store.cpp— I1 atomic write orderinglibs/worldbuilding/src/worldbuilding_service.cpp— I2 creation cleanup orderingTest plan
eval_relation_currencyno longer errors on column mismatcheval_scene_completenessreads narrative from filesystem correctlypatch_scene/patch_chapterdon't leave orphaned files on DB failuredelete_pending_creationruns after entity creation succeeds