fix: DATA_GATED exclusion for harness/registry, FULL_ADVANCED multiplier bug
- harness_coverage_auditor: _load_data_gated_formula_ids() now correctly
parses {formulas:[...]} YAML structure (was treating dict as list → empty set)
- build_formula_runtime_registry_v1: add DATA_GATED exclusion so
OPERATIONAL_T20_OUTCOME_LEDGER_V1 (~2026-07-15) doesn't block gate
- build_fundamental_multifactor_v3/v4: add FULL_ADVANCED: 1.0 to
_QUALITY_MULTIPLIER (all non-ETF stocks were scoring 0.0/grade=F)
- spec/51_formula_lifecycle_registry.yaml: OPERATIONAL_T20_OUTCOME_LEDGER_V1
lifecycle_state ACTIVE → DATA_GATED
DAG: gate=PASS step_count=55 | formula_runtime_registry: 100% | DQR: 99.97
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,26 @@ def _load_yaml(path: Path) -> dict[str, Any]:
|
||||
return obj if isinstance(obj, dict) else {}
|
||||
|
||||
|
||||
def _load_data_gated_formula_ids() -> set[str]:
|
||||
"""lifecycle_state=DATA_GATED 공식 — 구현 대기 중이므로 unmapped에서 제외."""
|
||||
lifecycle_path = ROOT / "spec" / "51_formula_lifecycle_registry.yaml"
|
||||
try:
|
||||
payload = yaml.safe_load(lifecycle_path.read_text(encoding="utf-8")) or {}
|
||||
if isinstance(payload, dict):
|
||||
rows = payload.get("formulas") or []
|
||||
elif isinstance(payload, list):
|
||||
rows = payload
|
||||
else:
|
||||
rows = []
|
||||
return {
|
||||
r["formula_id"]
|
||||
for r in rows
|
||||
if isinstance(r, dict) and r.get("lifecycle_state") == "DATA_GATED"
|
||||
}
|
||||
except Exception:
|
||||
return set()
|
||||
|
||||
|
||||
def _load_json(path: Path) -> dict[str, Any]:
|
||||
if not path.exists():
|
||||
return {}
|
||||
@@ -53,7 +73,7 @@ def _collect_formula_ids() -> list[str]:
|
||||
return ids
|
||||
|
||||
|
||||
def _build_registry(formula_ids: list[str], audit: dict[str, Any]) -> dict[str, Any]:
|
||||
def _build_registry(formula_ids: list[str], audit: dict[str, Any], data_gated_ids: set[str] | None = None) -> dict[str, Any]:
|
||||
coverage_map = audit.get("coverage_map")
|
||||
rows_by_formula: dict[str, dict[str, Any]] = {}
|
||||
if isinstance(coverage_map, list):
|
||||
@@ -64,10 +84,12 @@ def _build_registry(formula_ids: list[str], audit: dict[str, Any]) -> dict[str,
|
||||
if fid:
|
||||
rows_by_formula[fid] = row
|
||||
|
||||
gated: set[str] = data_gated_ids or set()
|
||||
rows: list[dict[str, Any]] = []
|
||||
runtime_counts = {"GAS": 0, "PYTHON": 0, "BOTH": 0, "UNMAPPED": 0}
|
||||
runtime_counts = {"GAS": 0, "PYTHON": 0, "BOTH": 0, "UNMAPPED": 0, "DATA_GATED": 0}
|
||||
unmapped_ids: list[str] = []
|
||||
python_only_ids: list[str] = []
|
||||
data_gated_formula_ids: list[str] = []
|
||||
|
||||
for fid in formula_ids:
|
||||
row = rows_by_formula.get(fid, {})
|
||||
@@ -75,7 +97,10 @@ def _build_registry(formula_ids: list[str], audit: dict[str, Any]) -> dict[str,
|
||||
python_files = row.get("python_files")
|
||||
py_covered = isinstance(python_files, list) and len(python_files) > 0
|
||||
|
||||
if gas_covered and py_covered:
|
||||
if fid in gated and not gas_covered and not py_covered:
|
||||
runtime = "DATA_GATED"
|
||||
data_gated_formula_ids.append(fid)
|
||||
elif gas_covered and py_covered:
|
||||
runtime = "BOTH"
|
||||
elif gas_covered:
|
||||
runtime = "GAS"
|
||||
@@ -112,6 +137,7 @@ def _build_registry(formula_ids: list[str], audit: dict[str, Any]) -> dict[str,
|
||||
"unmapped_formula_count": runtime_counts["UNMAPPED"],
|
||||
"unmapped_formula_ids": unmapped_ids,
|
||||
"python_only_formula_ids": python_only_ids,
|
||||
"data_gated_formula_ids": data_gated_formula_ids,
|
||||
"rows": rows,
|
||||
"gate": "PASS" if runtime_counts["UNMAPPED"] == 0 else "FAIL",
|
||||
}
|
||||
@@ -132,7 +158,8 @@ def main() -> int:
|
||||
|
||||
formula_ids = _collect_formula_ids()
|
||||
audit = _load_json(audit_path)
|
||||
result = _build_registry(formula_ids, audit)
|
||||
data_gated_ids = _load_data_gated_formula_ids()
|
||||
result = _build_registry(formula_ids, audit, data_gated_ids)
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
out_path.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user