Files
Jyotisha/scripts/report_render/yoga_reader_meaning.py
T
ClaudeandClaude Opus 5.5 ba4396d3ed
Independent Staging Quality Gate / validate-python (push) Successful in 7m51s
Independent Staging Quality Gate / validate-frontend (push) Successful in 6m23s
Independent Staging Quality Gate / publish (push) Successful in 2m49s
feat(yoga): the astrologer's 322e2f30 — yoga refreshed after Shadbala, one Budhaditya, Raman Bahu Puthra / Sareera Soukhya / Nishkapata by branch, plain reader lines (BUG-2406)
Owner 2026-11-26 approved items 1-4 (not Rogagrastha, not M10). Frozen
jyotish_engine.py / yoga_engine.py / yoga_rules.json changed only for these.
Her texts are rewritten without book/author names or disclaimers; Nishkapata
keeps its plain meaning instead of a conduct gate that printed another rule's
sentence. A combust Budhaditya says Mercury is combust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
2026-11-26 07:22:11 +08:00

83 lines
4.5 KiB
Python

"""BUG-2406 (负责人 2026-11-26 批准,占星师 322e2f30 ④): plain reader lines for a few yogas.
Adapted from her upstream ``scripts/yoga_reader_meaning.py``. Same trigger conditions: a line is
written only for a row whose recorded geometry supports it (a successful whole-rule result or a
named matched path), never for a failed, blocked or unsupported row. Her sentences are rewritten
to the owner's rules: plain statements, no 「不等于」「不能据此」 disclaimers, no book or author
(2026-11-16 answers commit, BUG-2129). Her Nishkapata 「传统含义」 line is not needed here: the rule's
own effect text now carries that meaning (yoga_rules.json, BUG-2406).
This is a presentation adapter only; it does not change detection or weights, and reads no
life history or user feedback.
"""
from __future__ import annotations
from typing import Any
_BLOCKED = {"blocked", "not_implemented", "evaluation_error", "conditions_not_met"}
_LINES = {
"kahala_yoga": (
"意志坚定,愿意主动承担任务,有带领他人的倾向。",
"Determined, willing to take on tasks, with a tendency to lead others.",
),
"mridanga_yoga": (
"个人影响力和号召力强,有领导的倾向,在承担责任时容易发挥出来。",
"Strong personal influence and magnetism, with a tendency to lead that shows when taking on responsibility.",
),
"bvr_satkathadisravana_yoga": (
"喜欢阅读、听讲和研习经典,对思想、信仰或传统知识有持续的兴趣。",
"Enjoys reading, listening and studying classical texts, with a lasting interest in ideas, faith or traditional knowledge.",
),
"bvr_bhratruvriddhi_precise": (
"兄弟姐妹之间互相扶持,能从彼此的发展中得益。",
"Siblings support one another and benefit from each other's progress.",
),
"bvr_buddhimaturya_yoga": (
"思考成熟、重视见识,习惯先把问题弄清楚再下判断。",
"Mature in thinking and values insight; tends to understand a problem before judging it.",
),
}
_DEBILITY = ("参与的行星有落陷,这些特质发挥得不够顺畅。",
" A participating planet is debilitated, so these traits come through less smoothly.")
def _rule(row: dict) -> str:
return str(row.get("rule_id") or row.get("id") or "")
def yoga_reader_tendency(row: Any, language: str = "zh") -> str:
"""The plain line for ``row``, or "" when its recorded geometry does not support one (her conditions)."""
if not isinstance(row, dict) or row.get("error_type"):
return ""
if any(row.get(key) in _BLOCKED for key in ("formation_status", "condition_status", "evidence_status")):
return ""
rule = _rule(row)
if rule not in _LINES:
return ""
zh = language != "en"
evidence = row.get("formation_evidence") if isinstance(row.get("formation_evidence"), dict) else {}
paths = set(evidence.get("matched_geometry_paths") or []) | set(evidence.get("matched_paths") or [])
checks = row.get("condition_checks") if isinstance(row.get("condition_checks"), dict) else {}
if rule in {"kahala_yoga", "mridanga_yoga"}:
recorded = row.get("condition_evidence") if isinstance(row.get("condition_evidence"), dict) else {}
definition = recorded.get("definition")
matched = bool(definition) and any(
isinstance(node, dict) and node.get("definition") == definition and node.get("matched") is True
for node in recorded.get("execution_trace") or [])
if not (matched and (row.get("traditional_effects") or row.get("traditional_effects_en") or row.get("effects"))):
return ""
text = _LINES[rule][0 if zh else 1]
limiting = (row.get("strength_factors") or {}).get("limiting_factors") or [] if isinstance(row.get("strength_factors"), dict) else []
if any(isinstance(f, dict) and f.get("kind") in {"d1_dignity", "d9_dignity"} and f.get("value") == "DEBILITATED"
for f in limiting):
text += _DEBILITY[0 if zh else 1]
return text
if rule == "bvr_satkathadisravana_yoga":
ok = "remarks_received_aspect" in paths and bool(checks.get("third_lord_received_benefic_aspects"))
elif rule == "bvr_bhratruvriddhi_precise":
ok = bool(paths & {"third_lord_benefic_connection", "mars_benefic_connection", "third_house_benefic_connection"})
else:
ok = bool(paths & {"definition", "remarks_distinct_benefic_companion"})
return _LINES[rule][0 if zh else 1] if ok else ""