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

52 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Select the default market data provider for research packets."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any
ROOT = Path(__file__).resolve().parents[1]
DEFAULT_REGISTRY = ROOT / "references" / "market_research" / "market_provider_registry_v1.json"
def _load(path: Path) -> dict[str, Any]:
payload = json.loads(path.read_text(encoding="utf-8"))
return payload if isinstance(payload, dict) else {}
def select_provider(*, asset_class: str, registry_path: Path = DEFAULT_REGISTRY) -> dict[str, Any]:
registry = _load(registry_path)
providers = registry.get("providers") if isinstance(registry.get("providers"), list) else []
normalized_asset = str(asset_class or "").strip().lower()
candidates = [
row for row in providers
if isinstance(row, dict) and normalized_asset in {str(item).lower() for item in row.get("asset_classes") or []}
]
candidates.sort(key=lambda row: int(row.get("priority") or 999))
selected = candidates[0] if candidates else {}
return {
"schema": "jyotish.market_provider_selection.v1",
"status": "selected" if selected else "blocked",
"asset_class": normalized_asset,
"provider": selected,
"candidate_count": len(candidates),
"boundary": str(registry.get("boundary") or ""),
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--asset-class", required=True)
parser.add_argument("--registry", type=Path, default=DEFAULT_REGISTRY)
args = parser.parse_args()
print(json.dumps(select_provider(asset_class=args.asset_class, registry_path=args.registry), ensure_ascii=False, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())