공식 레지스트리와 생성물 동기화
This commit is contained in:
@@ -8,29 +8,14 @@ import yaml
|
||||
from refactor_master_helpers import ROOT, extract_formula_ids, extract_formula_outputs, load_yaml
|
||||
|
||||
|
||||
def _infer_owner(formula_id: str) -> str:
|
||||
fid = formula_id.upper()
|
||||
if any(token in fid for token in ("REPORT", "RENDER", "NARRATIVE", "TRACE", "LEDGER", "VERDICT", "JUDGMENT", "HEADLINE", "SUMMARY", "EXPLAIN")):
|
||||
return "report_owner"
|
||||
if any(token in fid for token in ("DATA_", "RAW", "FRESHNESS", "HARNESS", "INGEST", "MISSING", "CONTRACT")):
|
||||
return "data_owner"
|
||||
if any(token in fid for token in ("GAS", "ADAPTER", "EXPORT", "RUNTIME", "BUNDLE", "ZIP", "PACKAGE")):
|
||||
return "release_manager"
|
||||
if any(token in fid for token in ("CASH", "HEAT", "RISK", "SIZE", "STOP", "TAKE_PROFIT", "PROFIT", "LOSS", "PORTFOLIO", "POSITION", "EXIT", "SELL", "BUY", "ALLOCATION")):
|
||||
return "quant_owner"
|
||||
if any(token in fid for token in ("MACRO", "REGIME", "SECTOR", "LIQUIDITY", "SMART_MONEY", "FUNDAMENTAL", "EARNINGS", "GROWTH", "MARKET_SHARE", "MOMENTUM", "FLOW", "ALPHA", "PREDICTION", "PERFORMANCE")):
|
||||
return "engine_owner"
|
||||
return "engine_owner"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
formulas = load_yaml(ROOT / "spec" / "13_formula_registry.yaml").get("formula_registry", {}).get("formulas", {})
|
||||
owners = load_yaml(ROOT / "spec" / "ownership_map.yaml").get("ownership_map", {})
|
||||
formula_ids = extract_formula_ids()
|
||||
output_map = extract_formula_outputs()
|
||||
|
||||
missing_owner = [fid for fid in formula_ids if not str(formulas.get(fid, {}).get("owner") or _infer_owner(fid)).strip()]
|
||||
missing_status = [fid for fid in formula_ids if not str(formulas.get(fid, {}).get("status") or "active").strip()]
|
||||
missing_owner = [fid for fid in formula_ids if not str(formulas.get(fid, {}).get("owner") or "").strip()]
|
||||
missing_status = [fid for fid in formula_ids if not str(formulas.get(fid, {}).get("status") or "").strip()]
|
||||
missing_outputs = [fid for fid, outs in output_map.items() if not outs]
|
||||
|
||||
normalized = {
|
||||
@@ -40,9 +25,9 @@ def main() -> int:
|
||||
"formulas": [
|
||||
{
|
||||
"formula_id": fid,
|
||||
"owner": formulas.get(fid, {}).get("owner") or _infer_owner(fid),
|
||||
"status": formulas.get(fid, {}).get("status") or "active",
|
||||
"output_fields": output_map.get(fid, []) or ["TODO_REQUIRED"],
|
||||
"owner": formulas.get(fid, {}).get("owner"),
|
||||
"status": formulas.get(fid, {}).get("status"),
|
||||
"output_fields": output_map.get(fid, []),
|
||||
}
|
||||
for fid in formula_ids
|
||||
],
|
||||
@@ -60,7 +45,7 @@ def main() -> int:
|
||||
"missing_status_list": missing_status[:200],
|
||||
"missing_output_field_list": missing_outputs[:200],
|
||||
"owner_map_concepts": len(owners) if isinstance(owners, dict) else 0,
|
||||
"gate": "PASS",
|
||||
"gate": "FAIL" if missing_owner or missing_status or missing_outputs else "PASS",
|
||||
}
|
||||
out = ROOT / "Temp" / "formula_owner_coverage_v1.json"
|
||||
out.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
@@ -17,12 +17,14 @@ def main() -> int:
|
||||
normalized = yaml.safe_load((ROOT / "spec" / "03_formulas" / "formula_registry.normalized.yaml").read_text(encoding="utf-8"))
|
||||
domain_files = manifest.get("domains") or {}
|
||||
formulas = normalized.get("formulas") or []
|
||||
ok = bool(domain_files) and len(formulas) > 0
|
||||
missing_owner = [row.get("formula_id") for row in formulas if not str((row or {}).get("owner") or "").strip()]
|
||||
missing_status = [row.get("formula_id") for row in formulas if not str((row or {}).get("status") or "").strip()]
|
||||
missing_outputs = [row.get("formula_id") for row in formulas if not (row or {}).get("output_fields")]
|
||||
ok = bool(domain_files) and len(formulas) > 0 and not missing_owner and not missing_status and not missing_outputs
|
||||
print("FORMULA_REGISTRY_OK" if ok else "FORMULA_REGISTRY_FAIL")
|
||||
print(f"domain_count={len(domain_files)} formula_count={len(formulas)}")
|
||||
print(f"domain_count={len(domain_files)} formula_count={len(formulas)} missing_owner={len(missing_owner)} missing_status={len(missing_status)} missing_outputs={len(missing_outputs)}")
|
||||
return 0 if ok or not args.strict else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user