Files
Jyotisha/tests/test_dispositor_cycle_resolution.py
T
Jesse_ChenandClaude Opus 5.5 bc9b9f89bb fix(engine): dispositor cycles are not collapsed to one planet; dasa convergence drops uncalibrated probabilities (upstream e9beae6b)
final_dispositor_from_chain and its regression test are upstream
yinduzhanxing e9beae6b; probability is None with probability_basis. The
Narayana convergence additions of that commit are out of scope.
TASK-upstream-sync4-20261002 T7.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
2026-10-02 13:56:31 +08:00

39 lines
1.4 KiB
Python

"""Do not collapse a directed dispositor cycle into an arbitrary terminal."""
import ast
from pathlib import Path
def resolver():
# Isolate the pure function without importing the large CLI and adapters.
source = Path(__file__).parents[1] / 'scripts/jyotish_engine.py'
tree = ast.parse(source.read_text())
node = next(n for n in tree.body if isinstance(n, ast.FunctionDef)
and n.name == 'final_dispositor_from_chain')
namespace = {}
exec(compile(ast.Module(body=[node], type_ignores=[]), str(source), 'exec'), namespace)
return namespace[node.name]
def chain(*names):
return [{'planet':a,'dispositor':b} for a,b in zip(names,names[1:])]
def test_cycle_rotation_and_leading_planet():
f = resolver()
expected = 'Cycle: Jupiter -> Mercury -> Jupiter'
assert f(chain('Mercury','Jupiter','Mercury')) == expected
assert f(chain('Jupiter','Mercury','Jupiter')) == expected
assert f(chain('Venus','Jupiter','Mercury','Jupiter')) == expected
def test_terminal_and_incomplete_are_distinct():
f = resolver()
assert f(chain('Sun','Mars','Saturn','Saturn')) == 'Saturn'
assert f(chain('Sun','Mars')) is None
assert f([]) is None
assert f(chain('Sun','Mars') + chain('Venus','Venus')) is None
def test_three_body_cycle_preserves_direction():
assert resolver()(chain('Sun','Mars','Moon','Sun')) == 'Cycle: Mars -> Moon -> Sun -> Mars'