产品 2026-11-07 占星师方案 (item 4/5/6/8/10): the report reading and the export follow her skill. - reading_facts v2 contract: birth parameters (no name/coordinates), 12 houses with KP cusps, functional roles and natural-vs-functional conflicts, per-domain vargas (wealth D2+D11+D10, A2/A11/A10; career D10+A10, AK/AmK; marriage D9+UL, A7/DK), special points, Jaimini, yogas as candidates with conditions, Vimshottari to PD + Narayana with dates (birth date + age) and the legacy variant, every dasha family's current period/status, transits from four reference points, Sade Sati, double transit, strengths, KP, annual, technique audit, evidence paths, method differences, blocked / parameter_sensitive / withheld states - consult card facts: multi-varga domains, A2/A11/A10/AK/A7 participation, D1 varga resolves, yoga path fixed, Narayana ages; KP is conditional (参数敏感) instead of 不参与 - report writer: professional prompt (evidence first, A/B/C, dual-track timing, status labels), ninth section 依据与边界 (stored reading v2; v1 still reads), Latin allowed, longer limits - export: technique audit chapter (Functional Benefic/Malefic, MEVG / Global Web Evidence, Real Case Calibration rows), parameter/method differences, dasha system status, evidence boundaries and the D1–D60 ledger (20 formal + 40 research D-N); upstream varga_evidence_matrix / generic_varga_research_audit + registries ported so the ledger is no longer blocked - ordinary projection no longer deletes technique audit / MEVG / 参数敏感; parameter_sensitive is relabelled 参数敏感 - quality gate: upstream technique_audit_table check restored, plus required-row check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
310 lines
13 KiB
Python
310 lines
13 KiB
Python
"""Auditable formal-varga metadata for later evidence-matrix analysis."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from datetime import datetime, timedelta
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
# This module is reached both as ``scripts.x`` from the repository root and as
|
|
# a plain sibling when jyotish_engine.py runs as a script, where sys.path[0] is
|
|
# scripts/. Its own dependencies use bare sibling imports, so scripts/ has to be
|
|
# importable either way; relying on some earlier import to have arranged that
|
|
# left the engine's golden cases failing with a ModuleNotFoundError naming the
|
|
# wrong module. See ERR-170.
|
|
_SCRIPTS_DIR = str(Path(__file__).resolve().parent)
|
|
if _SCRIPTS_DIR not in sys.path:
|
|
sys.path.insert(0, _SCRIPTS_DIR)
|
|
|
|
from domain_calculation_service import compute_chart # noqa: E402
|
|
from divisional_charts_extended import DivisionalChartsCalculator # noqa: E402
|
|
from generic_varga_research_audit import build_generic_varga_audit # noqa: E402
|
|
from varga import calc_all_vargas # noqa: E402
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REGISTRY_PATH = ROOT / "references/oracle/d1_d60_varga_mapping_registry_2026_07_19.json"
|
|
|
|
|
|
def formal_divisions() -> tuple[int, ...]:
|
|
rows = json.loads(REGISTRY_PATH.read_text(encoding="utf-8"))["rows"]
|
|
return tuple(row["number"] for row in rows if row["formal_name_present"])
|
|
|
|
|
|
FORMAL_DIVISIONS = formal_divisions()
|
|
|
|
TOPIC_DIVISIONS = {
|
|
"wealth": ("D1", "D2", "D4", "D11"),
|
|
"career": ("D1", "D5", "D10", "D24"),
|
|
"relationship": ("D1", "D7", "D9", "D12"),
|
|
"health_pressure": ("D1", "D6", "D8", "D30"),
|
|
"learning_spirituality": ("D1", "D20", "D24", "D27", "D40", "D45", "D60"),
|
|
}
|
|
|
|
|
|
def _registry_rows() -> dict[int, dict[str, Any]]:
|
|
rows = json.loads(REGISTRY_PATH.read_text(encoding="utf-8"))["rows"]
|
|
return {int(row["number"]): row for row in rows}
|
|
|
|
|
|
def _compute_vargas(payload: dict[str, Any]) -> dict[str, dict[str, Any]]:
|
|
chart = compute_chart(payload)
|
|
planet_lons = {
|
|
name: data["lon"]
|
|
for name, data in chart.get("planets", {}).items()
|
|
if name in {"Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu"}
|
|
}
|
|
result: dict[str, dict[str, Any]] = {
|
|
"D1": {
|
|
"Ascendant": chart["ascendant"],
|
|
**{name: {"sign": data.get("sign"), "lon": data.get("lon")} for name, data in chart["planets"].items()},
|
|
}
|
|
}
|
|
all_vargas = calc_all_vargas(
|
|
planet_lons,
|
|
chart["ascendant"]["lon"],
|
|
divisions=[division for division in FORMAL_DIVISIONS if division != 1],
|
|
)
|
|
for division in FORMAL_DIVISIONS:
|
|
if division == 1:
|
|
continue
|
|
prefix = f"D{division}_"
|
|
key = next(name for name in all_vargas if name.startswith(prefix))
|
|
result[f"D{division}"] = all_vargas[key]
|
|
return result
|
|
|
|
|
|
def _compute_generic_vargas(payload: dict[str, Any]) -> dict[str, dict[str, Any]]:
|
|
"""Calculate raw D-N positions for research-only generic divisions."""
|
|
chart = compute_chart(payload)
|
|
positions = {
|
|
"Ascendant": chart["ascendant"]["lon"],
|
|
**{
|
|
name: data["lon"]
|
|
for name, data in chart.get("planets", {}).items()
|
|
if name in {"Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu"}
|
|
},
|
|
}
|
|
calculator = DivisionalChartsCalculator()
|
|
audit = build_generic_varga_audit()
|
|
return {
|
|
division: {
|
|
body: calculator.calc_custom_varga(longitude, int(division[1:]))
|
|
for body, longitude in positions.items()
|
|
}
|
|
for division in audit["rows"]
|
|
}
|
|
|
|
|
|
def _signature(chart: dict[str, Any]) -> str:
|
|
return json.dumps(chart, ensure_ascii=False, sort_keys=True, separators=(",", ":"), default=str)
|
|
|
|
|
|
def _build_d1_to_d60_ledger(
|
|
formal_vargas: dict[str, dict[str, Any]],
|
|
generic_vargas: dict[str, dict[str, Any]],
|
|
) -> dict[str, dict[str, Any]]:
|
|
"""Expose every D1-D60 row with its calculation and claim boundary."""
|
|
ledger: dict[str, dict[str, Any]] = {}
|
|
for division in range(1, 61):
|
|
code = f"D{division}"
|
|
if code in formal_vargas:
|
|
row = formal_vargas[code]
|
|
registry = row["registry"]
|
|
ledger[code] = {
|
|
"division": code,
|
|
"raw": row["raw"],
|
|
"calculation_basis": registry["local_basis"],
|
|
"capability_tier": "formal_traditional_division",
|
|
"formal_traditional_formula": True,
|
|
"external_oracle_status": registry["external_oracle_status"],
|
|
"external_numeric_oracle_verified": registry["external_oracle_status"] == "verified",
|
|
"stability": row["stability"],
|
|
"interpretation_allowed": True,
|
|
"claim_boundary": registry["claim_boundary"],
|
|
}
|
|
continue
|
|
row = generic_vargas.get(code)
|
|
if row is None:
|
|
ledger[code] = {
|
|
"division": code,
|
|
"raw": None,
|
|
"calculation_basis": "generic_dn_unavailable",
|
|
"capability_tier": "research_generic_dn_division",
|
|
"formal_traditional_formula": False,
|
|
"external_oracle_status": "missing",
|
|
"external_numeric_oracle_verified": False,
|
|
"stability": "not_calculated",
|
|
"interpretation_allowed": False,
|
|
"claim_boundary": "No generic raw row was supplied for this research-only division.",
|
|
}
|
|
continue
|
|
ledger[code] = {
|
|
"division": code,
|
|
"raw": row["raw"],
|
|
"calculation_basis": row["algorithm_status"],
|
|
"capability_tier": "research_generic_dn_division",
|
|
"formal_traditional_formula": False,
|
|
"external_oracle_status": "missing",
|
|
"external_numeric_oracle_verified": False,
|
|
"stability": row["stability"],
|
|
"interpretation_allowed": False,
|
|
"claim_boundary": row["boundary"],
|
|
}
|
|
return ledger
|
|
|
|
|
|
def _sample_payloads(
|
|
payload: dict[str, Any], *, time_uncertainty_minutes: int, coordinate_uncertainty_degrees: float
|
|
) -> list[dict[str, Any]]:
|
|
center = datetime(
|
|
int(payload["year"]), int(payload["month"]), int(payload["day"]),
|
|
int(payload["hour"]), int(payload["minute"]), int(payload.get("second", 0)),
|
|
)
|
|
offsets = range(-time_uncertainty_minutes, time_uncertainty_minutes + 1)
|
|
coordinate_offsets = [(0.0, 0.0)]
|
|
if coordinate_uncertainty_degrees:
|
|
coordinate_offsets.extend([
|
|
(-coordinate_uncertainty_degrees, 0.0),
|
|
(coordinate_uncertainty_degrees, 0.0),
|
|
(0.0, -coordinate_uncertainty_degrees),
|
|
(0.0, coordinate_uncertainty_degrees),
|
|
])
|
|
samples = []
|
|
for minute_offset in offsets:
|
|
moment = center + timedelta(minutes=minute_offset)
|
|
for lat_offset, lon_offset in coordinate_offsets:
|
|
sample = dict(payload)
|
|
sample.update({
|
|
"year": moment.year, "month": moment.month, "day": moment.day,
|
|
"hour": moment.hour, "minute": moment.minute, "second": moment.second,
|
|
"lat": float(payload["lat"]) + lat_offset,
|
|
"lon": float(payload["lon"]) + lon_offset,
|
|
})
|
|
samples.append(sample)
|
|
return samples
|
|
|
|
|
|
def build_varga_matrix(
|
|
payload: dict[str, Any], *, time_uncertainty_minutes: int = 1,
|
|
coordinate_uncertainty_degrees: float = 0.0,
|
|
) -> dict[str, Any]:
|
|
if time_uncertainty_minutes < 0 or coordinate_uncertainty_degrees < 0:
|
|
raise ValueError("uncertainty values must be non-negative")
|
|
center = _compute_vargas(payload)
|
|
generic_center = _compute_generic_vargas(payload)
|
|
samples = _sample_payloads(
|
|
payload,
|
|
time_uncertainty_minutes=time_uncertainty_minutes,
|
|
coordinate_uncertainty_degrees=coordinate_uncertainty_degrees,
|
|
)
|
|
sample_results = [_compute_vargas(sample) for sample in samples]
|
|
generic_sample_results = [_compute_generic_vargas(sample) for sample in samples]
|
|
registry = _registry_rows()
|
|
tested = bool(time_uncertainty_minutes or coordinate_uncertainty_degrees)
|
|
formal_vargas = {}
|
|
for division in FORMAL_DIVISIONS:
|
|
name = f"D{division}"
|
|
signature = _signature(center[name])
|
|
stable = all(_signature(sample[name]) == signature for sample in sample_results)
|
|
formal_vargas[name] = {
|
|
"raw": center[name],
|
|
"registry": registry[division],
|
|
"stability": "not_tested" if not tested else "stable" if stable else "unstable",
|
|
}
|
|
topic_evidence = evaluate_topics(formal_vargas)
|
|
sensitivity_status = "not_tested" if not tested else "used"
|
|
generic_research_audit = build_generic_varga_audit()
|
|
generic_vargas = {}
|
|
for division, raw in generic_center.items():
|
|
signature = _signature(raw)
|
|
stable = all(_signature(sample[division]) == signature for sample in generic_sample_results)
|
|
audit_row = generic_research_audit["rows"][division]
|
|
generic_vargas[division] = {
|
|
"raw": raw,
|
|
"stability": "not_tested" if not tested else "stable" if stable else "unstable",
|
|
"algorithm_status": "generic_dn_unverified",
|
|
"claim_status": audit_row["claim_status"],
|
|
"promotion_allowed": audit_row["promotion_allowed"],
|
|
"boundary": "Raw D-N calculation only; this row cannot support a thematic conclusion.",
|
|
}
|
|
d1_to_d60 = _build_d1_to_d60_ledger(formal_vargas, generic_vargas)
|
|
return {
|
|
"scope": "varga_evidence_matrix",
|
|
"d1_to_d60": d1_to_d60,
|
|
"d1_to_d60_summary": {
|
|
"formal_traditional_division_count": len(FORMAL_DIVISIONS),
|
|
"research_generic_dn_division_count": 60 - len(FORMAL_DIVISIONS),
|
|
},
|
|
"formal_vargas": formal_vargas,
|
|
"topic_evidence": topic_evidence,
|
|
"generic_only_count": sum(not row["formal_name_present"] for row in registry.values()),
|
|
"generic_research_rows": list(generic_research_audit["rows"].values()),
|
|
"generic_research_audit": generic_research_audit,
|
|
"generic_vargas": generic_vargas,
|
|
"time_uncertainty_minutes": time_uncertainty_minutes,
|
|
"coordinate_uncertainty_degrees": coordinate_uncertainty_degrees,
|
|
"technique_audit_table": [
|
|
{
|
|
"technique": "D1-D60 Capability Ledger",
|
|
"status": "used",
|
|
"detail": "All 60 division factors are returned with formula class, raw position, oracle status, and interpretation permission.",
|
|
},
|
|
{
|
|
"technique": "Formal Varga Matrix",
|
|
"status": "used",
|
|
"detail": f"{len(formal_vargas)} formally modeled divisions; raw results retained.",
|
|
},
|
|
{
|
|
"technique": "Time/Location Sensitivity",
|
|
"status": sensitivity_status,
|
|
"detail": "No perturbation requested." if not tested else "Time and coordinate perturbations compared per division.",
|
|
},
|
|
{
|
|
"technique": "Generic-only Research Boundary",
|
|
"status": "blocked",
|
|
"detail": "40 generic-only divisions remain raw/research-only and cannot support conclusions.",
|
|
},
|
|
{
|
|
"technique": "Generic Varga Research Audit",
|
|
"status": "blocked",
|
|
"detail": "All 40 generic-only rows have explicit research gates; no row is promotion-eligible.",
|
|
},
|
|
{
|
|
"technique": "Generic D-N Raw Computation",
|
|
"status": "used",
|
|
"detail": "40 raw D-N charts were calculated with the generic algorithm; none is validated for thematic interpretation.",
|
|
},
|
|
{
|
|
"technique": "External Varga Parity",
|
|
"status": "partial",
|
|
"detail": "Registry records formula/source status; no all-60 external numeric parity claim is made.",
|
|
},
|
|
],
|
|
"boundary": "All D1-D60 rows are visible. Generic-only divisions are excluded from conclusions; unstable rows cannot be strong evidence.",
|
|
}
|
|
|
|
|
|
def evaluate_topics(
|
|
formal_vargas: dict[str, dict[str, Any]], *, topics: list[str] | None = None
|
|
) -> dict[str, list[dict[str, Any]]]:
|
|
selected_topics = topics or list(TOPIC_DIVISIONS)
|
|
result = {}
|
|
for topic in selected_topics:
|
|
rows = []
|
|
for division in TOPIC_DIVISIONS.get(topic, ()):
|
|
row = formal_vargas.get(division)
|
|
if row is None:
|
|
rows.append({"division": division, "status": "not_applicable", "strong_evidence": False})
|
|
continue
|
|
stability = row.get("stability")
|
|
status = "unstable" if stability == "unstable" else "support"
|
|
rows.append({
|
|
"division": division,
|
|
"status": status,
|
|
"strong_evidence": status == "support" and stability == "stable",
|
|
})
|
|
result[topic] = rows
|
|
return result
|