feat: import reproducible timing validation

This commit is contained in:
732642856
2026-07-17 22:19:09 +08:00
parent bba201da3b
commit ba9d43e128
39 changed files with 8283 additions and 3 deletions
@@ -0,0 +1,12 @@
import json
from pathlib import Path
from scripts.archive_vedastro_nuget_probe import build_archive
def test_archive_contains_all_identity_layers(tmp_path: Path) -> None:
candidate=tmp_path/"candidate.json";runtime=tmp_path/"runtime.json"
candidate.write_text(json.dumps({"status":"reproducible_library_executable_verified","package_sha256":"a","library_dll_sha256":"b"}))
runtime.write_text(json.dumps({"version":"1.2.0.0","informational_version":"1.2.0","methods":["M"],"method_contracts":[{"name":"M"}]}))
report=build_archive(candidate,runtime)
assert report["assembly_version"]=="1.2.0.0"
assert report["public_methods"]==["M"]
assert report["runtime_image_id"].startswith("sha256:")
+10
View File
@@ -0,0 +1,10 @@
from pathlib import Path
from scripts.day_level_holdout_validator import validate
ROOT=Path(__file__).resolve().parents[1]
def test_empty_preregistered_holdout_remains_honestly_blocked() -> None:
report=validate(ROOT/"references/real_case_calibration/day_level_holdout_v3_preregistration.json")
assert report["status"] == "awaiting_independent_labels"
assert report["annotation_count"] == 0
assert report["production_tuning_allowed"] is False
@@ -0,0 +1,35 @@
import json
from pathlib import Path
from scripts.three_engine_mismatch_arbitrator import arbitrate_manifest
ROOT = Path(__file__).resolve().parents[1]
def test_arbitrator_classifies_every_mismatch_without_majority_truth() -> None:
report = arbitrate_manifest(ROOT / "references/oracle/three_engine_parity_replay_manifest.json")
assert report["mismatch_count"] == 60
assert report["classified_count"] == 60
assert report["unclassified_count"] == 0
assert report["truth_policy"] == "no_majority_vote"
assert sum(report["category_counts"].values()) == 60
assert all(row["differing_engines"] for row in report["rows"])
def test_vedastro_only_d2_difference_is_endpoint_semantics(tmp_path: Path) -> None:
manifest = {
"engines": {name: {} for name in ("VedAstro", "PyJHora_JHora", "jyotishganit")},
"comparison_rows": [{
"section": "D2", "field": "Sun.sign", "local_value": "Leo",
"oracle_values": {"VedAstro": "Gemini", "PyJHora_JHora": "Leo", "jyotishganit": "Leo"},
"status": "mismatch",
}],
}
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
row = arbitrate_manifest(path)["rows"][0]
assert row["category"] == "endpoint_or_varga_semantics"
assert row["differing_engines"] == ["VedAstro"]
+50
View File
@@ -0,0 +1,50 @@
from scripts.timing_precision_contract import build_timing_precision_contract
import json
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_timing_contract_preserves_dates_but_caps_claim_status() -> None:
contract = build_timing_precision_contract({
"verified_window": "2026-08 to 2026-10",
"candidate_windows": [{
"start": "2026-08-12", "end": "2026-08-16", "rank": 1,
"signals": ["Vimshottari", "Narayana", "D10", "transit"],
"confidence_cap": "low",
}],
"exact_triggers": [{"at": "2026-08-14T09:30:00Z", "technique": "exact_transit"}],
})
assert contract["timing_precision"] == "candidate_day_window"
assert contract["claim_status"] == "exploratory_unvalidated"
assert contract["verified_window"] == "2026-08 to 2026-10"
assert contract["candidate_windows"][0]["start"] == "2026-08-12"
assert contract["exact_triggers"][0]["at"] == "2026-08-14T09:30:00Z"
assert contract["promotion_gate"]["status"] == "blocked"
def test_empty_timing_contract_still_exposes_boundary() -> None:
contract = build_timing_precision_contract()
assert contract["timing_precision"] == "broad_window_only"
assert contract["candidate_windows"] == []
assert "不能作为确定事件承诺" in contract["boundary"]
def test_predict_cli_exposes_exploratory_timing_contract() -> None:
completed = subprocess.run(
[sys.executable, "scripts/jyotish_engine.py", "predict", "--chart", '{"planets":{}}',
"--lat", "0", "--lon", "0", "--tz", "0"],
cwd=ROOT, text=True, capture_output=True, timeout=30, check=False,
)
assert completed.returncode == 0, completed.stderr
contract = json.loads(completed.stdout)["timing_precision_contract"]
assert contract["claim_status"] == "exploratory_unvalidated"
assert contract["promotion_gate"]["current_negative_controls_reusable_for_tuning"] is False
def test_consultation_api_attaches_same_contract() -> None:
source = (ROOT / "scripts/jyotish_api_server.py").read_text(encoding="utf-8")
assert source.count("result['timing_precision_contract'] = build_timing_precision_contract") == 2
@@ -0,0 +1,13 @@
from pathlib import Path
from scripts.xalen_difference_attribution import build_report
ROOT=Path(__file__).resolve().parents[1]
def test_all_xalen_shadbala_and_av_differences_are_formula_unit_attributed() -> None:
report=build_report(ROOT/"references/oracle/xalen_fourth_oracle_comparison_2026_07_17.json")
assert report["row_count"]==46
assert report["classified_count"]==46
assert sum(report["category_counts"].values())==46
assert all(row["unit"] in {"Virupa","bindu_count"} for row in report["rows"])
av=[r for r in report["rows"] if r["unit"]=="bindu_count"]
assert len(av)==4
assert all(r["row_total_local"]==r["row_total_xalen"] for r in av)
@@ -0,0 +1,10 @@
from pathlib import Path
from scripts.xalen_ephemeris_mode_comparison import compare
ROOT=Path(__file__).resolve().parents[1]
def test_independent_xalen_ephemeris_is_separately_disclosed() -> None:
r=compare(ROOT/'references/oracle/artifacts/xalen_steve_jobs_high_rigor_raw.json',ROOT/'references/oracle/artifacts/xalen_steve_jobs_independent_ephemeris_raw.json')
assert r['shared_mode']=='shared_input'
assert r['independent_mode']=='independent_ephemeris'
assert r['maximum_absolute_longitude_delta_deg']<0.02
assert r['varga_difference_count']==0
assert 'house numbers remain shared' in r['boundary']
+9
View File
@@ -0,0 +1,9 @@
from scripts.xalen_oracle_adapter import COMMIT, MANIFEST
def test_xalen_adapter_is_pinned_and_license_bounded() -> None:
text = MANIFEST.read_text(encoding="utf-8")
assert COMMIT in text
assert "xalen-vedic" in text
assert len(COMMIT) == 40
assert "independent_ephemeris" in (MANIFEST.parent.parent.parent / "scripts/xalen_oracle_adapter.py").read_text(encoding="utf-8")
+11
View File
@@ -0,0 +1,11 @@
from pathlib import Path
from scripts.xalen_oracle_comparison import compare
ROOT=Path(__file__).resolve().parents[1]
def test_xalen_compares_all_high_rigor_rows_as_fourth_observation() -> None:
report=compare(ROOT/"references/oracle/three_engine_parity_replay_manifest.json",ROOT/"references/oracle/artifacts/xalen_steve_jobs_high_rigor_raw.json")
assert report["row_count"] == 92
assert report["match_count"] + report["mismatch_count"] == 92
assert report["truth_policy"] == "fourth_observation_not_truth"
assert report["license"] == "Apache-2.0"
+5
View File
@@ -0,0 +1,5 @@
from scripts.xalen_public_case_batch import PLANETS,SIGNS
def test_batch_contract_uses_seven_planets_and_twelve_signs() -> None:
assert PLANETS==['Sun','Moon','Mars','Mercury','Jupiter','Venus','Saturn']
assert len(SIGNS)==12