Skip to content

Commit b6bc03d

Browse files
committed
Publish ORBISTIUM accepted-epoch index and current-state bindings
1 parent bf7fa89 commit b6bc03d

3 files changed

Lines changed: 127 additions & 0 deletions

File tree

epochs/current/index.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"object_type": "AcceptedEpochIndex",
3+
"status": "ACTIVE_TRUTH",
4+
"historical": false,
5+
"current_accepted_epoch_ref": "epochs/current/accepted-epoch-0001.json",
6+
"entries": [
7+
{
8+
"accepted_epoch_id": "accepted-epoch-0001",
9+
"path": "epochs/current/accepted-epoch-0001.json",
10+
"epoch_ref": "current/epoch.json",
11+
"graph_ref": "current/graph.json",
12+
"trust_summary_ref": "current/trust-summary.json",
13+
"digest_ref": "current/digest.txt"
14+
}
15+
]
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pathlib import Path
2+
import json
3+
4+
ROOT = Path(__file__).resolve().parents[1]
5+
6+
def load(rel: str):
7+
return json.loads((ROOT / rel).read_text(encoding="utf-8"))
8+
9+
def test_outsider_can_identify_current_accepted_epoch_from_objects():
10+
accepted = load("epochs/current/accepted-epoch-0001.json")
11+
index = load("epochs/current/index.json")
12+
13+
assert accepted["object_type"] == "AcceptedEpoch"
14+
assert accepted["status"] == "ACTIVE_TRUTH"
15+
assert index["object_type"] == "AcceptedEpochIndex"
16+
assert index["status"] == "ACTIVE_TRUTH"
17+
assert index["current_accepted_epoch_ref"] == "epochs/current/accepted-epoch-0001.json"
18+
19+
first = index["entries"][0]
20+
assert first["accepted_epoch_id"] == accepted["accepted_epoch_id"]
21+
assert first["epoch_ref"] == "current/epoch.json"
22+
assert first["graph_ref"] == "current/graph.json"
23+
assert accepted["trust_summary_ref"] == "current/trust-summary.json"
24+
assert accepted["digest_ref"] == "current/digest.txt"
25+
assert accepted["historical_archive_ref"] == "epochs/history/"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python3
2+
from pathlib import Path
3+
import json
4+
import sys
5+
6+
ROOT = Path(__file__).resolve().parents[1]
7+
errors = []
8+
9+
def need(cond, name):
10+
if cond:
11+
print(f"[VERIFY] {name}")
12+
else:
13+
print(f"[FAIL] {name}")
14+
errors.append(name)
15+
16+
accepted_path = ROOT / "epochs/current/accepted-epoch-0001.json"
17+
index_path = ROOT / "epochs/current/index.json"
18+
history_readme = ROOT / "epochs/history/README.md"
19+
20+
for rel in [
21+
"epochs/current/accepted-epoch-0001.json",
22+
"epochs/current/index.json",
23+
"epochs/history/README.md",
24+
"current/epoch.json",
25+
"current/graph.json",
26+
"current/trust-summary.json",
27+
"current/contradictions.json",
28+
"current/repairs.json",
29+
"current/quarantine.json",
30+
"current/digest.txt",
31+
]:
32+
need((ROOT / rel).is_file(), f"file-present {rel}")
33+
34+
accepted = json.loads(accepted_path.read_text(encoding="utf-8"))
35+
index = json.loads(index_path.read_text(encoding="utf-8"))
36+
37+
need(accepted.get("object_type") == "AcceptedEpoch", "accepted-epoch-type")
38+
need(accepted.get("status") == "ACTIVE_TRUTH", "accepted-epoch-status")
39+
need(accepted.get("historical_archive_ref") == "epochs/history/", "accepted-epoch-history-ref")
40+
need(accepted.get("epoch_ref") == "current/epoch.json", "accepted-epoch-epoch-ref")
41+
need(accepted.get("graph_ref") == "current/graph.json", "accepted-epoch-graph-ref")
42+
need(accepted.get("trust_summary_ref") == "current/trust-summary.json", "accepted-epoch-trust-summary-ref")
43+
need(accepted.get("contradictions_ref") == "current/contradictions.json", "accepted-epoch-contradictions-ref")
44+
need(accepted.get("repairs_ref") == "current/repairs.json", "accepted-epoch-repairs-ref")
45+
need(accepted.get("quarantine_ref") == "current/quarantine.json", "accepted-epoch-quarantine-ref")
46+
need(accepted.get("digest_ref") == "current/digest.txt", "accepted-epoch-digest-ref")
47+
48+
need(index.get("object_type") == "AcceptedEpochIndex", "accepted-epoch-index-type")
49+
need(index.get("status") == "ACTIVE_TRUTH", "accepted-epoch-index-status")
50+
need(index.get("historical") is False, "accepted-epoch-index-historical-false")
51+
need(index.get("current_accepted_epoch_ref") == "epochs/current/accepted-epoch-0001.json", "accepted-epoch-index-binding")
52+
53+
entries = index.get("entries", [])
54+
need(len(entries) >= 1, "accepted-epoch-index-entry-present")
55+
if entries:
56+
first = entries[0]
57+
need(first.get("accepted_epoch_id") == accepted.get("accepted_epoch_id"), "accepted-epoch-index-entry-id")
58+
need(first.get("path") == "epochs/current/accepted-epoch-0001.json", "accepted-epoch-index-entry-path")
59+
need(first.get("epoch_ref") == "current/epoch.json", "accepted-epoch-index-entry-epoch-ref")
60+
need(first.get("graph_ref") == "current/graph.json", "accepted-epoch-index-entry-graph-ref")
61+
62+
epoch = json.loads((ROOT / accepted["epoch_ref"]).read_text(encoding="utf-8"))
63+
graph = json.loads((ROOT / accepted["graph_ref"]).read_text(encoding="utf-8"))
64+
trust = json.loads((ROOT / accepted["trust_summary_ref"]).read_text(encoding="utf-8"))
65+
contradictions = json.loads((ROOT / accepted["contradictions_ref"]).read_text(encoding="utf-8"))
66+
repairs = json.loads((ROOT / accepted["repairs_ref"]).read_text(encoding="utf-8"))
67+
quarantine = json.loads((ROOT / accepted["quarantine_ref"]).read_text(encoding="utf-8"))
68+
69+
need("epoch_id" in epoch, "epoch-object-readable")
70+
need("law_version" in epoch, "epoch-law-version-present")
71+
need("graph_digest" in epoch, "epoch-graph-digest-present")
72+
need(isinstance(graph, dict) and len(graph) > 0, "graph-surface-readable")
73+
need(isinstance(trust, dict) and len(trust) > 0, "trust-summary-readable")
74+
need(isinstance(contradictions.get("items"), list), "contradictions-readable")
75+
need(isinstance(repairs.get("items"), list), "repairs-readable")
76+
need(isinstance(quarantine.get("items"), list), "quarantine-readable")
77+
need("current/epoch.json" in (ROOT / "current/digest.txt").read_text(encoding="utf-8"), "digest-covers-current-epoch")
78+
need("historical" in history_readme.read_text(encoding="utf-8").lower(), "history-archive-explicit")
79+
80+
if errors:
81+
print("[FAIL] PHASE 4 / STEP 51 accepted-epoch minimum verification failed")
82+
for e in errors:
83+
print(f" - {e}")
84+
sys.exit(1)
85+
86+
print("[PASS] PHASE 4 / STEP 51 accepted-epoch minimum verified")

0 commit comments

Comments
 (0)