feat: inventory schema 0.3 and close WP-0006 T01 T02 T04

v0.2 records stay valid. v0.3 requires the five facets. Validators
reject inline Scaleway endpoints and secret-looking strings. The
backup record is the first 0.3 object. Reef views already met T02.
This commit is contained in:
tegwick 2026-08-15 02:40:43 +02:00
parent a9830f3109
commit 34a014a896
8 changed files with 140 additions and 12 deletions

View file

@ -41,11 +41,16 @@ def main() -> int:
assert forecast["record_type"] == "forecast"
assert len({row["period"] for row in forecast["rows"]}) == len(forecast["rows"])
assert all(row["total_eur"] == round(row["infrastructure_eur"] + row["internal_labor_eur"], 2) for row in forecast["rows"])
assert schema["properties"]["schema_version"]["const"] == "0.2"
assert set(schema["properties"]["schema_version"]["enum"]) == {"0.2", "0.3"}
required = set(schema["required"])
v03 = {"description", "decision", "operational_refs", "credential_handles", "consumers"}
for resource in resources:
assert not required - resource.keys(), f"missing fields: {required - resource.keys()}"
need = set(required)
if resource.get("schema_version") == "0.3":
need |= v03
assert not need - resource.keys(), f"missing fields: {need - resource.keys()}"
validate_record(resource)
assert any(resource.get("schema_version") == "0.3" for resource in resources)
operational_records = [load(str(path)) for path in Path("data/control-cycle").glob("*.json")]
control_records += operational_records
record_ids = {record["record_id"] for record in control_records}
@ -126,6 +131,8 @@ def main() -> int:
if view["reef_id"] == "reef-railiance":
assert view["role"] == "compute_substrate"
assert any("reef-storage" in note for note in view.get("notes") or [])
if view["reef_id"] == "reef-storage":
assert view["role"] == "storage_substrate"
print("resource-control declarations: valid")
return 0