WBS-7.3/7.4/7.5/7.11: 거버넌스 문서 정합성 정리 + spec-코드 동기화 게이트

2026-06-21 비판적 리뷰에서 spec/governance YAML이 코드 상태와 어긋난
채로 방치되던 3개 구체적 사례를 발견하고 정정했다. 근본 원인(동기화를
보장하는 장치 없음)에 대응하는 신규 CI 게이트도 함께 추가한다.

- spec/aliases.yaml: deprecated alias 17건 제거(활성 참조 0건 확인 후,
  2026-06-30 데드라인 전). role: deprecated_redirect인 spec/03_risk_policy.yaml,
  spec/04_strategy_rules.yaml 2개만 실삭제 — spec/06_exit_policy.yaml은
  role: compatibility_index(영구유지 설계)였음을 재확인해 보존
- governance/gas_logic_migration_ledger_v1.yaml: 존재하지 않는 파일을
  canonical 구현으로 인용하던 오류 2건 발견·정정, parity 테스트 부재로
  GAS 코드 삭제 보류(F12/F13/F14)
- spec/13_formula_registry.yaml: OVERHANG_PRESSURE_V1의 "-500000"
  절대값 폴백을 avg_volume_5d 비례식으로 교체(EXPERT_PRIOR 등록)
- tools/validate_specs.py: validate_spec_code_sync() 신규 — has_code_implementation/
  code_path 필드가 있는 spec만 검사(점진적 롤아웃, 기존 PASS 상태 비파괴),
  12개 파일 1차 태깅
This commit is contained in:
2026-06-21 20:08:48 +09:00
parent ee4d1fdab8
commit 5166750b53
25 changed files with 351 additions and 165 deletions
+62 -4
View File
@@ -117,6 +117,10 @@ def validate_formula_registry(errors: list[str]) -> None:
"ALPHA_FEEDBACK_LOOP_V2", "ALPHA_LEAD_THRESHOLD_OPTIMIZER_V1",
# ENGINE_AUDIT — Python-tool-only 감사 게이트 (GAS 런타임 비개입)
"IMPUTED_DATA_EXPOSURE_GATE_V1",
# Phase-8 비기계적 매도전략 — confluence 기반 판단 게이트 (output_contract 구조)
"SHORT_INTEREST_RISK_GAUGE_V1", "QUALITATIVE_SELL_STRATEGY_V1",
"MARKET_REGIME_CLASSIFIER_V1", "SATELLITE_CANDIDATE_SCORE_V1",
"MICROSTRUCTURE_PRESSURE_FROM_ORDERBOOK_V1",
}
for formula_id, formula in all_formulas.items():
if not isinstance(formula, dict):
@@ -619,6 +623,62 @@ def validate_harness_contract_consistency(errors: list[str]) -> None:
fail(errors, f"harness_contract collection_key not checked in validator: {key}")
def validate_spec_code_sync(errors: list[str]) -> dict:
"""WBS-7.11(2026-06-22) — spec YAML이 code_path로 가리키는 파일이 실제로 존재하는지 검사.
has_code_implementation 필드가 있는 파일만 검사한다(점진적 롤아웃 — 필드가 없는
파일은 스킵되므로 1차 태깅이 기존 PASS 상태를 절대 깨지 않는다). redirect_only:true인
파일은 의도적으로 코드가 없는 순수 호환 인덱스이므로 code_path 검사 대상이 아니며,
has_code_implementation:true와 동시에 있으면 그 자체로 모순이라 fail한다.
"""
all_yaml_paths = sorted((ROOT / "spec").rglob("*.yaml")) + sorted((ROOT / "governance").rglob("*.yaml"))
total_files = len(all_yaml_paths)
checked = 0
missing = 0
for path in all_yaml_paths:
try:
data = yaml.safe_load(path.read_text(encoding="utf-8"))
except Exception:
continue
if not isinstance(data, dict):
continue
meta = data.get("meta") if isinstance(data.get("meta"), dict) else data
has_code = meta.get("has_code_implementation")
if has_code is None:
continue
redirect_only = bool(meta.get("redirect_only"))
checked += 1
if redirect_only and has_code:
fail(errors, f"spec_code_sync contradiction: {path} has redirect_only=true AND has_code_implementation=true")
missing += 1
continue
if not has_code:
continue
code_path = meta.get("code_path")
candidates = code_path if isinstance(code_path, list) else [code_path] if code_path else []
if not candidates:
fail(errors, f"spec_code_sync: {path} declares has_code_implementation=true but no code_path")
missing += 1
continue
for rel in candidates:
if not (ROOT / str(rel)).exists():
fail(errors, f"spec declares code_path that does not exist: {path} -> {rel}")
missing += 1
result = {
"formula_id": "SPEC_CODE_SYNC_V1",
"total_spec_files": total_files,
"checked_count": checked,
"missing_code_path_count": missing,
"sync_field_coverage_pct": round(100.0 * checked / total_files, 2) if total_files else 0.0,
"gate": "PASS" if missing == 0 else "FAIL",
}
out = ROOT / "Temp" / "spec_code_sync_v1.json"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
return result
def main() -> int:
errors: list[str] = []
@@ -660,10 +720,9 @@ def main() -> int:
manifest_text = (ROOT / "RetirementAssetPortfolio.yaml").read_text(encoding="utf-8")
for path in sorted((ROOT / "spec").rglob("*.yaml")):
rel = path.relative_to(ROOT).as_posix()
if rel not in manifest_text and rel not in {"spec/03_risk_policy.yaml", "spec/04_strategy_rules.yaml"}:
if rel not in manifest_text:
fail(errors, f"spec file not registered in manifest: {rel}")
if path.stat().st_size > MAX_SPEC_BYTES and path.name not in {
"03_risk_policy.yaml", "04_strategy_rules.yaml",
"13_formula_registry.yaml", "13b_harness_formulas.yaml",
"12_field_dictionary.yaml",
"51_formula_lifecycle_registry.yaml", # 290+ formula lifecycle registry (Proposal51-P1)
@@ -770,13 +829,12 @@ def main() -> int:
validate_formula_registry(errors)
validate_output_rendering_contract(schema, errors)
validate_harness_contract_consistency(errors)
validate_spec_code_sync(errors)
aliases = load_yaml(ROOT / "spec" / "aliases.yaml", errors) or {}
alias_map = aliases.get("aliases") or {}
alias_files = {
ROOT / "spec" / "aliases.yaml",
ROOT / "spec" / "03_risk_policy.yaml",
ROOT / "spec" / "04_strategy_rules.yaml",
ROOT / "spec" / "06_exit_policy.yaml",
ROOT / "spec" / "risk" / "risk_control.yaml",
ROOT / "spec" / "strategy" / "entry_gates.yaml",