Files
Jyotisha/scripts/market_astrology_benchmark.py
T
ClaudeandClaude Opus 5.5 6a57faacdb feat(consult): run the astrologer's upstream skill in full (BUG-1696, BUG-1697, BUG-1698)
- root SKILL.md is her upstream file (body byte-identical to the 5fb8379c mirror; description quoted so YAML parses and Mastra can load the skill)
- chat binds the whole SKILL.md plus references/product_runtime_contract.md (safety-only) instead of a ~477-character excerpt
- every turn carries her full strict-workflow-router (synced to upstream) and the domain's event-judgment file; product lists follow as an extra layer
- import her 10 sub-skills, family router, interpretation status contract, technique ontology and the 54 files her method names
- tests/test_upstream_skill_parity.py (in the quick gate) fails whenever her skill and ours drift
- 18 frontend guards that locked the excerpt design updated with 原值/新值/原因 notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-07 14:02:26 +08:00

82 lines
3.1 KiB
Python

#!/usr/bin/env python3
"""Benchmark harness for market / financial astrology research."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any
SCHEMA = "jyotish.market_astrology_benchmark.v1"
def _as_dict(value: Any) -> dict[str, Any]:
return value if isinstance(value, dict) else {}
def build_market_astrology_benchmark(
*,
research_pack: dict[str, Any] | None,
feature_store: dict[str, Any] | None = None,
) -> dict[str, Any]:
research_pack = _as_dict(research_pack)
feature_store = _as_dict(feature_store or research_pack.get("feature_store"))
backtest = _as_dict(research_pack.get("backtest"))
metrics = _as_dict(backtest.get("metrics"))
rows = feature_store.get("rows") if isinstance(feature_store.get("rows"), list) else []
labels = feature_store.get("labels") if isinstance(feature_store.get("labels"), list) else []
sample_count = int(metrics.get("sample_count") or len(rows) or 0)
hit_count = int(metrics.get("hit_count") or 0)
hit_rate = metrics.get("hit_rate")
if hit_rate is None and sample_count:
hit_rate = round(hit_count / sample_count, 3)
return {
"schema": SCHEMA,
"status": "ready" if sample_count else "blocked",
"summary": {
"sample_count": sample_count,
"hit_count": hit_count,
"hit_rate": hit_rate,
"label_count": len(labels),
"missing_sections": list(research_pack.get("missing_sections") or []),
},
"source_status": {
"research_pack_status": research_pack.get("status") or "blocked",
"feature_store_status": feature_store.get("status") or "blocked",
"backtest_status": backtest.get("status") or "blocked",
},
"quality_flags": {
"has_price_rows": bool(rows),
"has_labels": bool(labels),
"has_feature_store": bool(feature_store),
},
"audit": {
"technique_audit": [
{"technique": "Market benchmark harness", "status": "used" if sample_count else "blocked"},
{"technique": "Walk-forward metrics", "status": backtest.get("status") or "blocked"},
{"technique": "Feature store reuse", "status": feature_store.get("status") or "blocked"},
],
"claim_boundary": "This benchmark summarizes research packets only; it does not validate trading profits.",
},
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--research-pack", type=Path, required=True)
parser.add_argument("--feature-store", type=Path)
args = parser.parse_args()
research_pack = json.loads(args.research_pack.read_text(encoding="utf-8"))
feature_store = json.loads(args.feature_store.read_text(encoding="utf-8")) if args.feature_store else None
report = build_market_astrology_benchmark(research_pack=research_pack, feature_store=feature_store)
print(json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())