diff --git a/src/system/config.py b/src/system/config.py index 7acf006..5cbb09d 100644 --- a/src/system/config.py +++ b/src/system/config.py @@ -87,4 +87,20 @@ def _deep_merge(base: dict, overrides: dict) -> None: if key in base and isinstance(base[key], dict) and isinstance(val, dict): _deep_merge(base[key], val) else: - base[key] = val \ No newline at end of file + base[key] = val + + +def save_config(cfg: dict, path: Path = DEFAULT_CONFIG_PATH) -> bool: + """Save config dict to YAML file (preserves existing keys, overwrites in-memory state). + + Returns True on success, False on failure. + """ + try: + import yaml + with open(path, "w") as f: + yaml.dump(cfg, f, default_flow_style=False) + logger.info("Saved config to %s", path) + return True + except (ImportError, OSError) as e: + logger.warning("Failed to save config to %s: %s", path, e) + return False \ No newline at end of file