Files
Jyotisha/scripts/research/sarvatobhadra_external.py
ClaudeandClaude Opus 5.5 ac9be6f88c feat(techniques): port the astrologer upstream skill's missing techniques
Port from yinduzhanxing 5fb8379c (MIT): Naisargika, Kaala, Karaka, Tara,
Lagnamsaka, Yogardha, Mandooka, Paryaaya and Padanadhamsa dashas;
Sarvatobhadra, Kota and Kalanala chakras; Nakshatra Latta; Pachakadi;
Raman Amsayu and Pindayu. Producers and their upstream tests are copied;
scripts/upstream_technique_layers.py feeds them our natal and transit
positions and attaches chart.consultation_native_layers.upstream_techniques.

- dasha_registry: kaala and padanadhamsa keys (35 -> 37); the nine ported
  dashas are served by compute_dasha or fail closed with upstream's reason.
- technique_registry.json: 16 partial entries; README badges follow.
- Evidence lookup section `upstream_techniques` in the consultation tool.
- Boundaries: Kalanala carries no PyJHora (AGPL) grid coordinates;
  Padanadhamsa/Lagnamsaka run on our Narayana engine (no Rath Table 12,
  PVR co-lord variants or second cycle). PyJHora observers and the Amsayu
  worked-example scaffold live in scripts/research (root .py budget).
- PyJHora black-box cross-checks: Naisargika (lords/years) and Kaala
  (seed segment and fraction within 5e-4) on a public chart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-07 14:44:37 +08:00

76 lines
4.5 KiB
Python

"""Read the installed PyJHora SBC grid as data, without importing Qt or executing UI code."""
import json
import subprocess
import sys
from copy import deepcopy
from scripts.research.kota_chakra_external import PLANETS
def build_sarvatobhadra_external_report(*, stars, ayanamsa, timeout=30):
if not isinstance(stars, dict) or set(stars) != set(PLANETS):
raise ValueError('all nine planetary star indices required')
if any(type(v) is not int or not 1 <= v <= 27 for v in stars.values()):
raise ValueError('planetary star indices must be integers 1..27')
if not isinstance(ayanamsa, str) or not ayanamsa.strip():
raise ValueError('explicit ayanamsa required')
evidence = dict(technique='sarvatobhadra_chakra', status='blocked', ayanamsa=ayanamsa,
variant_profile_id='sarvatobhadra_pyjhora_literal_grid_v1',
source_url='https://github.com/naturalstupid/PyJHora/blob/main/src/jhora/ui/chakra.py',
claim_boundary='External grid/placement only; no Vedha, Latta, natal Panchaka matching or event interpretation.')
# Parse the external literal; do not import QWidget or execute extracted code.
code = '''import ast, json, importlib.util, hashlib
from pathlib import Path
from importlib.metadata import version
p = Path(importlib.util.find_spec('jhora').origin).parent / 'ui/chakra.py'
source = p.read_bytes()
tree = ast.parse(source)
cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == 'Sarvatobadra')
init = next(n for n in cls.body if isinstance(n, ast.FunctionDef) and n.name == '__init__')
matches = [n for n in init.body if isinstance(n, ast.Assign) and any(isinstance(t, ast.Attribute) and t.attr == '_grid_label_values' for t in n.targets)]
if len(matches) != 1: raise ValueError('ambiguous grid definition')
print(json.dumps(dict(grid=ast.literal_eval(matches[0].value), version=version('PyJHora'), source_sha256=hashlib.sha256(source).hexdigest())))
'''
try:
run = subprocess.run([sys.executable, '-c', code], text=True, capture_output=True,
timeout=timeout, check=True)
raw = json.loads(run.stdout)
grid = raw['grid']
if len(grid) != 9 or any(len(row) != 9 for row in grid):
raise ValueError('unexpected grid shape')
cells, index = [], {}
for r, line in enumerate(grid):
for c, value in enumerate(line):
border = r in (0, 8) or c in (0, 8)
kind = ('nakshatra' if border else 'rashi') if type(value) is int else 'text'
if kind == 'nakshatra':
if value in index:
raise ValueError('duplicate star')
index[value] = (r, c)
cells.append(dict(row=r, column=c, kind=kind, raw_label=value))
if set(index) != set(range(1, 29)):
raise ValueError('incomplete external star perimeter')
rows = [dict(planet=p, source_star_index=stars[p], row=index[stars[p]][0],
column=index[stars[p]][1]) for p in PLANETS]
evidence.update(status='external_observation_only', cells=cells, rows=rows,
pyjhora_version=raw['version'], source_sha256=raw['source_sha256'],
indexing='Upstream SBC uses original 1..27 stars directly; 28 is Abhijit. Do not reuse Kalanala ring indices.')
except (OSError, subprocess.SubprocessError, ValueError, TypeError, KeyError, StopIteration) as exc:
evidence['reason'] = 'external_sarvatobhadra_unavailable:' + type(exc).__name__
lines = ['# Sarvatobhadra Chakra — external grid', '', evidence['claim_boundary']]
if 'cells' in evidence:
lines += ['', '| ' + ' | '.join(str(i) for i in range(9)) + ' |', '| ' + ' | '.join(['---'] * 9) + ' |']
for r in range(9):
values = []
for cell in evidence['cells'][r*9:r*9+9]:
label = str(cell['raw_label'])
if cell['kind'] != 'text':
label = cell['kind'] + ':' + label
planets = [p['planet'] for p in rows if p['row'] == r and p['column'] == cell['column']]
values.append(label + ('<br>' + ', '.join(planets) if planets else ''))
lines.append('| ' + ' | '.join(values) + ' |')
else:
lines += ['', evidence['reason']]
return dict(status=evidence['status'], customer_export_admitted=False, evidence_appendix=[evidence],
exports=dict(ai_evidence_bundle=deepcopy(evidence), markdown='\n'.join(lines)))