test: import research oracle probes
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.jyotishyamitra_adapter_probe import (
|
||||
build_report,
|
||||
canonical_request,
|
||||
compare_with_existing_oracles,
|
||||
normalize_raw,
|
||||
schema_fingerprint,
|
||||
)
|
||||
|
||||
|
||||
WHEEL = Path("/tmp/jyotishyamitra_probe/jyotishyamitra-1.4.0-py3-none-any.whl")
|
||||
WHEEL_SHA256 = "4f1a16facfa86ef01cb44de505c6de2e66b2f8d2c8b5e125c090e3f8485c6a9d"
|
||||
|
||||
|
||||
def test_jyotishyamitra_probe_contract_uses_pinned_identity_fixture(tmp_path: Path) -> None:
|
||||
wheel = WHEEL
|
||||
assert wheel.exists(), "fixture_missing: run pinned wheel download outside CI; tests must not fetch network"
|
||||
report = build_report(
|
||||
wheel_path=wheel,
|
||||
commit="86f7eb610a66b06b3f0817d2c53355bec8b3bf8d",
|
||||
raw={"D1": {"Sun": "Aquarius"}, "metadata": {"ayanamsa": "Lahiri"}},
|
||||
)
|
||||
|
||||
assert report["oracle"] == "jyotishyamitra"
|
||||
assert report["license"] == "MIT"
|
||||
assert report["version"] == "1.4.0"
|
||||
assert report["source_commit"] == "86f7eb610a66b06b3f0817d2c53355bec8b3bf8d"
|
||||
assert report["wheel_sha256"]
|
||||
assert report["wheel_sha256"] == WHEEL_SHA256
|
||||
assert report["raw_sha256"]
|
||||
assert report["normalized_raw_sha256"]
|
||||
assert report["package_metadata"]["version"] == "1.4.0"
|
||||
assert report["package_metadata"]["requires_python"] == ">=3.7"
|
||||
assert report["package_metadata"]["license"] is None
|
||||
assert report["package_metadata"]["license_file_spdx_inferred"] == "MIT"
|
||||
assert report["python_runtime"]["version"]
|
||||
assert report["schema_fingerprint"]["sha256"]
|
||||
assert report["isolated_subprocess"]["used"] is False
|
||||
assert report["truth_policy"] == "independent_observation_not_truth"
|
||||
|
||||
|
||||
def test_jyotishyamitra_missing_wheel_is_explicitly_blocked(tmp_path: Path) -> None:
|
||||
report = build_report(tmp_path / "missing.whl")
|
||||
|
||||
assert report["status"] == "blocked"
|
||||
assert report["blocked_reason"] == "fixture_missing"
|
||||
assert report["promotion_allowed"] is False
|
||||
|
||||
|
||||
def test_jyotishyamitra_canonical_request_records_defaults() -> None:
|
||||
request = canonical_request(
|
||||
{
|
||||
"name": "Steve Jobs",
|
||||
"gender": "male",
|
||||
"place": "San Francisco",
|
||||
"longitude": -122.4194,
|
||||
"latitude": 37.7749,
|
||||
"timezone": -8.0,
|
||||
"birth": {"year": 1955, "month": 2, "day": 24, "hour": 19, "minute": 15},
|
||||
}
|
||||
)
|
||||
|
||||
assert request["ayanamsa"] == "package_default"
|
||||
assert request["node_mode"] == "package_default"
|
||||
assert request["returnval"] == "ASTRODATA_DICTIONARY"
|
||||
assert request["birth"]["second"] == 0
|
||||
|
||||
|
||||
def test_jyotishyamitra_schema_fingerprint_is_stable() -> None:
|
||||
fp = schema_fingerprint({"D1": {"Sun": "Aquarius"}, "scores": [1, 2]})
|
||||
|
||||
assert fp["path_count"] == 3
|
||||
assert fp["sha256"]
|
||||
assert "$.D1.Sun:str" in fp["sample_paths"]
|
||||
|
||||
|
||||
def test_jyotishyamitra_normalizes_volatile_current_dasha_timestamp() -> None:
|
||||
a = {"Dashas": {"Vimshottari": {"current": {"date": "run-a", "lord": "Sun"}}}}
|
||||
b = {"Dashas": {"Vimshottari": {"current": {"date": "run-b", "lord": "Sun"}}}}
|
||||
|
||||
assert normalize_raw(a) == normalize_raw(b)
|
||||
|
||||
|
||||
def test_jyotishyamitra_field_comparison_is_observation_not_promotion() -> None:
|
||||
comparison = compare_with_existing_oracles(
|
||||
{"D1": {"Sun": "Aquarius"}, "D9": {"Moon": "Cancer"}},
|
||||
{"D1": {"Sun": "Aquarius"}, "D9": {"Moon": "Leo"}},
|
||||
{"D1": {"Sun": "Aquarius"}, "D9": {"Moon": "Cancer"}},
|
||||
)
|
||||
|
||||
assert comparison["row_count"] == 2
|
||||
assert comparison["match_counts"]["local"] == 1
|
||||
assert comparison["match_counts"]["xalen"] == 2
|
||||
assert comparison["promotion_allowed"] is False
|
||||
@@ -0,0 +1,38 @@
|
||||
from scripts.timing_negative_holdout_audit import build_report
|
||||
|
||||
|
||||
def test_timing_negative_holdout_blocks_positive_only_sources() -> None:
|
||||
report = build_report(
|
||||
[
|
||||
{
|
||||
"name": "positive-only public timeline",
|
||||
"positive_events": True,
|
||||
"explicit_non_event_intervals": False,
|
||||
"independent_human_reviewed": False,
|
||||
"observed_before_preregistration": False,
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
assert report["claim_status"] == "exploratory_unvalidated"
|
||||
assert report["production_tuning_allowed"] is False
|
||||
assert report["sources"][0]["usable_for_promotion"] is False
|
||||
assert "missing_explicit_non_event_intervals" in report["sources"][0]["blockers"]
|
||||
|
||||
|
||||
def test_timing_negative_holdout_can_only_promote_locked_independent_labels() -> None:
|
||||
report = build_report(
|
||||
[
|
||||
{
|
||||
"name": "locked blind label packet",
|
||||
"positive_events": True,
|
||||
"explicit_non_event_intervals": True,
|
||||
"independent_human_reviewed": True,
|
||||
"observed_before_preregistration": False,
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
assert report["claim_status"] == "ready_for_blind_holdout"
|
||||
assert report["production_tuning_allowed"] is True
|
||||
assert report["sources"][0]["blockers"] == []
|
||||
@@ -0,0 +1,38 @@
|
||||
from scripts.vedastro_identity_archive import build_archive
|
||||
|
||||
|
||||
def test_vedastro_identity_archive_records_self_host_identity(monkeypatch) -> None:
|
||||
fixtures = {
|
||||
"https://api.nuget.org/v3/registration5-semver1/vedastro.library/1.2.0.json": {
|
||||
"catalogEntry": "https://example.invalid/catalog.json",
|
||||
"packageContent": "https://example.invalid/pkg.nupkg",
|
||||
"published": "2023-03-22T22:22:01.81+00:00",
|
||||
},
|
||||
"https://example.invalid/catalog.json": {
|
||||
"packageHashAlgorithm": "SHA512",
|
||||
"packageHash": "hash",
|
||||
"packageSize": 230836,
|
||||
"published": "2023-03-22T22:22:01.81Z",
|
||||
"catalog:commitId": "commit",
|
||||
"catalog:commitTimeStamp": "2023-03-22T22:24:11.811524Z",
|
||||
"licenseExpression": "MIT",
|
||||
"projectUrl": "https://vedastro.org/",
|
||||
"dependencyGroups": [
|
||||
{
|
||||
"targetFramework": "net7.0",
|
||||
"dependencies": [{"id": "SwissEphNet", "range": "[2.8.0.2, )"}],
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
monkeypatch.setattr("scripts.vedastro_identity_archive._json_url", lambda url, timeout: fixtures[url])
|
||||
report = build_archive("1.2.0")
|
||||
|
||||
assert report["package_hash_algorithm"] == "SHA512"
|
||||
assert report["license"] == "MIT"
|
||||
assert report["self_host_candidate_status"] == "reproducible_package_identity_archived"
|
||||
assert report["hosted_api_status"] == "blocked"
|
||||
assert report["dependencies"] == [
|
||||
{"target_framework": "net7.0", "id": "SwissEphNet", "range": "[2.8.0.2, )"}
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
from scripts.vp_jain_shadbala_benchmark import build_report
|
||||
|
||||
|
||||
def test_vp_jain_published_component_benchmark_is_fully_classified() -> None:
|
||||
report = build_report()
|
||||
|
||||
assert report["case"]["name"] == "VP Jain published Shadbala example"
|
||||
assert report["summary"]["row_count"] == 42
|
||||
assert report["summary"]["classified_count"] == 42
|
||||
assert report["summary"]["within_tolerance_count"] == 34
|
||||
assert report["summary"]["method_variant_count"] == 8
|
||||
|
||||
|
||||
def test_vp_jain_benchmark_keeps_known_method_variants_explicit() -> None:
|
||||
rows = build_report()["rows"]
|
||||
variants = {(row["component"], row["planet"]): row for row in rows if row["status"] != "within_tolerance"}
|
||||
|
||||
assert set(variants) == {
|
||||
("sthana", "Sun"),
|
||||
("sthana", "Mercury"),
|
||||
("chesta", "Sun"),
|
||||
("chesta", "Moon"),
|
||||
("chesta", "Mars"),
|
||||
("chesta", "Mercury"),
|
||||
("chesta", "Jupiter"),
|
||||
("chesta", "Saturn"),
|
||||
}
|
||||
assert variants[("sthana", "Sun")]["variant"] == "moolatrikona_degree_range_vs_whole_sign"
|
||||
assert variants[("chesta", "Moon")]["variant"] == "luminary_chesta_policy"
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import json
|
||||
|
||||
from scripts.xalen_arbitration_gate import build_report
|
||||
|
||||
|
||||
def test_xalen_arbitration_gate_blocks_unresolved_method_variants(tmp_path) -> None:
|
||||
attribution = tmp_path / "attr.json"
|
||||
public_batch = tmp_path / "batch.json"
|
||||
ephemeris = tmp_path / "ephem.json"
|
||||
attribution.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"rows": [
|
||||
{
|
||||
"field": "Sun.chesta",
|
||||
"truth_status": "method_variant_unresolved",
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
public_batch.write_text(json.dumps({"case_count": 5}), encoding="utf-8")
|
||||
ephemeris.write_text(
|
||||
json.dumps({"maximum_absolute_longitude_delta_deg": 0.001, "varga_difference_count": 0}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
report = build_report(attribution, public_batch, ephemeris)
|
||||
|
||||
assert report["multi_case_replay_status"] == "ready"
|
||||
assert report["independent_ephemeris_status"] == "ready"
|
||||
assert report["truth_status"] == "blocked"
|
||||
assert report["promotion_allowed"] is False
|
||||
|
||||
|
||||
def test_xalen_arbitration_gate_allows_only_when_variants_are_arbitrated(tmp_path) -> None:
|
||||
attribution = tmp_path / "attr.json"
|
||||
public_batch = tmp_path / "batch.json"
|
||||
ephemeris = tmp_path / "ephem.json"
|
||||
attribution.write_text(json.dumps({"rows": [{"truth_status": "external_worked_example_match"}]}), encoding="utf-8")
|
||||
public_batch.write_text(json.dumps({"case_count": 5}), encoding="utf-8")
|
||||
ephemeris.write_text(
|
||||
json.dumps({"maximum_absolute_longitude_delta_deg": 0.001, "varga_difference_count": 0}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
report = build_report(attribution, public_batch, ephemeris)
|
||||
|
||||
assert report["truth_status"] == "ready"
|
||||
assert report["promotion_allowed"] is True
|
||||
Reference in New Issue
Block a user