Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata/releases/0.3.120.json

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ def setUpClass(cls) -> None:
cls.catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
cls.schema = ROOT / "metadata/schema/artifact-catalog-v1.schema.json"

def published_catalog(self) -> dict:
catalog = copy.deepcopy(self.catalog)
catalog["entries"] = [row for row in catalog["entries"] if row["publicationState"] == "published"]
return catalog

def known_software_catalog(self, family: str) -> tuple[dict, dict]:
contracts = load_json(ROOT / "metadata/contracts/families-v1.json")
contract = next(row for row in contracts["softwareFamilies"] if row["family"] == family)
catalog = copy.deepcopy(self.catalog)
catalog = self.published_catalog()
if family == "midnight-node-toolkit":
entry = next(row for row in catalog["entries"] if row["family"] == "indexer-standalone" and row["platform"] == "linux/amd64")
entry["family"] = family
Expand Down Expand Up @@ -92,10 +97,12 @@ def known_software_catalog(self, family: str) -> tuple[dict, dict]:

def test_exact_legacy_backfill(self) -> None:
validate_catalog(self.catalog, self.schema)
self.assertEqual(len(self.catalog["entries"]), 66)
self.assertEqual(len({row["semanticId"] for row in self.catalog["entries"]}), 66)
self.assertEqual(len({row["asset"]["name"] for row in self.catalog["entries"]}), 66)
for row in self.catalog["entries"]:
legacy = [row for row in self.catalog["entries"] if row["publicationState"] == "published"]
planned = [row for row in self.catalog["entries"] if row["publicationState"] == "planned"]
self.assertEqual((len(legacy), len(planned), len(self.catalog["entries"])), (66, 31, 97))
self.assertEqual(len({row["semanticId"] for row in legacy}), 66)
self.assertEqual(len({row["asset"]["name"] for row in legacy}), 66)
for row in legacy:
self.assertEqual(row["asset"]["apiDigest"], f"sha256:{row['asset']['sha256']}")
self.assertEqual(row["publicationState"], "published")
self.assertEqual(row["legacyProvenance"], "legacy-unverified")
Expand Down Expand Up @@ -447,7 +454,8 @@ def test_committed_index_and_state_transitions_are_bound(self) -> None:

def test_planned_rows_and_global_destination_identities_are_exact(self) -> None:
_, entry = self.known_software_catalog("indexer-standalone")
planned = copy.deepcopy(self.catalog)
previous = self.published_catalog()
planned = copy.deepcopy(previous)
entry = copy.deepcopy(entry)
entry["version"] = "9.9.9"
entry["semanticId"] = "indexer-standalone/9.9.9/linux/amd64"
Expand All @@ -463,16 +471,16 @@ def test_planned_rows_and_global_destination_identities_are_exact(self) -> None:
planned["entries"].append(entry)
planned["entries"].sort(key=lambda row: row["semanticId"])
validate_catalog(planned, self.schema)
validate_repository_state(planned, stable_index(planned), self.catalog)
self.assertEqual(len(stable_index(planned)["entries"]), len(self.catalog["entries"]))
validate_repository_state(planned, stable_index(planned), previous)
self.assertEqual(len(stable_index(planned)["entries"]), 66)

for mutate in [
lambda row: row["asset"].update({"id": 999}),
lambda row: row["asset"].update({"state": "uploaded"}),
lambda row: row["asset"].pop("sha256"),
]:
invalid = copy.deepcopy(planned)
mutate(next(row for row in invalid["entries"] if row["publicationState"] == "planned"))
mutate(next(row for row in invalid["entries"] if row["semanticId"] == entry["semanticId"]))
with self.assertRaises(WarehouseError):
validate_catalog(invalid, self.schema)

Expand Down
14 changes: 11 additions & 3 deletions tests/test_clean_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
from tests.test_proof_contract import proof_entry # noqa: E402


def published_catalog() -> dict:
catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
catalog["entries"] = [
row for row in catalog["entries"] if row["publicationState"] == "published"
]
return catalog


class CleanRoomReadmeTests(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
Expand All @@ -57,7 +65,7 @@ def future_proposal(self, candidates: list[dict], *, binary_names: list[str], pr
}

def planned_indexer(self, candidate: dict, *, family: str = "indexer-standalone", version: str = "9.9.9", archive: dict | None = None) -> tuple[dict, dict]:
catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
catalog = published_catalog()
contracts = load_json(ROOT / "metadata/contracts/families-v1.json")
contract = next(row for row in contracts["softwareFamilies"] if row["family"] == family)
name = contract["nameTemplate"].format(os="linux", arch="amd64", version=version)
Expand Down Expand Up @@ -323,7 +331,7 @@ def test_readme_exact_proposal_and_receipt_boundary_executes(self) -> None:

# Execute the documented state choreography without exposing the planned row
# through the stable index and without skipping a transition.
base = load_json(ROOT / "metadata/releases/0.3.120.json")
base = published_catalog()
validate_repository_state(planned_catalog, stable_index(planned_catalog), base)
uploading = copy.deepcopy(planned_catalog)
row = next(item for item in uploading["entries"] if item["publicationState"] == "planned")
Expand Down Expand Up @@ -353,7 +361,7 @@ def test_readme_exact_proposal_and_receipt_boundary_executes(self) -> None:
self.assertEqual(len(stable_index(published)["entries"]), 67)

def test_readme_extension_future_k_and_static_revision_gates_execute(self) -> None:
catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
catalog = published_catalog()
family_contract = load_json(ROOT / "metadata/contracts/families-v1.json")
extended_contract = copy.deepcopy(family_contract)
extended_contract["softwareFamilies"].append({
Expand Down
3 changes: 3 additions & 0 deletions tests/test_promotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def evidence(self, envelope_bytes: bytes, authority: str = "owner-approval-1") -

def planned_catalog(self, candidate: list[dict]) -> dict:
catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
catalog["entries"] = [
row for row in catalog["entries"] if row["publicationState"] == "published"
]
for row in candidate:
match = re.fullmatch(r"indexer-standalone-linux-amd64-v(.+)[.]zip", row["name"])
self.assertIsNotNone(match, row["name"])
Expand Down
24 changes: 16 additions & 8 deletions tests/test_proof_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
CONTRACT = load_json(ROOT / "metadata/contracts/proof-data-q8b-v1.json")


def published_catalog() -> dict:
catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
catalog["entries"] = [
row for row in catalog["entries"] if row["publicationState"] == "published"
]
return catalog


def proof_entry(*, k: int | None = None, semver: str | None = None, name: str | None = None, generation: str | None = None, correction_seed: str | None = None) -> dict:
if k is not None:
pinned = CONTRACT["srs"]["objects"][k]
Expand Down Expand Up @@ -124,7 +132,7 @@ def test_exact_q8b_inventory(self) -> None:
self.assertEqual(contract["ledgerStatic"]["archiveBytes"], 21601265)

def test_generation_and_static_revision_resolution(self) -> None:
base = load_json(ROOT / "metadata/releases/0.3.120.json")
base = published_catalog()
generation_1 = proof_entry(k=5)
generation_2 = proof_entry(k=5, name="midnight-srs-noarch-2p5-sha256-" + "d" * 64 + ".bin", generation="sha256:" + "d" * 64)
generation_2["asset"]["id"] = 1000
Expand All @@ -140,7 +148,7 @@ def test_generation_and_static_revision_resolution(self) -> None:
self.assertEqual(result["assetName"], generation_2["asset"]["name"])

normal = proof_entry(semver="9.0.0")
normal_catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
normal_catalog = published_catalog()
normal_catalog["entries"].append(normal)
validate_catalog(normal_catalog, ROOT / "metadata/schema/artifact-catalog-v1.schema.json")
self.assertEqual(normal["proofData"]["memberManifestSha256"], CONTRACT["ledgerStatic"]["memberManifestSha256"])
Expand All @@ -151,7 +159,7 @@ def test_generation_and_static_revision_resolution(self) -> None:
second["asset"]["id"] = 1001
second["asset"]["nodeId"] = "RA_fixture_3"
second["asset"]["apiUrl"] = "https://api.github.com/repos/effectstream/binaries/releases/assets/1001"
another = load_json(ROOT / "metadata/releases/0.3.120.json")
another = published_catalog()
another["entries"].extend([first, second])
validate_catalog(another, ROOT / "metadata/schema/artifact-catalog-v1.schema.json")
with self.assertRaisesRegex(WarehouseError, "Ledger-static"):
Expand All @@ -160,7 +168,7 @@ def test_generation_and_static_revision_resolution(self) -> None:
self.assertEqual(result["assetName"], second["asset"]["name"])

def test_static10_cannot_claim_static9(self) -> None:
base = load_json(ROOT / "metadata/releases/0.3.120.json")
base = published_catalog()
invalid = proof_entry(semver="9.0.0", correction_seed="d")
invalid["proofData"]["exactConsumers"][0]["ledgerStaticSemver"] = "10.0.0"
base["entries"].append(invalid)
Expand All @@ -179,7 +187,7 @@ def test_static10_cannot_claim_static9(self) -> None:
]:
changed = copy.deepcopy(correction)
mutate(changed)
catalog = load_json(ROOT / "metadata/releases/0.3.120.json")
catalog = published_catalog()
catalog["entries"].append(changed)
with self.assertRaises(WarehouseError):
validate_catalog(catalog, ROOT / "metadata/schema/artifact-catalog-v1.schema.json")
Expand Down Expand Up @@ -210,7 +218,7 @@ def test_srs_correction_tokens_bind_generation_bytes_source_and_alias(self) -> N
commit=provider_commit,
)
for entry in [sha, ts, provider]:
base = load_json(ROOT / "metadata/releases/0.3.120.json")
base = published_catalog()
base["entries"].append(entry)
validate_catalog(base, ROOT / "metadata/schema/artifact-catalog-v1.schema.json")

Expand All @@ -227,7 +235,7 @@ def test_srs_correction_tokens_bind_generation_bytes_source_and_alias(self) -> N
(provider, lambda row: row["asset"].update({"sha256": "e" * 64, "apiDigest": "sha256:" + "e" * 64})),
]
for entry, mutate in mutations:
base = load_json(ROOT / "metadata/releases/0.3.120.json")
base = published_catalog()
invalid = copy.deepcopy(entry)
mutate(invalid)
base["entries"].append(invalid)
Expand All @@ -236,7 +244,7 @@ def test_srs_correction_tokens_bind_generation_bytes_source_and_alias(self) -> N

def test_literal_q8b_rows_reject_identity_and_tree_mutations(self) -> None:
for entry in [proof_entry(k=1), proof_entry(semver="9.0.0", correction_seed="e")]:
base = load_json(ROOT / "metadata/releases/0.3.120.json")
base = published_catalog()
base["entries"].append(entry)
validate_catalog(base, ROOT / "metadata/schema/artifact-catalog-v1.schema.json")
identity_mutation = (
Expand Down