G0~G8 성과·동맹 측정 OS 작업 일괄 고정
8월 7일까지 워킹트리에만 남아 있던 미커밋 작업을 커밋한다. 여러 사본 폴더(worktree·clone)에 흩어져 있던 중간 스냅샷을 정리하기 전에 원본을 git 이력으로 고정하는 것이 목적이다. - contracts/routes/services: measurement, outcome_trajectory, rupture_repair, deliberate_practice, calibration_transfer, supervision_research, multimodal_alliance, continuous_improvement 계열 신규 모듈과 테스트 - infra/db/init: 07~16 마이그레이션(측정 기반~calibration transfer 실행) - apps/web: 세션 리뷰 카드·관리 화면·E2E 스펙 추가 - docs/ops: G0~G8 라이브 통합·배포·롤백 증거 문서와 evidence JSON/PNG - scripts: smoke·ledger·릴리스 에이전트·NAS 프리뷰 운영 스크립트 engine.public 로그 .bak과 apps/web/test-results 산출물은 커밋에서 제외했다.
This commit is contained in:
parent
93dd8f82d7
commit
16e791e044
390 changed files with 243188 additions and 499 deletions
86
scripts/compare-alliance-calibration.py
Normal file
86
scripts/compare-alliance-calibration.py
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Compare two versioned Alliance calibration snapshots against the G0 gold pack."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
API_ROOT = REPO_ROOT / "apps" / "api"
|
||||
if str(API_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(API_ROOT))
|
||||
|
||||
from app.contracts.measurement import BenchmarkCase # noqa: E402
|
||||
from app.services.alliance_calibration import ( # noqa: E402
|
||||
AllianceCalibrationSnapshot,
|
||||
compare_alliance_snapshots,
|
||||
gold_reference_snapshot,
|
||||
render_alliance_comparison_markdown,
|
||||
)
|
||||
|
||||
|
||||
def _read_json(path: Path) -> Any:
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--baseline", type=Path)
|
||||
parser.add_argument("--gold-baseline", action="store_true")
|
||||
parser.add_argument("--candidate", type=Path, required=True)
|
||||
parser.add_argument(
|
||||
"--benchmark",
|
||||
type=Path,
|
||||
default=API_ROOT / "app" / "data" / "outcome_alliance_benchmark_g0.v1.json",
|
||||
)
|
||||
parser.add_argument("--out-json", type=Path, required=True)
|
||||
parser.add_argument("--out-md", type=Path, required=True)
|
||||
parser.add_argument("--min-direction-accuracy", type=float, default=0.0)
|
||||
args = parser.parse_args()
|
||||
|
||||
benchmark_payload = _read_json(args.benchmark)
|
||||
cases = tuple(
|
||||
BenchmarkCase.model_validate(item) for item in benchmark_payload["cases"]
|
||||
)
|
||||
if args.gold_baseline == (args.baseline is not None):
|
||||
parser.error("choose exactly one of --baseline or --gold-baseline")
|
||||
baseline = (
|
||||
gold_reference_snapshot(cases)
|
||||
if args.gold_baseline
|
||||
else AllianceCalibrationSnapshot.model_validate(_read_json(args.baseline))
|
||||
)
|
||||
candidate = AllianceCalibrationSnapshot.model_validate(_read_json(args.candidate))
|
||||
report = compare_alliance_snapshots(baseline, candidate, cases)
|
||||
args.out_json.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.out_md.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.out_json.write_text(
|
||||
json.dumps(report, ensure_ascii=False, indent=2, default=str) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
args.out_md.write_text(
|
||||
render_alliance_comparison_markdown(report),
|
||||
encoding="utf-8",
|
||||
)
|
||||
accuracy = float(report["candidate"]["direction_accuracy"])
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"candidate_direction_accuracy": accuracy,
|
||||
"candidate_evidence_recall": report["candidate"]["evidence_recall"],
|
||||
"candidate_missing_or_failed": report["candidate"]["missing_or_failed_count"],
|
||||
"mean_absolute_score_delta": report["drift"]["mean_absolute_score_delta"],
|
||||
"report": str(args.out_md),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
)
|
||||
return 0 if accuracy >= args.min_direction_accuracy else 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue