Files
Jyotisha/scripts/research/capture_consult_evidence_card_golden.py
T
Jesse_ChenandClaude Opus 5.5 d5616c347e feat(engine): expose native technique layers in the consultation output
TASK-consult-evidence-card-v2-20260927 T1. New module
scripts/consultation_native_layers.py, thinly registered after the merged
engine fields in _attach_local_consultation_layers (no handler method, no new
forgery site). It writes one new top-level chart key,
chart.consultation_native_layers, kept out of chart.modules so the thematic
report's full_reading_module_count does not move:

- d9_summary: D9 lagna, each planet's D9 sign and dignity
  (jyotish_engine._get_dignity_level), Vargottama (_calc_vargottama),
  D1<->D9 reversals
- punarphoo (punarphoo.detect_punarphoo, observation_only)
- vivah_saham (jyotish_engine._calc_vivah_saham), day_night (gulika)
- slow_transits: Jupiter / Saturn / Rahu / Ketu now with natal house and the
  Jupiter / Saturn SAV / BAV, and the next twelve months' ingress / station
  dates (ephemeris_events; nodes by the same daily-noon sampling)
- double_transit: cmd_double_transit_pac for houses 1-12, conclusions only,
  plus DK / UL targets by the same PAC rule
- karakamsha, argala, dispositor_chains, inter_chart_linkage, moon_transit
  (lookup-only layers)
- annual_tajika on the annual route: build_annual_tajika_pack (annual lagna,
  Varshesha, Muntha, Mudda Dasha with dates, Sun / Moon / year-lord Tajika
  aspects), parameter_sensitive; blocked when the pack is not reliable,
  never natal data

A/B on 3 public AA charts x 4 routes: every existing output is identical,
only the new key is added; about 40 ms per workflow. Golden regenerated with
annual and timing routes (family workflow byte-identical apart from the new
key).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
2026-09-27 16:27:24 +08:00

114 lines
4.5 KiB
Python

"""Capture real engine consultation responses for the evidence-card tests.
Three public AA charts (Steve Jobs, Barack Obama, Elizabeth Taylor), the
research reference date, raman ayanamsa, mean nodes. Each chart carries the
family route (`workflow`) and, for evidence card v2, the annual
(`annual_workflow`) and timing (`timing_workflow`) routes with the frontend's
default twelve-month horizon. External VedAstro is not called (same stand-in
as the research runner). Each response is trimmed by key only: every kept
value is the engine's own value, unchanged.
PYTHONHASHSEED=0 python scripts/research/capture_consult_evidence_card_golden.py
"""
from __future__ import annotations
import json
import os
import sys
from pathlib import Path
from typing import Any
ROOT = Path(__file__).resolve().parents[2]
sys.path[:0] = [str(ROOT), str(ROOT / "scripts"), str(ROOT / "scripts" / "research")]
from consult_evidence_card_lib import ( # noqa: E402
AYANAMSA,
NODE_MODE,
QUESTIONS,
REFERENCE_DATE,
load_public_charts,
)
import consult_evidence_card_run as runner # noqa: E402
OUT = ROOT / "frontend" / "tests" / "fixtures" / "consult-evidence-card-golden.json"
TOP_KEEP = (
"success", "question", "routing", "consumer_context", "thematic_report",
"birth_time_sensitivity", "reference_transparency", "candidate_range",
"range_boundary_contexts",
)
RECTIFICATION_KEEP = ("effective_accuracy", "lagna_boundary", "summary", "enabled_vargas")
CHART_KEEP = (
"success", "birth", "ascendant", "planets", "houses", "shadbala", "dasha", "yogas",
# Evidence card v2: native technique layers (scripts/consultation_native_layers.py).
"consultation_native_layers",
)
EXTRA_ROUTES = (
("annual_workflow", {"id": "annual", "domain": "annual", "question": "未来一年重点是什么?"}),
("timing_workflow", {"id": "timing", "domain": "timing", "question": "接下来一年哪些时间点重要?"}),
)
MODULE_KEEP = (
"varga_spectrum", "shadbala", "arudha_padas", "jaimini", "narayana_dasha",
"ashtakavarga", "dasha_sub_periods", "kp_cusps", "gulika",
"functional_benefic_malefic", "kakshya", "yogas", "chara_dasha", "transits",
)
NARAYANA_KEEP = ("lagna_sign", "current_dasha", "current_year", "current_age", "mahadasha_sequence")
def _pick(value: dict[str, Any], keys: tuple[str, ...]) -> dict[str, Any]:
return {key: value[key] for key in keys if key in value}
def trim(workflow: dict[str, Any]) -> dict[str, Any]:
out = _pick(workflow, TOP_KEEP)
out["rectification"] = _pick(workflow.get("rectification") or {}, RECTIFICATION_KEEP)
chart = workflow.get("chart") or {}
kept_chart = _pick(chart, CHART_KEEP)
modules = _pick(chart.get("modules") or {}, MODULE_KEEP)
if isinstance(modules.get("narayana_dasha"), dict):
modules["narayana_dasha"] = _pick(modules["narayana_dasha"], NARAYANA_KEEP)
kept_chart["modules"] = modules
out["chart"] = kept_chart
return out
def main() -> int:
if os.environ.get("PYTHONHASHSEED") != "0":
raise SystemExit("Set PYTHONHASHSEED=0 before starting this process (ERR-111).")
runner._block_external_vedastro()
question = next(item for item in QUESTIONS if item["id"] == "family")
charts = []
for chart in load_public_charts(ROOT):
workflow = runner._run_workflow(runner._workflow_body(chart, question))
entry = {
"id": chart["id"],
"label": chart["label"],
"source": chart["source"],
"case_id": chart["case_id"],
"rodden_rating": chart["rodden_rating"],
"workflow": trim(workflow),
}
for key, extra in EXTRA_ROUTES:
entry[key] = trim(runner._run_workflow(runner._workflow_body(chart, extra)))
charts.append(entry)
payload = {
"source": "scripts/research/capture_consult_evidence_card_golden.py",
"note": "Real engine consultation_workflow responses for three public AA charts, trimmed by key only.",
"reference_date": REFERENCE_DATE,
"ayanamsa": AYANAMSA,
"node_mode": NODE_MODE,
"route": question["domain"],
"question": question["question"],
"extra_routes": {key: extra for key, extra in EXTRA_ROUTES},
"external_vedastro": "not_called",
"charts": charts,
}
OUT.write_text(json.dumps(payload, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
print(f"wrote {OUT} ({OUT.stat().st_size} bytes)")
return 0
if __name__ == "__main__":
raise SystemExit(main())