- KP monthly support read the birth-balance lord every month (no current_dasha in the issue #137 timeline); now the running lords, matching upstream - ported prediction_verdict_matrix.py and references/rectification_evidence_contract_v1.json (the contract was always blocked as file missing) - English audit statuses run / not_run written as Ran / Not run (run is also a packet key) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
220 lines
9.8 KiB
Python
220 lines
9.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Build a source-bounded prediction verdict matrix for timing work.
|
|
|
|
This module does not calculate charts or invent event outcomes. It turns the
|
|
existing report packet evidence into a compact adjudication layer: which dasha
|
|
families are allowed to lead, which strength filters can raise/lower claims,
|
|
and which missing replay or parameter checks cap the wording.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
SCHEMA = "jyotish.prediction_verdict_matrix.v1"
|
|
|
|
EVENT_POLICIES: dict[str, dict[str, Any]] = {
|
|
"career": {
|
|
"primary_dashas": ["Vimshottari", "Narayana"],
|
|
"supporting_layers": ["D10", "A10", "transit_multi_reference", "Shadbala", "Ashtakavarga"],
|
|
"minimum_time_layer": "AD",
|
|
"claim_cap_without_replay": "quarter_window",
|
|
},
|
|
"relationship": {
|
|
"primary_dashas": ["Vimshottari", "Jaimini/Chara"],
|
|
"supporting_layers": ["D9", "UL", "DK", "Venus/Jupiter", "transit_multi_reference"],
|
|
"minimum_time_layer": "AD/PD",
|
|
"claim_cap_without_replay": "season_window",
|
|
},
|
|
"wealth": {
|
|
"primary_dashas": ["Vimshottari", "Narayana"],
|
|
"supporting_layers": ["D2", "D11", "Sree Lagna", "Shadbala", "Ashtakavarga"],
|
|
"minimum_time_layer": "AD",
|
|
"claim_cap_without_replay": "quarter_window",
|
|
},
|
|
"health": {
|
|
"primary_dashas": ["Vimshottari", "Narayana"],
|
|
"supporting_layers": ["D6", "D30", "6/8/12 houses", "Saturn/Mars/Rahu transit"],
|
|
"minimum_time_layer": "PD",
|
|
"claim_cap_without_replay": "low_confidence_warning_only",
|
|
},
|
|
"relocation": {
|
|
"primary_dashas": ["Vimshottari", "Narayana"],
|
|
"supporting_layers": ["D4", "12th house", "Rahu/Ketu", "transit_multi_reference"],
|
|
"minimum_time_layer": "AD",
|
|
"claim_cap_without_replay": "quarter_window",
|
|
},
|
|
"education": {
|
|
"primary_dashas": ["Vimshottari", "Narayana"],
|
|
"supporting_layers": ["D24", "5/9 houses", "Jupiter/Mercury", "transit_multi_reference"],
|
|
"minimum_time_layer": "AD",
|
|
"claim_cap_without_replay": "quarter_window",
|
|
},
|
|
}
|
|
|
|
|
|
def _as_dict(value: Any) -> dict[str, Any]:
|
|
return value if isinstance(value, dict) else {}
|
|
|
|
|
|
def _as_list(value: Any) -> list[Any]:
|
|
return value if isinstance(value, list) else []
|
|
|
|
|
|
def _status(value: Any, default: str = "blocked") -> str:
|
|
item = _as_dict(value)
|
|
return str(item.get("status") or item.get("execution_status") or item.get("claim_status") or default)
|
|
|
|
|
|
def _status_is_usable(status: str) -> bool:
|
|
return status in {"executed", "used", "available", "verified", "partial_verified", "target_slices_verified"}
|
|
|
|
|
|
def build_dasha_selector_contract(domain: str) -> dict[str, Any]:
|
|
policy = EVENT_POLICIES.get(domain, EVENT_POLICIES["career"])
|
|
return {
|
|
"schema": "jyotish.dasha_selector_contract.v1",
|
|
"domain": domain,
|
|
"primary_dashas": policy["primary_dashas"],
|
|
"supporting_layers": policy["supporting_layers"],
|
|
"minimum_time_layer": policy["minimum_time_layer"],
|
|
"conflict_rule": (
|
|
"If primary dashas disagree on the same event window, downgrade to "
|
|
"parameter_sensitive and widen the claim to the configured cap."
|
|
),
|
|
"claim_cap_without_replay": policy["claim_cap_without_replay"],
|
|
}
|
|
|
|
|
|
def build_parameter_sensitivity_scan(packet: dict[str, Any]) -> dict[str, Any]:
|
|
profile = _as_dict(packet.get("calculation_profile"))
|
|
existing = _as_dict(packet.get("parameter_sensitivity")) or _as_dict(packet.get("ayanamsa_node_sensitivity"))
|
|
birth_time = _as_dict(packet.get("birth_time_sensitivity"))
|
|
unstable = []
|
|
if _status(birth_time) in {"candidate_window_only", "parameter_sensitive"}:
|
|
unstable.append("birth_time_sensitivity")
|
|
if not profile.get("ayanamsa") and not _as_dict(profile.get("effective_settings")).get("ayanamsa"):
|
|
unstable.append("ayanamsa_missing")
|
|
if not profile.get("node_mode") and not _as_dict(profile.get("effective_settings")).get("node_mode"):
|
|
unstable.append("node_mode_missing")
|
|
if _status(existing, "not_supplied") in {"parameter_sensitive", "conflict"}:
|
|
unstable.append("alternate_profile_conflict")
|
|
status = "stable" if not unstable else "parameter_sensitive"
|
|
return {
|
|
"schema": "jyotish.ayanamsa_node_sensitivity_scan.v1",
|
|
"status": status,
|
|
"stable_items": [] if unstable else ["ayanamsa", "node_mode", "birth_time_window"],
|
|
"unstable_items": unstable,
|
|
"source_status": _status(existing, "not_supplied"),
|
|
"boundary": (
|
|
"This scan reads supplied profile/sensitivity evidence only. It does not "
|
|
"recalculate alternate ayanamsas or node modes unless an upstream producer provides them."
|
|
),
|
|
}
|
|
|
|
|
|
def build_strength_filter_gate(packet: dict[str, Any]) -> dict[str, Any]:
|
|
worksheets = _as_dict(packet.get("worksheets"))
|
|
strengths = _as_dict(worksheets.get("strengths_and_scores"))
|
|
shadbala = _as_dict(strengths.get("shadbala") or packet.get("shadbala"))
|
|
ashtakavarga = _as_dict(strengths.get("ashtakavarga") or packet.get("ashtakavarga"))
|
|
fbm = _as_dict(strengths.get("functional_benefic_malefic"))
|
|
filters = []
|
|
if shadbala:
|
|
filters.append({"layer": "Shadbala", "status": _status(shadbala, "available"), "effect": "modulates dasha lord delivery"})
|
|
if ashtakavarga:
|
|
filters.append({"layer": "Ashtakavarga", "status": _status(ashtakavarga, "available"), "effect": "modulates transit/house carrying capacity"})
|
|
if fbm:
|
|
filters.append({"layer": "Functional Benefic/Malefic", "status": _status(fbm, "used"), "effect": "overrides natural benefic/malefic shorthand"})
|
|
status = "executed" if filters else "blocked"
|
|
return {
|
|
"schema": "jyotish.strength_filter_gate.v1",
|
|
"status": status,
|
|
"filters": filters,
|
|
"claim_effect": "raise_or_lower_verdict_strength" if filters else "no_strength_filter_available",
|
|
"boundary": "Strength layers filter claim intensity; they do not create standalone event predictions.",
|
|
}
|
|
|
|
|
|
def _domain_from_event(event: dict[str, Any]) -> str:
|
|
domain = str(event.get("domain") or event.get("event_domain") or "career").lower()
|
|
return domain if domain in EVENT_POLICIES else "career"
|
|
|
|
|
|
def build_prediction_verdict_matrix(packet: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
packet = _as_dict(packet)
|
|
event_replay = _as_dict(packet.get("event_replay"))
|
|
events = [_as_dict(event) for event in _as_list(event_replay.get("events")) if isinstance(event, dict)]
|
|
domains = sorted({_domain_from_event(event) for event in events}) or ["career", "relationship", "wealth"]
|
|
sensitivity = build_parameter_sensitivity_scan(packet)
|
|
strength_gate = build_strength_filter_gate(packet)
|
|
timing_contract = _as_dict(packet.get("timing_precision_contract"))
|
|
timing_status = str(timing_contract.get("claim_status") or timing_contract.get("timing_precision") or "broad_window_only")
|
|
replay_status = _status(event_replay)
|
|
|
|
rows = []
|
|
for domain in domains:
|
|
selector = build_dasha_selector_contract(domain)
|
|
blockers = []
|
|
if replay_status in {"blocked", "missing"}:
|
|
blockers.append("event_replay_missing")
|
|
if sensitivity["status"] != "stable":
|
|
blockers.append("parameter_sensitivity_open")
|
|
if strength_gate["status"] == "blocked":
|
|
blockers.append("strength_filter_missing")
|
|
evidence_label = "blocked" if "event_replay_missing" in blockers else (
|
|
"parameter_sensitive" if blockers else "multi_system_consensus_ready"
|
|
)
|
|
rows.append({
|
|
"domain": domain,
|
|
"event_count": sum(1 for event in events if _domain_from_event(event) == domain),
|
|
"selector": selector,
|
|
"timing_status": timing_status,
|
|
"strength_gate_status": strength_gate["status"],
|
|
"sensitivity_status": sensitivity["status"],
|
|
"evidence_label": evidence_label,
|
|
"claim_cap": selector["claim_cap_without_replay"] if blockers else "case_replay_bounded_window",
|
|
"blockers": blockers,
|
|
})
|
|
|
|
status = "blocked" if all(row["evidence_label"] == "blocked" for row in rows) else (
|
|
"parameter_sensitive" if any(row["blockers"] for row in rows) else "executed"
|
|
)
|
|
return {
|
|
"schema": SCHEMA,
|
|
"status": status,
|
|
"rows": rows,
|
|
"event_replay_status": replay_status,
|
|
"parameter_sensitivity": sensitivity,
|
|
"strength_filter_gate": strength_gate,
|
|
"technique_audit_rows": [
|
|
{"technique": "Event Replay Bench", "status": replay_status, "source": "packet.event_replay"},
|
|
{"technique": "Dasha Selector Contract", "status": "executed", "source": "domain policy registry"},
|
|
{"technique": "Ayanamsa/Node Sensitivity", "status": sensitivity["status"], "source": "packet profile/sensitivity"},
|
|
{"technique": "Strength Filter Gate", "status": strength_gate["status"], "source": "packet strengths_and_scores"},
|
|
],
|
|
"boundary": (
|
|
"This matrix adjudicates evidence already present in the packet. It must not be "
|
|
"used to claim global closure, exact dates, or a result unsupported by event replay."
|
|
),
|
|
}
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--packet", help="JSON report packet path. Empty input returns blocked starter matrix.")
|
|
args = parser.parse_args()
|
|
packet: dict[str, Any] = {}
|
|
if args.packet:
|
|
packet = json.loads(Path(args.packet).read_text(encoding="utf-8"))
|
|
print(json.dumps(build_prediction_verdict_matrix(packet), ensure_ascii=False, indent=2, sort_keys=True))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|