fix(registry): a write repairs a YAML that a failed migration left in format 1 (Issue #71)

The writer commits the migrated DB before it replaces the YAML. If that
replacement failed, the DB said format 2 and the next run did nothing.
When the DB is current the writer now also reads the YAML's format and
rewrites a YAML that is older or missing.

Refs #71

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-25 17:00:25 +00:00
1 parent 263a72483a
commit 015075077c
1 file changed
+11
+11
View File
@@ -124,6 +124,17 @@ def atomic_dump_yaml_main():
if from_version < registry_format.CURRENT:
d, migrated_rows = registry_format.migrate(d)
force_yaml = True
elif row:
# The DB is current; its YAML copy may not be (a migration whose
# YAML rewrite failed after the DB commit). Then rewrite it.
y = None
if os.path.exists(yaml_path):
try:
with open(yaml_path) as f:
y = yaml.safe_load(f)
except Exception:
y = None
force_yaml = registry_format.stored_version(y) < registry_format.CURRENT
old_sessions = get_all_sessions_status(d)
# a mutation that replaces a row the monitor registered for a pane it