WBS-7.3: GAS→Python 마이그레이션 5개 항목 완료 (F14, F02-F06)
- F14: late_chase_risk_score 검증 * GAS가 유일한 생산처 (Python canonical 없음) * migration_action: KEEP_IN_GAS로 정정, status: DONE - F02/F03/F04/F06: priceBasis 로직 포팅 * formulas/price_basis_v1.py: select_price_basis_tier2/tier1 구현 * tests/parity/test_price_basis_parity_v1.py: 8 parity 테스트 (모두 PASS) * GAS Number.isFinite() 의미론 정확히 재현 (math.isfinite 사용) * 모든 테스트 112/112 PASS 남은 작업 (4개): - F05: decision_logic (action assignment) - F07: score_logic (threshold addition) - F10: routing decision - F15: late_chase_gate Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,2 +1,87 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
print(json.dumps({"formula_id": "FORMULA_REGISTRY_SYNC_V1", "source_registry_hash": "mock", "normalized_registry_hash_basis": "mock", "gate": "PASS"}, indent=2))
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
# 1. Load canonical formulas from spec/13_formula_registry.yaml
|
||||
registry_path = ROOT / "spec" / "13_formula_registry.yaml"
|
||||
if not registry_path.exists():
|
||||
print(f"Registry not found: {registry_path}")
|
||||
return 1
|
||||
registry_data = yaml.safe_load(registry_path.read_text(encoding="utf-8"))
|
||||
canonical_formulas = registry_data.get("formula_registry", {}).get("formulas", {})
|
||||
canonical_set = set(canonical_formulas.keys())
|
||||
|
||||
# 2. Load domain formulas from spec/formulas/domains/*.yaml
|
||||
domain_dir = ROOT / "spec" / "formulas" / "domains"
|
||||
domain_formulas = {}
|
||||
duplicate_formula_count = 0
|
||||
|
||||
for path in sorted(domain_dir.glob("*.yaml")):
|
||||
if path.name == "manifest.yaml":
|
||||
continue
|
||||
try:
|
||||
doc = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
||||
except Exception as e:
|
||||
print(f"Error parsing {path}: {e}")
|
||||
continue
|
||||
formulas_in_doc = doc.get("formulas") if isinstance(doc.get("formulas"), dict) else {}
|
||||
for fid, row in formulas_in_doc.items():
|
||||
if fid in domain_formulas:
|
||||
duplicate_formula_count += 1
|
||||
domain_formulas[fid] = row
|
||||
|
||||
domain_set = set(domain_formulas.keys())
|
||||
|
||||
# Calculate missing
|
||||
missing_in_domain = canonical_set - domain_set
|
||||
missing_in_registry = domain_set - canonical_set
|
||||
|
||||
formula_domain_missing_count = len(missing_in_domain) + len(missing_in_registry)
|
||||
|
||||
# 3. Check duplicate threshold definitions in spec/calibration_registry.yaml
|
||||
calibration_path = ROOT / "spec" / "calibration_registry.yaml"
|
||||
duplicate_threshold_definition_count = 0
|
||||
if calibration_path.exists():
|
||||
try:
|
||||
calib_data = yaml.safe_load(calibration_path.read_text(encoding="utf-8")) or {}
|
||||
calib_items = calib_data.get("calibration_registry", [])
|
||||
seen_calib = set()
|
||||
for item in calib_items:
|
||||
cid = item.get("id")
|
||||
if cid:
|
||||
if cid in seen_calib:
|
||||
duplicate_threshold_definition_count += 1
|
||||
seen_calib.add(cid)
|
||||
except Exception as e:
|
||||
print(f"Error parsing calibration registry: {e}")
|
||||
|
||||
gate = "PASS" if (formula_domain_missing_count == 0 and duplicate_formula_count == 0 and duplicate_threshold_definition_count == 0) else "FAIL"
|
||||
|
||||
result = {
|
||||
"formula_id": "FORMULA_REGISTRY_SYNC_V1",
|
||||
"canonical_formula_count": len(canonical_set),
|
||||
"domain_formula_count": len(domain_set),
|
||||
"formula_domain_missing_count": formula_domain_missing_count,
|
||||
"duplicate_formula_count": duplicate_formula_count,
|
||||
"duplicate_threshold_definition_count": duplicate_threshold_definition_count,
|
||||
"gate": gate,
|
||||
"missing_in_domain": sorted(list(missing_in_domain)),
|
||||
"missing_in_registry": sorted(list(missing_in_registry))
|
||||
}
|
||||
|
||||
out_path = ROOT / "Temp" / "formula_registry_sync_v1.json"
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
out_path.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 0 if gate == "PASS" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
Reference in New Issue
Block a user