Problem
_migrate_config is called at the start of --start and --update. It deep-merges CONFIG_DEFAULTS into the existing config.toml and writes back any missing keys. Bugs here affect every user on every run. Key edge cases are untested:
- Malformed
config.toml: currently caught and printed, but no test verifies this
- Already-migrated config: calling
_migrate_config on a fully up-to-date config should not write the file (to avoid unnecessary disk I/O and timestamp changes)
- Unknown user keys: keys that exist in
config.toml but not in CONFIG_DEFAULTS (e.g. a user-added comment or a key from an older version) should be preserved, not dropped
Acceptance Criteria
Proposed Tests
test_migrate_config_handles_malformed_toml — write invalid TOML; assert error printed, no crash
test_migrate_config_no_write_when_already_complete — mock save_config; assert it is not called when config already has all keys
test_migrate_config_preserves_unknown_keys — add a non-default key to config; assert it is present after migration
test_migrate_config_adds_missing_keys — config missing a key from CONFIG_DEFAULTS; assert key is added after migration
Problem
_migrate_configis called at the start of--startand--update. It deep-mergesCONFIG_DEFAULTSinto the existingconfig.tomland writes back any missing keys. Bugs here affect every user on every run. Key edge cases are untested:config.toml: currently caught and printed, but no test verifies this_migrate_configon a fully up-to-date config should not write the file (to avoid unnecessary disk I/O and timestamp changes)config.tomlbut not inCONFIG_DEFAULTS(e.g. a user-added comment or a key from an older version) should be preserved, not droppedAcceptance Criteria
config.tomlproduces a human-readable error message and does not crash with a raw traceback_migrate_configon an already-complete config does not callsave_config(no disk write)CONFIG_DEFAULTSsurvive a_migrate_configround-tripProposed Tests
test_migrate_config_handles_malformed_toml— write invalid TOML; assert error printed, no crashtest_migrate_config_no_write_when_already_complete— mocksave_config; assert it is not called when config already has all keystest_migrate_config_preserves_unknown_keys— add a non-default key to config; assert it is present after migrationtest_migrate_config_adds_missing_keys— config missing a key fromCONFIG_DEFAULTS; assert key is added after migration