feat: sync mismatch progress evidence closure

This commit is contained in:
732642856
2026-07-20 00:03:56 +08:00
parent 198c0763a6
commit 6d4d22630c
30 changed files with 3766 additions and 326 deletions
@@ -0,0 +1,63 @@
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
INDEX = ROOT / "references/oracle/evidence_packet_index_2026_07_19.json"
def test_evidence_packet_index_integrity_validator_passes_current_index() -> None:
data = json.loads(
subprocess.check_output(
["python3", "scripts/evidence_packet_index_integrity.py", "--index", str(INDEX)],
cwd=ROOT,
text=True,
)
)
assert data["scope"] == "evidence_packet_index_integrity"
assert data["status"] == "pass"
assert data["summary"]["packet_count"] >= 60
assert data["summary"]["missing_path_count"] == 0
assert data["summary"]["duplicate_packet_id_count"] == 0
assert data["summary"]["invalid_claim_status_count"] == 0
def test_evidence_packet_index_integrity_reports_bad_index(tmp_path: Path) -> None:
bad = tmp_path / "bad_index.json"
bad.write_text(
json.dumps(
{
"packets": [
{
"packet_id": "dup",
"path": "references/oracle/missing_packet.json",
"domain": "timing_holdout",
"claim_status": "done",
"consumer_policy": "research",
"claim_boundary": "",
},
{
"packet_id": "dup",
"path": "references/oracle/evidence_packet_index_2026_07_19.json",
"domain": "timing_holdout",
"claim_status": "partial",
"consumer_policy": "research",
"claim_boundary": "ok",
},
]
}
),
encoding="utf-8",
)
data = json.loads(
subprocess.check_output(
["python3", "scripts/evidence_packet_index_integrity.py", "--index", str(bad)],
cwd=ROOT,
text=True,
)
)
assert data["status"] == "fail"
assert data["summary"]["missing_path_count"] == 1
assert data["summary"]["duplicate_packet_id_count"] == 1
assert data["summary"]["invalid_claim_status_count"] == 1
@@ -0,0 +1,31 @@
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
QUEUE = ROOT / "references/oracle/jyotishganit_mismatch_attribution_queue_2026_07_19.json"
INDEX = ROOT / "references/oracle/evidence_packet_index_2026_07_19.json"
def test_comparison_d4_alias_is_not_counted_as_missing_local_schema():
out = subprocess.check_output(["python3", "scripts/jyotishganit_vs_local_field_comparison.py"], cwd=ROOT, text=True)
data = json.loads(out)
mismatches = [r for r in data["rows"] if r["status"] == "mismatch"]
assert all(not (r["section"] == "D4" and r["local_sign"] is None) for r in mismatches)
def test_mismatch_attribution_queue_marks_partial_not_truth():
data = json.loads(QUEUE.read_text(encoding="utf-8"))
assert data["scope"] == "jyotishganit_mismatch_attribution_queue"
assert data["claim_status"] == "partial"
assert data["production_tuning_allowed"] is False
assert data["truth_matrix_allowed"] is False
assert data["summary"]["mismatch_count"] >= 1
assert all(row["attribution_status"] == "queued" for row in data["rows"])
def test_evidence_index_registers_mismatch_attribution_queue():
index = json.loads(INDEX.read_text(encoding="utf-8"))
packets = {row["packet_id"]: row for row in index["packets"]}
assert packets["jyotishganit_mismatch_attribution_queue"]["claim_status"] == "partial"
@@ -0,0 +1,38 @@
from __future__ import annotations
import json
from pathlib import Path
from scripts.three_engine_mismatch_closure_queue import build_queue
ROOT = Path(__file__).resolve().parents[1]
ARBITRATION = ROOT / "references" / "oracle" / "three_engine_mismatch_arbitration_2026_07_19.json"
QUEUE = ROOT / "references" / "oracle" / "three_engine_mismatch_closure_queue_2026_07_19.json"
def test_closure_queue_turns_classified_mismatches_into_actionable_items() -> None:
queue = build_queue(ARBITRATION)
assert queue["scope"] == "three_engine_mismatch_closure_queue"
assert queue["status"] == "open"
assert queue["truth_policy"] == "no_majority_vote"
assert queue["production_tuning_allowed"] is False
assert queue["summary"]["source_mismatch_count"] == 60
assert queue["summary"]["queue_count"] == 60
assert queue["summary"]["priority_counts"]["P0"] >= 1
first = queue["queue"][0]
assert first["ticket_id"].startswith("TEMCQ-")
assert first["owner_track"] in {"endpoint_contract", "formula_source", "unit_schema", "worked_example"}
assert first["closure_status"] == "open"
assert first["required_evidence"]
assert first["commercial_visibility"] == "do_not_expose_raw"
def test_closure_queue_artifact_matches_mismatch_count() -> None:
data = json.loads(QUEUE.read_text(encoding="utf-8"))
assert data["summary"]["source_mismatch_count"] == 60
assert data["summary"]["queue_count"] == 60
assert data["production_tuning_allowed"] is False
assert all(row["closure_status"] == "open" for row in data["queue"])
@@ -0,0 +1,41 @@
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
ARTIFACT = ROOT / "references/oracle/three_engine_mismatch_progress_ledger_2026_07_19.json"
INDEX = ROOT / "references/oracle/evidence_packet_index_2026_07_19.json"
def test_three_engine_progress_ledger_reports_attributed_node_rows():
data = json.loads(
subprocess.check_output(
["python3", "scripts/three_engine_mismatch_progress_ledger.py"],
cwd=ROOT,
text=True,
)
)
assert data["scope"] == "three_engine_mismatch_progress_ledger"
assert data["claim_status"] == "partial"
assert data["truth_matrix_allowed"] is False
assert data["summary"] == {
"source_queue_count": 60,
"attributed_no_tuning_count": 2,
"remaining_open_count": 58,
}
def test_three_engine_progress_ledger_does_not_close_queue_or_vote():
data = json.loads(ARTIFACT.read_text(encoding="utf-8"))
assert {row["field"] for row in data["attributed_rows"]} == {"Rahu", "Ketu"}
assert all(row["closure_state"] == "attributed_no_tuning" for row in data["attributed_rows"])
assert "no engine majority vote is allowed" in data["boundary"]
def test_evidence_index_registers_three_engine_progress_ledger():
packets = {
row["packet_id"]: row
for row in json.loads(INDEX.read_text(encoding="utf-8"))["packets"]
}
assert packets["three_engine_mismatch_progress_ledger"]["claim_status"] == "partial"