Skip to content

fix: Worldbuilding core critical issues (C1, C2, I1, I2) - #161

Merged
ULookup merged 6 commits into
mainfrom
worktree-fix+worldbuilding-core-critical-fixes
Jun 19, 2026
Merged

ULookup merged 6 commits into
mainfrom
worktree-fix+worldbuilding-core-critical-fixes

Conversation

@ULookup

@ULookup ULookup commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • C1: Fix eval_relation_currency SQL column names (agent_a_id → agent_id, agent_b_id → target_id)
  • C2: Rewrite eval_scene_completeness to check narrative via filesystem (std::ifstream + nlohmann::json::parse) instead of non-existent DB column narrative_json. Inject worlds_base_dir via set_worlds_base_dir() from PipelineManager.
  • I1: Swap DB write and file write order in patch_scene/patch_chapter — DB first, then atomic file write (tmp + fs::rename)
  • I2: Move delete_pending_creation to after entity creation succeeds; remove catch-block recovery logic

Files Changed

  • libs/worldbuilding/src/condition_evaluator.cpp — C1 SQL fix + C2 filesystem narrative check
  • libs/worldbuilding/include/merak/worldbuilding/condition_evaluator.hpp — C2 worlds_base_dir_ injection
  • libs/worldbuilding/src/pipeline_manager.cpp — C2 inject worlds_base_dir into ConditionEvaluator
  • libs/worldbuilding/src/narrative_store.cpp — I1 atomic write ordering
  • libs/worldbuilding/src/worldbuilding_service.cpp — I2 creation cleanup ordering

Test plan

  • CI passes
  • Verify eval_relation_currency no longer errors on column mismatch
  • Verify eval_scene_completeness reads narrative from filesystem correctly
  • Verify patch_scene/patch_chapter don't leave orphaned files on DB failure
  • Verify delete_pending_creation runs after entity creation succeeds

ULookup added 6 commits June 19, 2026 18:02
…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.
@ULookup
ULookup merged commit f08c386 into main Jun 19, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant