Files
Jyotisha/scripts/report_render/technique_status_axes.py
T
ClaudeandClaude Opus 5.5 6dacd779d2
Independent Staging Quality Gate / validate-frontend (push) Successful in 5m51s
Independent Staging Quality Gate / validate-python (push) Successful in 7m50s
Independent Staging Quality Gate / publish (push) Successful in 3m39s
fix(report): astrologer 11-25 site-vs-local comparison fixes (BUG-2364–2376)
- 2364 KP sub-lord in the Nakshatra Reference: proportional, not equal ninths (upstream calc_sub_lord)
- 2365 birth-time sensitivity KP cusps: Placidus + Krishnamurti, same source as the formal KP table
- 2366 expression paths: D2/D11/D24/D4 house counted from the varga's own ascendant
- 2367 Bhavesh table: PD-only lord labelled, not "Yes", when the PD range is not stable
- 2368 KP cusp table: very strong significator is a lead, not a promise
- 2369 yoga wording: no blanket "cancellation not checked"; detector match is not "conditions hold"
- 2370 Neecha self-reference marked per condition
- 2371 reading guide: feedback only in rectification; all applicable systems, two dashas minimum
- 2372 audit table: progress/index rows are observation only
- 2373 Saptavargaja by chart
- 2374 Manahoo interferer never one of the pair (upstream 322e2f30)
- 2375 KP monthly table seeded under the KP profile (owner-approved frozen-file edit) + profile line
- 2376 annual continuous motion: full event list per year in the appendix (owner-approved)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
2026-11-25 16:54:52 +08:00

156 lines
7.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Calculation and interpretation axes shared with the consultation audit."""
import re
CALCULATION_LABELS = {
"executed": "已执行", "partial": "部分执行", "blocked": "阻塞", "not_applicable": "不适用",
}
INTERPRETATION_LABELS = {
"primary": "主要依据", "supporting": "辅助依据", "conditional": "有条件",
"observation_only": "仅观察", "blocked": "不作判断", "not_used": "不参与",
}
CALCULATION_LABELS_EN = {
"executed": "Calculation completed",
"partial": "Calculation partially completed",
"blocked": "Calculation blocked",
"not_applicable": "Calculation not applicable",
"not_run": "Calculation not completed",
}
INTERPRETATION_LABELS_EN = {
"primary": "primary interpretive basis",
"supporting": "supporting interpretive evidence",
"conditional": "conditional interpretation",
"observation_only": "observation only",
"blocked": "no interpretation",
"not_used": "excluded from interpretation",
}
FUNCTIONAL_PROFILE_LABELS = {"pvr_table30_v1": "PVR 表 30", "bphs_exception_profile": "BPHS 例外表"}
CONDITIONAL_EVIDENCE = {
"parameter_sensitive", "profile_sensitive", "single_system_inference",
"unclosed_divisional_chart", "user_history_verification_required",
}
_CANDIDATE = re.compile(
r"^(?:used|executed|已执行)?\s*[((]\s*(?:候选|candidate)\s*[))]$|^(?:候选|candidate|single_system_candidate)$",
re.I,
)
_CALCULATION_ALIASES = {
"partial": ("partial", "部分执行", "部分", "不足", "insufficient"),
"executed": ("已执行", "已匹配", "used", "executed", "complete", "official_verified", "pass", "ready", "ok", "matched"),
"not_applicable": ("不适用", "not_applicable", "n/a", "na", "not applicable"),
}
_INTERPRETATION_ALIASES = {
"primary": ("primary", "主要依据", "主要"),
"supporting": ("supporting", "辅助依据", "辅助"),
"conditional": ("conditional", "有条件", "条件性", "候选", "candidate"),
"observation_only": ("observation_only", "observation only", "仅观察", "观察"),
"blocked": ("blocked", "不作判断", "阻塞"),
}
def _key(value):
return str(value or "").strip().lower().replace(chr(96), "").replace("*", "")
def parse_technique_calculation_status(value, has_result=True):
normalized = _key(value)
if normalized in CONDITIONAL_EVIDENCE:
return "executed" if has_result else "partial"
if _CANDIDATE.fullmatch(str(value or "").strip()):
return "executed"
return next((key for key, labels in _CALCULATION_ALIASES.items() if normalized in labels), "blocked")
def parse_technique_audit_status(value, has_result=True):
calculation = parse_technique_calculation_status(value, has_result)
if _key(value) in CONDITIONAL_EVIDENCE or _CANDIDATE.fullmatch(str(value or "").strip()):
interpretation = "conditional"
else:
interpretation = {
"executed": "primary", "not_applicable": "not_used", "partial": "conditional", "blocked": "blocked",
}[calculation]
return {"calculation_status": calculation, "interpretation_status": interpretation}
def _has_result(packet, row):
if row.get("result"):
return True
worksheets = packet.get("worksheets") or {}
timing = worksheets.get("timing_and_predictive_systems") or {}
advanced = worksheets.get("advanced_systems") or {}
strengths = worksheets.get("strengths_and_scores") or {}
technique = row.get("technique")
if technique in ("Narayana Dasha", "Narayana / Patyayini / Tajika Parity"):
narayana = timing.get("narayana_dasha") or {}
return bool(narayana.get("current_dasha") or narayana.get("branches") or narayana.get("mahadasha"))
paths = {
"Vimshottari Dasha": (timing, "dasha"),
"KP Lord/Sub": (advanced, "kp"),
"Annual Tajika": (timing, "annual_tajika_pack"),
"Functional Benefic/Malefic": (strengths, "functional_benefic_malefic"),
}
source, key = paths.get(technique, ({}, None))
result = source.get(key)
return isinstance(result, dict) and bool(result) and not result.get("error") and result.get("status") != "blocked"
def technique_audit_axes(packet, row):
status = _key(row.get("status"))
if isinstance(row.get("calculation_status"), str):
calculation = parse_technique_calculation_status(row["calculation_status"])
raw_interpretation = _key(row.get("interpretation_status"))
interpretation = next((key for key, labels in _INTERPRETATION_ALIASES.items()
if raw_interpretation in labels), "not_used")
axes = {"calculation_status": calculation, "interpretation_status": interpretation}
else:
axes = parse_technique_audit_status(row.get("status"), _has_result(packet, row))
if status in CONDITIONAL_EVIDENCE:
axes["interpretation_evidence"] = status
if axes["calculation_status"] == "partial":
axes["calculation_gap"] = "calculation_result_missing"
elif status and axes["calculation_status"] == "blocked" and status not in ("blocked", "not_run", "not run", "未完成"):
axes["calculation_gap"] = status
# BUG-2372: progress and index rows are not an interpretive basis. "External Oracle Progress" was printed
# as "calculation completed, primary interpretive basis" while its own note says the checks are partial.
if row.get("technique") in _INDEX_ROWS:
axes["interpretation_status"] = "observation_only"
if row.get("technique") == "External Oracle Progress" and axes["calculation_status"] == "executed":
axes["calculation_status"] = "partial"
return axes
_INDEX_ROWS = ("External Oracle Progress", "Interpretation Source Pack")
def technique_audit_text(row, axes, language):
calculation = axes["calculation_status"]
interpretation = axes["interpretation_status"]
evidence = axes.get("interpretation_evidence")
if evidence:
# BUG-2095: the condition in words (was the code, e.g. `parameter_sensitive`).
from .reader_keys import reader_key
evidence = reader_key(evidence, language)
unfinished = _key(row.get("status")) in ("not_run", "not run", "未完成") or _key(row.get("calculation_status")) in ("not_run", "未完成")
if language == "en":
calc = CALCULATION_LABELS_EN["not_run" if unfinished else calculation]
suffix = f" ({evidence})" if evidence else ""
return f"{calc}, {INTERPRETATION_LABELS_EN[interpretation]}{suffix}"
calc = "未完成" if unfinished else CALCULATION_LABELS[calculation]
suffix = f"({evidence})" if evidence else ""
return f"计算{calc},解读{INTERPRETATION_LABELS[interpretation]}{suffix}"
def functional_profile_text(value, language="zh"):
if not value:
return "profile not specified" if language == "en" else "口径未注明"
labels = {"pvr_table30_v1": "PVR Table 30", "bphs_exception_profile": "BPHS exception table"} if language == "en" else FUNCTIONAL_PROFILE_LABELS
label = labels.get(value)
if label is None:
from .reader_keys import reader_key
return str(reader_key(str(value), language))
# 原值:「PVR 表 30(pvr_table30_v1)」/ "PVR Table 30 (pvr_table30_v1)"。
# 新值:只写口径名;版本只在功能吉凶表的口径一行(functional_layer_table)写一次。
# 原因:BUG-2095,读者正文不出现内部版本代码。
return label