Files
Jyotisha/scripts/niryaana_shoola_dasha.py
T
Jesse_ChenandCursor 04ad3325d5
Independent Staging Quality Gate / validate (push) Successful in 11m26s
Independent Staging Quality Gate / publish (push) Successful in 13m24s
fix(relationship): freeze marriage event classes and add conditional dashas (BUG-608)
Venus/Jupiter/Moon periods no longer collapse into one marriage-opportunity line. Full reading reports the ten BPHS conditional dasha families; Skill 6.9.16.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 16:04:52 +08:00

124 lines
4.4 KiB
Python

#!/usr/bin/env python3
"""Source-bounded Niryaana Shoola Dasha Mahadasha producer."""
from __future__ import annotations
from datetime import datetime, timedelta
from typing import Any
YEAR_DAYS = 365.25636
TOTAL_CYCLE = 108
SIGNS = (
"Aries",
"Taurus",
"Gemini",
"Cancer",
"Leo",
"Virgo",
"Libra",
"Scorpio",
"Sagittarius",
"Capricorn",
"Aquarius",
"Pisces",
)
def _sign_index(longitude: float) -> int:
return int(float(longitude) % 360.0 // 30.0)
def _forward_order(start_sign_index: int) -> list[int]:
return [(int(start_sign_index) + offset) % 12 for offset in range(12)]
def niryaana_shoola_applicability(
*, ascendant_longitude: float, lagna_strength: float, seventh_strength: float
) -> dict[str, Any]:
"""Select stronger Lagna/seventh start sign; unresolved ties stay blocked."""
lagna_sign = _sign_index(ascendant_longitude)
seventh_sign = (lagna_sign + 6) % 12
lagna_strength = float(lagna_strength)
seventh_strength = float(seventh_strength)
if lagna_strength == seventh_strength:
return {
"applicable": False,
"execution_status": "blocked",
"ascendant_sign_index": lagna_sign,
"seventh_sign_index": seventh_sign,
"lagna_strength": lagna_strength,
"seventh_strength": seventh_strength,
"rule_family": "goel_niryaana_shoola_stronger_lagna_or_seventh",
"reason": "Niryaana Shoola start sign requires a declared stronger Lagna or seventh sign; tie-break profile is not closed.",
}
start = lagna_sign if lagna_strength > seventh_strength else seventh_sign
return {
"applicable": True,
"ascendant_sign_index": lagna_sign,
"seventh_sign_index": seventh_sign,
"lagna_strength": lagna_strength,
"seventh_strength": seventh_strength,
"starting_sign_index": start,
"starting_sign": SIGNS[start],
"rule_family": "goel_niryaana_shoola_stronger_lagna_or_seventh",
"reason": "Niryaana Shoola starts from the stronger of Lagna and seventh sign.",
}
def calculate_niryaana_shoola_dasha(birth_info: dict[str, Any]) -> dict[str, Any]:
"""Return forward 9-year sign rows; AD/PD remain blocked."""
required = ("birth_datetime", "ascendant_longitude", "lagna_strength", "seventh_strength")
missing = [field for field in required if birth_info.get(field) is None]
if missing:
return {
"applicable": False,
"execution_status": "blocked",
"confidence_status": "blocked",
"reason": "Missing required input: " + ", ".join(missing),
"major": [],
}
birth = birth_info["birth_datetime"]
if isinstance(birth, str):
birth = datetime.fromisoformat(birth)
applicability = niryaana_shoola_applicability(
ascendant_longitude=float(birth_info["ascendant_longitude"]),
lagna_strength=float(birth_info["lagna_strength"]),
seventh_strength=float(birth_info["seventh_strength"]),
)
if not applicability["applicable"]:
return {
**applicability,
"confidence_status": "blocked",
"total_cycle": TOTAL_CYCLE,
"major": [],
}
year_days = float(birth_info.get("dasha_year_days") or YEAR_DAYS)
rows = []
cursor = birth
for sign_index in _forward_order(int(applicability["starting_sign_index"])):
end = cursor + timedelta(days=9.0 * year_days)
rows.append(
{
"level": "mahadasha",
"sign_index": sign_index,
"sign": SIGNS[sign_index],
"years": 9,
"start_date": cursor.isoformat(timespec="seconds"),
"end_date": end.isoformat(timespec="seconds"),
}
)
cursor = end
return {
**applicability,
"execution_status": "executed",
"confidence_status": "parameter_sensitive",
"verification_status": "source_bounded_local_candidate",
"period_depth_status": "mahadasha_executed_ad_pd_blocked_pending_row_level_replay",
"total_cycle": TOTAL_CYCLE,
"dasha_year_days": year_days,
"major": rows,
"reason": "Local source-bounded MD calculation; strength source, AD/PD, and runtime wiring remain explicitly gated.",
"source_locator": "VP Goel / public Jaimini summaries: stronger Lagna-or-seventh start, direct order, 9 years per sign, 108-year cycle.",
}