feat: WBS-1.5 공식 라이프사이클 레지스트리 269개 공식 마이그레이션 및 대조 검증
This commit is contained in:
@@ -20,33 +20,64 @@ def _status_value(row: dict[str, Any]) -> str:
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--registry", default="spec/13_formula_registry.yaml")
|
||||
ap.add_argument("--lifecycle", default="spec/51_formula_lifecycle_registry.yaml")
|
||||
args = ap.parse_args()
|
||||
|
||||
# 1. Read spec/13_formula_registry.yaml
|
||||
path = ROOT / args.registry
|
||||
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
formulas = ((data or {}).get("formula_registry") or {}).get("formulas") or {}
|
||||
|
||||
families: dict[str, list[str]] = defaultdict(list)
|
||||
for fid, row in formulas.items():
|
||||
for fid in formulas.keys():
|
||||
family = fid.rsplit("_V", 1)[0]
|
||||
families[family].append(fid)
|
||||
active_count = sum(
|
||||
1
|
||||
for fid, row in formulas.items()
|
||||
if _status_value(row) == "active"
|
||||
)
|
||||
inferred_count = sum(1 for row in formulas.values() if not str((row or {}).get("status") or "").strip())
|
||||
|
||||
# 2. Read spec/51_formula_lifecycle_registry.yaml
|
||||
lifecycle_path = ROOT / args.lifecycle
|
||||
if not lifecycle_path.exists():
|
||||
print(f"Lifecycle registry not found: {lifecycle_path}")
|
||||
return 1
|
||||
lifecycle_data = yaml.safe_load(lifecycle_path.read_text(encoding="utf-8"))
|
||||
lifecycle_formulas = lifecycle_data.get("formulas", [])
|
||||
|
||||
lifecycle_map = {f.get("formula_id"): f.get("lifecycle_state") for f in lifecycle_formulas if f.get("formula_id")}
|
||||
|
||||
# 3. Validation logic
|
||||
missing_ids = []
|
||||
invalid_state_ids = []
|
||||
valid_states = {"ACTIVE", "DEPRECATED", "DATA_GATED", "PENDING"}
|
||||
|
||||
for fid in formulas.keys():
|
||||
state = lifecycle_map.get(fid)
|
||||
if not state:
|
||||
missing_ids.append(fid)
|
||||
elif state not in valid_states:
|
||||
invalid_state_ids.append((fid, state))
|
||||
|
||||
missing_status_count = len(missing_ids) + len(invalid_state_ids)
|
||||
gate = "PASS" if missing_status_count == 0 else "FAIL"
|
||||
|
||||
if missing_ids:
|
||||
print(f"Missing formula registrations in 51_formula_lifecycle_registry.yaml: {missing_ids}")
|
||||
if invalid_state_ids:
|
||||
print(f"Invalid lifecycle states detected: {invalid_state_ids}")
|
||||
|
||||
result = {
|
||||
"formula_id": "FORMULA_VERSION_LIFECYCLE_V1",
|
||||
"formula_count": len(formulas),
|
||||
"missing_status_count": 0,
|
||||
"inferred_active_count": inferred_count,
|
||||
"missing_status_count": missing_status_count,
|
||||
"inferred_active_count": 0,
|
||||
"family_count": len(families),
|
||||
"active_count": active_count,
|
||||
"gate": "PASS",
|
||||
"active_count": sum(1 for state in lifecycle_map.values() if state == "ACTIVE"),
|
||||
"gate": gate,
|
||||
}
|
||||
|
||||
out = ROOT / "Temp" / "formula_version_lifecycle_v1.json"
|
||||
out.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
return 0 if gate == "PASS" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user