mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-29 04:47:10 -06:00
CodeRabbit (#3252): reload_dictionary() wrote DICT and DICT_IN_MEMORY under two separate locks. If install_dictionary() ran between them, the final state could hold an in-memory dictionary with the flag left false, so installed_path() would report a same-named disk file instead of None. Combined both into one DictState struct behind a single RwLock in both ru and cs, so install_dictionary() and reload_dictionary() each update the dictionary and its origin in one critical section. Didn't add a dedicated concurrency test: genuinely proving a race's absence needs real multi-threaded stress testing, and the previous commit on this PR already found that tests directly exercising install_dictionary()/reload_dictionary() concurrency in this crate's shared global state cause real, reproducible flakiness in unrelated tests. The fix is correct by construction (one lock acquisition around both field writes) and all 222 existing proof tests, run 15 times in a row, stay green. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>