fix(marriage): counting method reports a neutral geometry index only; real Parivartana no longer crashes (BUG-1183/1184)

TASK-upstream-sync4-20261002 T1 (upstream yinduzhanxing 0afa2780 for the
idea; wording is ours, in Chinese, per decision 2). _interpret_marriage_count
and _marriage_recommendations no longer state relationship counts, order,
quality or loyalty; the Marriage-counting evidence is always neutral and
carries only geometric_index (the dead D9-quality line in the adjudication is
removed). The count is computed before the Parivartana override (the old order
raised UnboundLocalError) and the exchange check now tests a real exchange
instead of a conjunction with the dispositor.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
This commit is contained in:
Jesse_Chen
2026-10-02 14:01:13 +08:00
co-authored by Claude Opus 5.5
parent bc9b9f89bb
commit ba97fd5980
4 changed files with 128 additions and 84 deletions
+3 -7
View File
@@ -5196,13 +5196,11 @@ class JyotishAPIHandler(BaseHTTPRequestHandler, VedastroEvidenceMixin, SynastryM
'Marriage-counting',
'D1/D9',
marriage_counting.get('interpretation'),
'positive' if (marriage_counting.get('marriage_count') or 0) <= 1 else 'neutral',
# BUG-1183: a geometry index, not a relationship count; never graded.
'neutral',
'moderate',
source='full_reading.modules.marriage_counting',
details={
'marriage_count': marriage_counting.get('marriage_count'),
'd9_marriage_quality': marriage_counting.get('d9_marriage_quality'),
},
details={'geometric_index': marriage_counting.get('geometric_index', marriage_counting.get('marriage_count'))},
))
vivah = full_modules.get('vivah_saham') if isinstance(full_modules, dict) else {}
if isinstance(vivah, dict) and vivah.get('vivah_saham'):
@@ -5819,7 +5817,6 @@ class JyotishAPIHandler(BaseHTTPRequestHandler, VedastroEvidenceMixin, SynastryM
seventh_sign = seventh.get('sign') or '未知'
seventh_planets = seventh.get('planets_label') or '无'
d9_quality = (((counting.get('details') or {}).get('d9_marriage_quality')) or {})
timing_conclusion = str(timing.get('conclusion') or '').strip()
vivah_conclusion = str(vivah.get('conclusion') or '').strip()
manifestation_core = self._strip_humanized_prefix(humanized.get('manifestation_mode'))
@@ -5845,7 +5842,6 @@ class JyotishAPIHandler(BaseHTTPRequestHandler, VedastroEvidenceMixin, SynastryM
"对象筛选这一轴,是当前婚恋判断里最不能跳过的一层。",
f"严格链已经明确当前落地形式更偏{manifestation_core},也就是说重点不是立刻确认关系,而是先看谁值得继续推进。",
str(counting.get('conclusion') or ''),
d9_quality.get('quality_rating') or '',
"这类组合更像先识别重复的关系模式,再决定是否深入,而不是因为出现线索就直接抬升成结婚窗口。",
f"时间边界:{humanized.get('time_confidence')}",
]),
+35 -77
View File
@@ -3,13 +3,16 @@ Marriage Counting Method (婚姻计数法) —— Bhrigu 体系 v7.0
Jyotish Vedic Astrology Skill
来源:bhrigu-pada-dasha-marriage-counting.md
算法:D1 第7宫主在 D1 的星座(A) → D9 的星座(B) → 从A数到B = 婚姻次数
算法:D1 第7宫主在 D1 的星座(A) → D9 的星座(B) → 从A数到B(含首尾)= 关系几何指数
产品口径(TASK-upstream-sync4-20261002 决策 2,BUG-1183):本模块只输出几何指数,
不输出婚姻或关系的次数、先后与质量断语。字段 marriage_count 为兼容旧消费方保留,
值与 geometric_index 相同。
v7.0 新增:
- Parivartana自动重算(原为TODO)
- D9 Venus/Mars/7宫主完整状态评估
- Upapada Loga整合
- 每段关系的质量预测
"""
from typing import Dict, Optional, List
@@ -50,7 +53,8 @@ def marriage_counting_method(
'point_A': {'sign': int, 'sign_cn': str}, # D1 中7宫主星座
'point_B': {'sign': int, 'sign_cn': str}, # D9 中7宫主星座
'distance': int, # 从A数到B (包含A和B)
'marriage_count': int, # 婚姻/认真关系数量
'geometric_index': int, # 关系几何指数(不是婚姻或关系次数)
'marriage_count': int, # 兼容字段,同 geometric_index
'interpretation': str, # 解读
'parivartana': dict or None, # Parivartana 检查结果
'warnings': list,
@@ -78,6 +82,14 @@ def marriage_counting_method(
d9_lon = d9_planet_lons[d1_house7_lord]
point_B = sign_of(d9_lon)
# Step 4: 计数 (从 A 到 B,包含 A 和 B)。须在 Parivartana 重算之前求出:
# 旧代码先在警告里引用 distance 再赋值,有交换时抛 UnboundLocalError(BUG-1184)。
if point_B >= point_A:
distance = point_B - point_A + 1
else:
# 跨越白羊座0°: 从 A 到双鱼座(11) + 从白羊座(0) 到 B
distance = (11 - point_A + 1) + (point_B + 1)
# Parivartana 检查
parivartana = None
if parivartana_check and d1_houses:
@@ -107,13 +119,6 @@ def marriage_counting_method(
# 使用交换后的结果
distance = distance_swapped
# Step 4: 计数 (从 A 到 B,包含 A 和 B)
if point_B >= point_A:
distance = point_B - point_A + 1
else:
# 跨越白羊座0°: 从 A 到双鱼座(11) + 从白羊座(0) 到 B
distance = (11 - point_A + 1) + (point_B + 1)
marriage_count = distance
# 解读
@@ -133,6 +138,7 @@ def marriage_counting_method(
'degree': d9_lon,
},
'distance': distance,
'geometric_index': marriage_count,
'marriage_count': marriage_count,
'interpretation': interpretation,
'parivartana': parivartana,
@@ -164,10 +170,10 @@ def _check_parivartana(
return {'has_parivartana': False, 'reason': f'{host} 位置未知'}
host_sign = sign_of(d1_planet_lons[host])
lord_own_sign = sign_of(d1_planet_lons.get(lord, 0))
# Parivartana: lord 在 host 的星座里,host 在 lord 的星座里
if host_sign == lord_own_sign and lord_sign == sign_of(d1_planet_lons.get(host, 0)):
# Parivartana: lord 在 host 的星座里(host 的定义已保证),host 在 lord 掌管的星座里。
# 旧写法比较 host 与 lord 是否同星座,实际判的是合相而非互换(BUG-1184)。
if SIGN_LORDS[host_sign] == lord:
return {
'has_parivartana': True,
'planet1': lord,
@@ -181,27 +187,15 @@ def _check_parivartana(
def _interpret_marriage_count(count: int, A: int, B: int) -> str:
"""解读婚姻计数结果"""
lines = []
lines.append(f"婚姻/认真关系数量:{count}")
if count == 1:
lines.append("解读:一次终身关系,忠诚度较高。")
if A == B:
lines.append(" D1与D9同星座 → 关系稳定,不易动摇。")
elif count == 2:
lines.append("解读:两段重要关系,可能再婚或长期关系更替。")
elif count == 3:
lines.append("解读:多段关系,关系模式较为复杂。")
elif count >= 4:
lines.append(f"解读:{count}段关系,关系频繁变化,需检视关系模式中的重复问题。")
# 特殊位置解读
"""只描述几何量,不推出婚姻或关系的次数、先后与质量(BUG-1183)。"""
lines = [
f"关系几何指数 {count}:D1 第7宫主所在星座数到它在 D9 所在星座的距离(含首尾),"
"是这个方法里的星座距离,不代表婚姻或关系的次数。"
]
if A == B:
lines.append("⭐ A=B(D1与D9同星座):内在一致,关系忠诚度高。")
if (B - A) % 12 == 6: # 对冲
lines.append("⚠️ A与B对冲:内在矛盾,关系中的拉锯与不稳定性。")
lines.append("D1 与 D9 两个参照点落在同一星座。")
if (B - A) % 12 == 6:
lines.append("D1 与 D9 两个参照点落在相对的星座。")
return "\n".join(lines)
@@ -238,7 +232,7 @@ def marriage_counting_full_analysis(
**base,
'd9_marriage_quality': d9_quality,
'recommendations': recommendations,
'note': '此法的"婚姻"指持续1年以上的认真关系,不一定是法律婚姻。',
'note': '几何指数只是方法内的星座距离,不是婚姻或关系的计数。',
}
@@ -374,48 +368,12 @@ def _assess_d9_marriage_quality(
def _marriage_recommendations(base: Dict, d9_quality: Dict) -> List[str]:
"""生成综合建议 v7.0"""
recs = []
count = base['marriage_count']
if count == 1:
recs.append("重点经营唯一关系,避免第三者介入。")
elif count == 2:
recs.append("第一次关系需认真经营;若结束,第二次关系质量需提前评估。")
# v7.0: 增加每段关系质量预测
recs.append("第一段关系通常受D1 7宫主状态影响,第二段受D9 7宫主状态影响。")
else:
recs.append("需检视关系模式中的重复问题(依恋类型、沟通方式等)。")
recs.append("每段关系的质量递进:第一段=D1质量,后续逐渐转向D9质量。")
# v7.0: 每段关系质量预测
if count >= 2 and 'point_A' in base and 'point_B' in base:
a = base['point_A']['sign']
b = base['point_B']['sign']
# 第一段关系:从A开始的质量
SIGN_LORDS_LIST = ['Mars','Venus','Mercury','Moon','Sun','Mercury',
'Venus','Mars','Jupiter','Saturn','Saturn','Jupiter']
BENEFICS = {'Jupiter', 'Venus', 'Moon', 'Mercury'}
a_lord = SIGN_LORDS_LIST[a]
if a_lord in BENEFICS:
recs.append(f"第一段关系由吉星{a_lord}主导,质量较好。")
else:
recs.append(f"第一段关系由{a_lord}主导,可能较为激烈或辛苦。")
# D9 质量建议
q_rating = d9_quality['quality_rating']
if '低' in q_rating or '中下' in q_rating:
recs.append("D9显示婚姻关系有挑战 → 建议在Dasha吉期内主动经营关系。")
recs.append("强烈建议婚前/关系前进行专业占星咨询。")
elif '高' in q_rating:
recs.append("D9显示婚姻关系质量高 → 珍惜并维护现有关系。")
elif '中上' in q_rating:
recs.append("D9显示婚姻关系基础好 → 持续投入可获良好回报。")
recs.append("建议配合 Vimshottari/Chara Dasha 确认具体结婚/分手时间。")
recs.append("注意:此法给出数量框架,具体事件需通过 Dasha + Transit 精确定位。")
return recs
"""几何指数与伴侣数量、事件断语分开(BUG-1183);不随指数大小给不同结论。"""
return [
"几何指数需与 D1 第7宫主、它在 D9 的落点以及已记录的尊贵因素一起读,不单独下结论。",
"这个指数不指认第几位伴侣,也不说明关系的长短、好坏或是否专一。",
"涉及时间的判断须另看已算出的 Dasha 与过运,并以本人的实际经历为准。",
]
# 导出函数