Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
234 lines
11 KiB
Python
234 lines
11 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 strength inputs or parameter checks cap the wording.
|
|
|
|
BUG-2068 (产品负责人与占星师 2026-11-20, B11): a report is never held back
|
|
because the reader supplied no life events. Missing events are not a blocker and
|
|
do not change a label. The real limits stay: missing strength input and open
|
|
parameter sensitivity. Events only appear here when an offline research packet
|
|
carries them (``--event-replay-file``); the website report packet has none.
|
|
|
|
BUG-2110 (占星师 2026-11-21): supplied events do not change a label or a claim cap
|
|
either. The matrix never compares the events with the systems; it only counts them.
|
|
"""
|
|
|
|
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")
|
|
# Offline research only: a packet built with --event-replay-file. Reported, never graded.
|
|
replay_status = _status(event_replay, "not_supplied") if event_replay else "not_supplied"
|
|
|
|
rows = []
|
|
for domain in domains:
|
|
selector = build_dasha_selector_contract(domain)
|
|
blockers = []
|
|
if sensitivity["status"] != "stable":
|
|
blockers.append("parameter_sensitivity_open")
|
|
if strength_gate["status"] == "blocked":
|
|
blockers.append("strength_filter_missing")
|
|
if "strength_filter_missing" in blockers:
|
|
evidence_label = "blocked" # a real missing input
|
|
elif blockers:
|
|
evidence_label = "parameter_sensitive"
|
|
else:
|
|
# Nothing here compares systems, so the row only says that this
|
|
# matrix found no open blocker, with or without events (BUG-2110).
|
|
evidence_label = "no_open_blocker"
|
|
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"],
|
|
"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"}]
|
|
if event_replay else []),
|
|
{"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 confirmed result."
|
|
),
|
|
}
|
|
|
|
|
|
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())
|