Files
Jyotisha/scripts/market_astrology_runner.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

116 lines
4.3 KiB
Python

#!/usr/bin/env python3
"""Unified runner for the repo's market astrology workflow."""
from __future__ import annotations
try: # reached as a script: this directory is on the path, the root is not
import _script_root # noqa: F401
except ModuleNotFoundError: # pragma: no cover - reached as scripts.x instead
try:
from scripts import _script_root # noqa: F401
except ModuleNotFoundError:
pass
import argparse
import json
from pathlib import Path
from typing import Any
from scripts.market_astrology_benchmark import build_market_astrology_benchmark
from scripts.market_astrology_research_pack import build_market_astrology_research_pack
from scripts.market_provider_federation import fetch_federated_market_prices
def _as_dict(value: Any) -> dict[str, Any]:
return value if isinstance(value, dict) else {}
def _as_list(value: Any) -> list[Any]:
return value if isinstance(value, list) else []
def _load_json(path: Path | None) -> Any:
if path is None:
return None
return json.loads(path.read_text(encoding="utf-8"))
def run_market_astrology_workflow(
*,
market_profile: dict[str, Any] | None,
astro_signals: list[dict[str, Any]] | None,
price_series: list[dict[str, Any]] | None = None,
labels: list[dict[str, Any]] | None = None,
benchmark: dict[str, Any] | None = None,
case_notes: dict[str, Any] | None = None,
use_provider: bool = False,
) -> dict[str, Any]:
market_profile = _as_dict(market_profile)
astro_signals = _as_list(astro_signals)
if use_provider:
provider_packet = fetch_federated_market_prices(
asset_class=str(market_profile.get("asset_class") or ""),
symbol=str(market_profile.get("symbol") or ""),
market_profile=market_profile,
)
price_series = provider_packet.get("price_series") if isinstance(provider_packet.get("price_series"), list) else []
else:
provider_packet = {
"schema": "jyotish.market_provider_federation.v1",
"status": "not_used",
"price_series": [],
}
research_pack = build_market_astrology_research_pack(
market_profile=market_profile,
astro_signals=astro_signals,
price_series=price_series,
labels=labels,
benchmark=benchmark,
case_notes=case_notes,
)
benchmark_report = build_market_astrology_benchmark(research_pack=research_pack)
return {
"schema": "jyotish.market_astrology_runner.v1",
"status": "ready" if research_pack.get("status") in {"ready_for_backtest", "partial"} else "blocked",
"market_profile": research_pack.get("market_profile") or market_profile,
"provider_packet": provider_packet,
"research_pack": research_pack,
"benchmark_report": benchmark_report,
"audit": {
"technique_audit": [
{"technique": "Market astrology runner", "status": "used"},
{"technique": "Provider packet", "status": provider_packet.get("status", "not_used")},
{"technique": "Research pack", "status": research_pack.get("status", "blocked")},
{"technique": "Benchmark report", "status": benchmark_report.get("status", "blocked")},
]
},
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--market-profile", type=Path, required=True)
parser.add_argument("--astro-signals", type=Path, required=True)
parser.add_argument("--price-series", type=Path)
parser.add_argument("--labels", type=Path)
parser.add_argument("--benchmark", type=Path)
parser.add_argument("--case-notes", type=Path)
parser.add_argument("--use-provider", action="store_true")
args = parser.parse_args()
result = run_market_astrology_workflow(
market_profile=_load_json(args.market_profile),
astro_signals=_load_json(args.astro_signals),
price_series=_load_json(args.price_series),
labels=_load_json(args.labels),
benchmark=_load_json(args.benchmark),
case_notes=_load_json(args.case_notes),
use_provider=args.use_provider,
)
print(json.dumps(result, ensure_ascii=False, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())