2026-10-12 18:28:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2026-10-12 19:07:32 +02:00
|
|
|
"""Validate every example dataspace against the v0.1 contract."""
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import sys
|
2026-10-12 18:28:16 +02:00
|
|
|
from pathlib import Path
|
2026-10-12 19:07:32 +02:00
|
|
|
|
2026-10-12 18:28:16 +02:00
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
2026-10-12 19:07:32 +02:00
|
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
|
|
|
|
|
|
from content_explorer.contract import validate_dataspace # noqa: E402
|
|
|
|
|
|
|
|
|
|
def main() -> int:
|
|
|
|
|
errors: list[str] = []
|
|
|
|
|
directories = sorted((ROOT / "examples" / "dataspaces").glob("*/snapshot.json"))
|
|
|
|
|
if not directories:
|
|
|
|
|
print("no dataspace fixtures found", file=sys.stderr)
|
|
|
|
|
return 1
|
|
|
|
|
for snapshot_path in directories:
|
|
|
|
|
directory = snapshot_path.parent
|
|
|
|
|
found = validate_dataspace(directory, require_size=True)
|
|
|
|
|
errors.extend(found)
|
|
|
|
|
if not found:
|
|
|
|
|
print(f"{directory.name}: contract ok")
|
|
|
|
|
if errors:
|
|
|
|
|
print("\n".join(errors), file=sys.stderr)
|
|
|
|
|
return 1
|
|
|
|
|
print("Fixture validation OK")
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
raise SystemExit(main())
|