Skip to content

Commit 81f688f

Browse files
committed
Make phase 2 catalog migration idempotent
1 parent 7617c07 commit 81f688f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

scripts/phase2_catalog_migration.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env python3
22
"""Complete settings-catalog.json coverage for the Phase 2 settings refactor.
33
4-
This is intentionally a one-shot, deterministic migration. It refuses to run if the
5-
set of currently uncataloged persistent keys differs from the baseline discovered
6-
in Phase 1, so it cannot silently paper over future catalog regressions.
4+
The migration is deterministic and only accepts either the exact Phase 1 gap or an
5+
already-completed catalog. Any different gap is treated as a regression.
76
"""
87
from __future__ import annotations
98

@@ -92,6 +91,13 @@ def main() -> int:
9291

9392
existing = {entry["key"] for entry in catalog.get("settings", [])}
9493
missing = set(unique) - existing
94+
if not missing:
95+
catalog_count = len(existing)
96+
if catalog_count != len(unique) or catalog.get("settingCount") != catalog_count:
97+
raise SystemExit(f"Catalog claims full coverage but counts disagree: {catalog_count}/{len(unique)}")
98+
print(f"Catalog already complete at {catalog_count}/{len(unique)} persistent keys")
99+
return 0
100+
95101
if missing != EXPECTED_MISSING:
96102
raise SystemExit(
97103
"Refusing Phase 2 migration because the uncataloged baseline changed.\n"

0 commit comments

Comments
 (0)