fix(rectification): restore classic eight methods and observe KP Placidus cusps
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import saham_daynight # noqa: E402
|
||||
import special_lagnas # noqa: E402
|
||||
import varga # noqa: E402
|
||||
from scripts.rectification.refinement_packet import NAKSHATRA_SPAN # noqa: E402
|
||||
from scripts.rectification.kp_cusp_observation import observe_kp_cusps # noqa: E402
|
||||
|
||||
AYANAMSA: Final = "lahiri"
|
||||
NODE_MODE: Final = "mean"
|
||||
@@ -61,9 +62,12 @@ DOMAIN_CONFIG: Final[dict[EventDomain, DomainConfig]] = {
|
||||
"family": (("D12", "D7", "D3"), (3, 4, 5, 9)),
|
||||
# Dated appearance/marks: D1 lagna / 1st house only. Not a primary formula.
|
||||
"appearance": ((), (1,)),
|
||||
# Occupation notes: D10 + D1 10th house, auxiliary, no type labels.
|
||||
"occupation": (("D10",), (10,)),
|
||||
}
|
||||
AUXILIARY_DOMAINS: Final[frozenset[str]] = frozenset({"appearance"})
|
||||
AUXILIARY_DOMAINS: Final[frozenset[str]] = frozenset({"appearance", "occupation"})
|
||||
AUXILIARY_SCORE_FACTOR: Final = 0.4
|
||||
OBSERVATION_ONLY_LAYERS: Final[frozenset[str]] = frozenset({"KP_cusps"})
|
||||
|
||||
|
||||
class RectificationEventCalculationError(RuntimeError):
|
||||
@@ -234,7 +238,11 @@ def _score_event(
|
||||
if sign_index is not None and _relative_house(sign_index, ascendant_index) in target_houses:
|
||||
rules.append(f"{label}_domain_house")
|
||||
points += weight
|
||||
arudha_keys = ("A7", "UL") if event["domain"] == "relationship" else ("A10",) if event["domain"] == "career" else ()
|
||||
arudha_keys = (
|
||||
("A7", "UL") if event["domain"] == "relationship"
|
||||
else ("A10",) if event["domain"] in {"career", "occupation"}
|
||||
else ()
|
||||
)
|
||||
arudha_signs = {
|
||||
value.get("sign_idx") for key in arudha_keys
|
||||
if isinstance((value := arudha_padas.get(key)), dict) and isinstance(value.get("sign_idx"), int)
|
||||
@@ -249,7 +257,11 @@ def _score_event(
|
||||
event_kind = event.get("event_kind", event["domain"])
|
||||
if event["domain"] in AUXILIARY_DOMAINS:
|
||||
points *= AUXILIARY_SCORE_FACTOR
|
||||
rules.append("appearance_auxiliary_not_primary")
|
||||
rules.append(
|
||||
"occupation_auxiliary_not_primary"
|
||||
if event["domain"] == "occupation"
|
||||
else "appearance_auxiliary_not_primary"
|
||||
)
|
||||
if not rules:
|
||||
rules.append("no_domain_activation")
|
||||
rules.append(f"event_kind:{event_kind}")
|
||||
@@ -435,7 +447,7 @@ def build_candidate_static_context(
|
||||
for prefix in ("D2", "D3", "D4", "D5", "D7", "D9", "D10", "D11", "D12", "D24", "D30")
|
||||
}
|
||||
available_layers = ["D1"]
|
||||
blocked_layers = ["KP_cusps"]
|
||||
blocked_layers: list[str] = []
|
||||
varga_ascendants: dict[str, int] = {}
|
||||
for prefix, value in varga_charts.items():
|
||||
ascendant = (value or {}).get("Ascendant") or {}
|
||||
@@ -471,6 +483,17 @@ def build_candidate_static_context(
|
||||
except (KeyError, TypeError, ValueError):
|
||||
blocked_layers.append("Shadbala")
|
||||
|
||||
birth_info = chart.get("birth_info") if isinstance(chart.get("birth_info"), dict) else {}
|
||||
kp_snapshot = observe_kp_cusps(
|
||||
birth_info.get("julian_day"),
|
||||
float(request["lat"]),
|
||||
float(request["lon"]),
|
||||
)
|
||||
if kp_snapshot.get("status") == "executed":
|
||||
available_layers.append("KP_cusps")
|
||||
else:
|
||||
blocked_layers.append("KP_cusps")
|
||||
|
||||
feature_payload = {
|
||||
"time": candidate_at.strftime("%H:%M"),
|
||||
"ascendant_degree": ascendant_longitude,
|
||||
@@ -484,6 +507,8 @@ def build_candidate_static_context(
|
||||
sun_degree=planet_longitudes.get("Sun") if isinstance(planet_longitudes.get("Sun"), (int, float)) else None,
|
||||
moon_degree=planet_longitudes.get("Moon") if isinstance(planet_longitudes.get("Moon"), (int, float)) else None,
|
||||
),
|
||||
**(kp_snapshot.get("indices") or {}),
|
||||
"kp_cusps": kp_snapshot,
|
||||
"varga_ascendants": varga_ascendants,
|
||||
"arudha_signs": arudha_signs,
|
||||
"available_layers": sorted(set(available_layers)),
|
||||
@@ -585,7 +610,10 @@ def _candidate_row(
|
||||
"time": candidate_at.strftime("%H:%M"),
|
||||
"score": round(sum(item["points"] for item in evidence), 4),
|
||||
"evidence": evidence,
|
||||
"missing_layers": sorted(set(missing_layers + context["feature"]["blocked_layers"])),
|
||||
"missing_layers": sorted(set(
|
||||
missing_layers
|
||||
+ [layer for layer in context["feature"]["blocked_layers"] if layer not in OBSERVATION_ONLY_LAYERS]
|
||||
)),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user