릴리스 DAG와 실현 성과 게이트 연결

This commit is contained in:
2026-06-18 01:48:17 +09:00
parent fee8131d5d
commit d7f9d3a944
7 changed files with 365 additions and 14 deletions
+8 -5
View File
@@ -16,6 +16,9 @@
"ops:package": "python tools/refresh_trading_calendar.py && python tools/prepare_upload_zip.py --validation-mode release --profile",
"prepare-upload-zip": "python tools/refresh_trading_calendar.py && python tools/prepare_upload_zip.py",
"ops:audit": "python tools/harness_coverage_auditor.py",
"build-realized-performance": "python tools/build_realized_performance_v1.py",
"validate-completion-harness": "python tools/validate_completion_harness_instructions_v1.py",
"validate-realized-performance": "python tools/validate_realized_performance_v1.py",
"validate-gas-recovery": "python tools/validate_gas_orchestration_recovery_v1.py",
"ops:clean": "python tools/clean_temp_artifacts_v1.py",
"ops:dev": "node core_satellite_collector.js",
@@ -26,14 +29,14 @@
"render-report-json": "python tools/render_operational_report.py --json GatherTradingData.json --output Temp/operational_report.md --report-json-output Temp/operational_report.json"
},
"dependencies": {
"cheerio": "latest",
"cheerio": "1.2.0",
"googleapis": "^171.4.0",
"iconv-lite": "latest",
"yahoo-finance2": "latest"
"iconv-lite": "0.7.2",
"yahoo-finance2": "3.15.3"
},
"optionalDependencies": {
"adm-zip": "latest",
"fast-xml-parser": "latest"
"adm-zip": "0.5.17",
"fast-xml-parser": "5.8.0"
},
"devDependencies": {
"xlsx": "^0.18.5"
+57 -2
View File
@@ -1,5 +1,5 @@
schema_version: release_dag.v3
step_count: 87
step_count: 90
goal: Linearize package.json scripts into a validated DAG execution graph.
execution_order:
# 토폴로지 정렬 기준 병렬 실행 wave (의존성 없는 노드들을 동시에 실행 가능)
@@ -21,6 +21,7 @@ execution_order:
- validate_calibration
- validate_cash_ledger
- validate_change_requests
- validate_completion_harness_instructions
- validate_factor_lifecycle
- validate_factor_lifecycle_completeness
- validate_field_dict
@@ -41,6 +42,7 @@ execution_order:
- build_etf_representative_monitor
- build_factor_shadow_eligibility
- build_formula_outputs
- build_realized_performance
- build_missing_formula_bridge
- build_ratchet_trailing_general
- build_rebalance_sheet
@@ -54,6 +56,7 @@ execution_order:
- validate_engine_health_card
- validate_module_io_coverage
- validate_no_replay_live_mix
- validate_realized_performance
- validate_rule_lifecycle
- validate_schema_model
wave_2:
@@ -148,6 +151,18 @@ dag:
artifact_policy: "keep"
note: "DATA_GATED 항목별 실측 진척도 — non-blocking diagnostic"
build_realized_performance:
id: build_realized_performance
command: ["python", "tools/build_realized_performance_v1.py"]
inputs: ["tools/build_realized_performance_v1.py", "GatherTradingData.json", "Temp/proposal_evaluation_history.json"]
outputs: ["Temp/realized_performance_v1.json"]
depends_on: ["build_data_gated_progress"]
timeout_sec: 30
cache_key: "build_realized_performance_v1"
strict: false
artifact_policy: "keep"
note: "WBS-4.1 realized performance replay summary — non-blocking diagnostic"
build_factor_shadow_eligibility:
id: build_factor_shadow_eligibility
command: ["python", "tools/build_factor_shadow_eligibility_v1.py"]
@@ -566,6 +581,18 @@ dag:
strict: true
artifact_policy: "keep"
validate_realized_performance:
id: validate_realized_performance
command: ["python", "tools/validate_realized_performance_v1.py"]
inputs: ["tools/validate_realized_performance_v1.py", "Temp/realized_performance_v1.json"]
outputs: ["Temp/validate_realized_performance_v1.json"]
depends_on: ["build_realized_performance"]
timeout_sec: 30
cache_key: "validate_realized_performance_v1"
strict: true
artifact_policy: "keep"
note: "REALIZED_PERFORMANCE_V1 output schema and evidence validation"
validate_runtime_source_whitelist:
id: validate_runtime_source_whitelist
command: ["python", "tools/validate_runtime_source_whitelist_v1.py", "--manifest", "runtime/active_artifact_manifest.yaml", "--scan", "src", "gas_*.gs"]
@@ -785,6 +812,34 @@ dag:
strict: true
artifact_policy: "keep"
validate_completion_harness_instructions:
id: validate_completion_harness_instructions
command: ["python", "tools/validate_completion_harness_instructions_v1.py"]
inputs:
[
"tools/validate_completion_harness_instructions_v1.py",
"AGENTS.md",
"REPORT_GUIDE.md",
"docs/runbook.md",
"docs/ROADMAP_WBS.md",
"docs/doctrine.md",
"prompts/analysis_prompt.md",
"prompts/review_prompt.md",
"prompts/capture_parse_prompt.md",
"prompts/engine_audit_master_prompt_v2.md",
"prompts/engine_audit_master_prompt_v3.md",
"prompts/engine_audit_prompt.md",
"prompts/low_capability_report_renderer.md",
"prompts/report_renderer_prompt.md",
"prompts/weekly_operational_report_master_prompt_v1.md"
]
outputs: ["Temp/completion_harness_instructions_v1.json"]
depends_on: []
timeout_sec: 30
cache_key: "validate_completion_harness_instructions_v1"
strict: true
artifact_policy: "keep"
validate_engine_health_card:
id: validate_engine_health_card
command: ["python", "tools/validate_engine_health_card_v1.py", "--json", "Temp/engine_health_card_v1.json"]
@@ -1159,7 +1214,7 @@ dag:
command: ["python", "tools/prepare_upload_zip.py", "--skip-validate", "--skip-convert", "--validation-mode", "package-only"]
inputs: ["tools/prepare_upload_zip.py"]
outputs: []
depends_on: ["audit_entropy", "validate_specs", "validate_active_manifest", "validate_report_sync", "validate_report_numeric_consistency", "validate_field_dict", "validate_provenance", "validate_low_capability", "validate_golden_coverage", "validate_calibration", "validate_schema_model", "validate_gas_adapter", "validate_agents_shrink", "validate_no_replay_live_mix", "validate_runtime_source_whitelist", "validate_cash_ledger", "validate_factor_lifecycle", "validate_factor_lifecycle_completeness", "validate_metric_alias_collision", "validate_architecture_boundaries", "validate_module_io_coverage", "validate_artifact_chain_hash", "validate_artifact_sync", "validate_renderer_no_calc", "validate_packaged_refs", "validate_property_invariants", "validate_anti_late_entry", "validate_rule_lifecycle", "validate_change_requests", "validate_engine_health_card", "validate_llm_regression", "validate_llm_copy_only", "build_final_decision", "build_final_context", "build_provenance_ledger", "build_live_replay_separation", "build_late_chase_attribution", "build_profit_giveback_ratchet", "build_shadow_ledger", "build_operating_cadence_signal", "build_engine_health_card", "build_module_io_coverage", "build_artifact_chain_hash", "build_report", "build_bundle", "build_schema_models", "build_architecture_boundaries", "validate_decision_trace", "validate_factor_conflicts", "validate_no_lookahead", "validate_execution_sim", "validate_render_diff", "build_shadow_promotion", "validate_llm_determinism", "build_time_stop_forecast", "validate_live_activation", "build_rebalance_sheet"]
depends_on: ["audit_entropy", "validate_specs", "validate_active_manifest", "validate_report_sync", "validate_report_numeric_consistency", "validate_field_dict", "validate_provenance", "validate_low_capability", "validate_golden_coverage", "validate_calibration", "validate_schema_model", "validate_gas_adapter", "validate_agents_shrink", "validate_no_replay_live_mix", "validate_realized_performance", "validate_runtime_source_whitelist", "validate_cash_ledger", "validate_factor_lifecycle", "validate_factor_lifecycle_completeness", "validate_metric_alias_collision", "validate_architecture_boundaries", "validate_module_io_coverage", "validate_artifact_chain_hash", "validate_artifact_sync", "validate_renderer_no_calc", "validate_packaged_refs", "validate_property_invariants", "validate_anti_late_entry", "validate_rule_lifecycle", "validate_change_requests", "validate_completion_harness_instructions", "validate_engine_health_card", "validate_llm_regression", "validate_llm_copy_only", "build_final_decision", "build_final_context", "build_provenance_ledger", "build_live_replay_separation", "build_late_chase_attribution", "build_profit_giveback_ratchet", "build_shadow_ledger", "build_operating_cadence_signal", "build_engine_health_card", "build_module_io_coverage", "build_artifact_chain_hash", "build_report", "build_bundle", "build_schema_models", "build_architecture_boundaries", "validate_decision_trace", "validate_factor_conflicts", "validate_no_lookahead", "validate_execution_sim", "validate_render_diff", "build_shadow_promotion", "validate_llm_determinism", "build_time_stop_forecast", "validate_live_activation", "build_rebalance_sheet"]
timeout_sec: 60
cache_key: "prepare_zip_v1"
strict: true
+36
View File
@@ -3,9 +3,12 @@ from __future__ import annotations
import argparse
import json
import zipfile
from functools import lru_cache
from datetime import datetime, timezone
from pathlib import Path
import yaml
from tools.orchestration_harness_v1 import run_plan
from src.quant_engine.pipeline_runtime_anomaly_lib_v1 import finalize_runtime_profile, runtime_profile_from_steps
@@ -86,6 +89,8 @@ TEMP_KEEP_FILES = {
"canonical_artifact_resolver_v1.json",
"final_execution_decision_v2.json",
"prediction_accuracy_harness_v2.json",
"realized_performance_v1.json",
"validate_realized_performance_v1.json",
"single_truth_ledger_v2.json",
"smart_cash_recovery_v7.json",
"smart_cash_recovery_v9.json",
@@ -107,6 +112,35 @@ UPLOAD_KEEP_DIRS_UPLOAD = {
}
@lru_cache(maxsize=1)
def _active_manifest_refs() -> set[str]:
manifest_path = ROOT / "runtime" / "active_artifact_manifest.yaml"
if not manifest_path.exists():
return set()
try:
manifest = yaml.safe_load(manifest_path.read_text(encoding="utf-8")) or {}
except Exception:
return set()
refs: set[str] = set()
if isinstance(manifest, dict):
canonical = manifest.get("canonical_source")
if isinstance(canonical, str) and canonical.strip():
refs.add(Path(canonical).as_posix())
aliases = manifest.get("active_aliases")
if isinstance(aliases, dict):
for val in aliases.values():
if isinstance(val, str) and val.strip():
refs.add(Path(val).as_posix())
rows = manifest.get("manifest_rows")
if isinstance(rows, list):
for row in rows:
if isinstance(row, dict):
active_artifact = row.get("active_artifact")
if isinstance(active_artifact, str) and active_artifact.strip():
refs.add(Path(active_artifact).as_posix())
return refs
def _load_json(path: Path) -> dict:
if not path.exists():
return {}
@@ -151,6 +185,8 @@ def should_include(path: Path, mode: str, include_xlsx: bool, include_backups: b
return False
if path.name == DEFAULT_OUTPUT.name:
return False
if mode == "upload" and rel.as_posix() in _active_manifest_refs():
return True
if parts[0] == "Temp":
if path.name in TEMP_EXCLUDED_FILES:
return False
+1 -1
View File
@@ -300,7 +300,7 @@ def main() -> int:
out_path.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
s = result["summary"]
print(
f"[{FORMULA_ID}] T20_replay_CAGR(est)={s.get('best_estimated_cagr_pct')}% "
f"[{FORMULA_ID}] T20_replay_CAGR(est)={s.get('best_estimated_cagr')}% "
f"Sharpe(est)={s.get('best_estimated_sharpe')} "
f"MDD_worst={s.get('worst_case_mdd_pct')}% "
f"T5_win_rate={s.get('t5_win_rate_pct')}% -> {out_path}"
+19 -6
View File
@@ -82,7 +82,7 @@ def main() -> int:
def add_to_closure(nid):
if nid not in closure:
closure.add(nid)
for dep in nodes[nid].get("depends_on") or []:
for dep in sorted(nodes[nid].get("depends_on") or []):
if dep in nodes:
add_to_closure(dep)
@@ -99,14 +99,14 @@ def main() -> int:
raise ValueError(f"Cycle detected involving {nid}")
if nid not in visited:
temp.add(nid)
for dep in nodes[nid].get("depends_on") or []:
for dep in sorted(nodes[nid].get("depends_on") or []):
if dep in closure:
visit(dep)
temp.remove(nid)
visited.add(nid)
order.append(nid)
for nid in closure:
for nid in sorted(closure):
if nid not in visited:
try:
visit(nid)
@@ -116,6 +116,8 @@ def main() -> int:
steps_run = []
success = True
warning_failed = False
warning_failures: list[dict[str, object]] = []
LINEAGE_LOG.parent.mkdir(parents=True, exist_ok=True)
@@ -180,6 +182,11 @@ def main() -> int:
print(proc.stderr)
if node.get("warn_only", False):
print(f"Node {nid} is warn_only - continuing")
warning_failed = True
warning_failures.append({
"node_id": nid,
"returncode": proc.returncode,
})
else:
success = False
if node.get("strict", True) or args.strict:
@@ -191,17 +198,23 @@ def main() -> int:
"formula_id": "RELEASE_DAG_RUN_V4",
"mode": args.mode,
"steps": steps_run,
"gate": "PASS" if success else "FAIL"
"warning_failures": warning_failures,
"gate": "PASS" if success and not warning_failed else "PASS_WITH_WARNINGS" if success else "FAIL"
}, ensure_ascii=False, indent=2), encoding="utf-8")
print(json.dumps({
"formula_id": "RELEASE_DAG_RUN_V4",
"mode": args.mode,
"step_count": len(steps_run),
"gate": "PASS" if success else "FAIL"
"warning_failure_count": len(warning_failures),
"gate": "PASS" if success and not warning_failed else "PASS_WITH_WARNINGS" if success else "FAIL"
}, ensure_ascii=True, indent=2))
return 0 if success else 1
if not success:
return 1
if args.strict and warning_failed:
return 1
return 0
if __name__ == "__main__":
@@ -0,0 +1,148 @@
#!/usr/bin/env python3
from __future__ import annotations
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def _read(rel: str) -> str:
path = ROOT / rel
if not path.exists():
return ""
return path.read_text(encoding="utf-8", errors="replace").lower()
def _require_any(text: str, options: list[str]) -> bool:
return any(option.lower() in text for option in options)
def _require_all(text: str, groups: list[list[str]]) -> bool:
return all(_require_any(text, group) for group in groups)
def main() -> int:
files: dict[str, list[list[str]]] = {
"AGENTS.md": [
["0b. 기본 하네스 완료 조건"],
["yaml"],
["코드"],
["데이터 실체"],
["검증 증빙"],
],
"docs/runbook.md": [
["complete only when", "완료"],
["yaml"],
["code"],
["data artifact", "data artifacts", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"docs/ROADMAP_WBS.md": [
["완료 조건"],
["yaml"],
["코드"],
["데이터 실체"],
["검증 증빙"],
],
"REPORT_GUIDE.md": [
["completion harness"],
["yaml"],
["code"],
["data artifact", "data artifacts", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"docs/doctrine.md": [
["completion harness"],
["yaml"],
["code"],
["data artifact", "data artifacts", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/analysis_prompt.md": [
["default completion harness"],
["yaml"],
["코드"],
["데이터 실체"],
["검증 증빙"],
],
"prompts/review_prompt.md": [
["default completion harness"],
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/capture_parse_prompt.md": [
["기본 완료 조건"],
["yaml"],
["코드"],
["데이터 실체"],
["검증 증빙"],
],
"prompts/engine_audit_master_prompt_v2.md": [
["default completion harness"],
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/engine_audit_master_prompt_v3.md": [
["default completion harness"],
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/engine_audit_prompt.md": [
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/low_capability_report_renderer.md": [
["default completion harness"],
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/report_renderer_prompt.md": [
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
"prompts/weekly_operational_report_master_prompt_v1.md": [
["default completion harness"],
["yaml"],
["code"],
["data artifact", "data/artifact"],
["validation evidence", "검증 증빙"],
],
}
missing: list[dict[str, object]] = []
for rel, groups in files.items():
text = _read(rel)
if not text:
missing.append({"file": rel, "reason": "missing_file"})
continue
if not _require_all(text, groups):
missing.append({"file": rel, "reason": "missing_required_text", "required_groups": groups})
result = {
"formula_id": "COMPLETION_HARNESS_INSTRUCTIONS_V1",
"gate": "PASS" if not missing else "FAIL",
"checked_files": len(files),
"missing": missing,
}
out = ROOT / "Temp" / "completion_harness_instructions_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 if not missing else 1
if __name__ == "__main__":
raise SystemExit(main())
+96
View File
@@ -0,0 +1,96 @@
"""validate_realized_performance_v1.py — REALIZED_PERFORMANCE_VALIDATE_V1
Temp/realized_performance_v1.json의 존재와 기본 스키마를 검증한다.
데이터가 충분하지 않은 구간은 allow-listed insufficient_data 상태로만 허용한다.
"""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any
ROOT = Path(__file__).resolve().parents[1]
DEFAULT_INPUT = ROOT / "Temp" / "realized_performance_v1.json"
DEFAULT_OUT = ROOT / "Temp" / "validate_realized_performance_v1.json"
FORMULA_ID = "REALIZED_PERFORMANCE_VALIDATE_V1"
def _load(path: Path) -> Any:
if not path.exists():
return {}
try:
return json.loads(path.read_text(encoding="utf-8"))
except Exception:
return {}
def _is_nonempty_dict(v: Any) -> bool:
return isinstance(v, dict) and len(v) > 0
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("--input", default=str(DEFAULT_INPUT))
ap.add_argument("--out", default=str(DEFAULT_OUT))
args = ap.parse_args()
input_path = Path(args.input)
input_path = input_path if input_path.is_absolute() else ROOT / input_path
out_path = Path(args.out)
out_path = out_path if out_path.is_absolute() else ROOT / out_path
payload = _load(input_path)
missing: list[dict[str, object]] = []
if not _is_nonempty_dict(payload):
missing.append({"field": "file", "reason": "missing_or_invalid_json"})
else:
if payload.get("formula_id") != "REALIZED_PERFORMANCE_V1":
missing.append({
"field": "formula_id",
"reason": "unexpected_value",
"expected": "REALIZED_PERFORMANCE_V1",
})
for field in ["performance_metrics", "current_portfolio_mdd", "insufficient_data_items", "summary"]:
if field not in payload:
missing.append({"field": field, "reason": "missing_key"})
perf = payload.get("performance_metrics")
if isinstance(perf, dict):
for key in ["t1_operational", "t5_operational", "t20_replay_estimated"]:
block = perf.get(key)
if not _is_nonempty_dict(block):
missing.append({"field": f"performance_metrics.{key}", "reason": "missing_block"})
continue
if "label" not in block or "n" not in block:
missing.append({"field": f"performance_metrics.{key}", "reason": "missing_label_or_n"})
summary = payload.get("summary")
if isinstance(summary, dict):
if "disclaimer" not in summary:
missing.append({"field": "summary.disclaimer", "reason": "missing_key"})
if "best_estimated_source" not in summary:
missing.append({"field": "summary.best_estimated_source", "reason": "missing_key"})
mdd = payload.get("current_portfolio_mdd")
if not _is_nonempty_dict(mdd):
missing.append({"field": "current_portfolio_mdd", "reason": "missing_block"})
else:
if "worst_case_scenario" not in mdd:
missing.append({"field": "current_portfolio_mdd.worst_case_scenario", "reason": "missing_key"})
result = {
"formula_id": FORMULA_ID,
"gate": "PASS" if not missing else "FAIL",
"checked_file": str(Path(args.input).as_posix()),
"missing": missing,
}
out_path.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(json.dumps(result, ensure_ascii=False, indent=2))
return 0 if not missing else 1
if __name__ == "__main__":
raise SystemExit(main())