File size: 1,357 Bytes
ed3aeeb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/env python3
"""Validate canonical registry metadata, eligibility, and local artifacts."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from registry_common import read_registry, validate_registry
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("registry", type=Path)
parser.add_argument("--verify-files", action="store_true")
parser.add_argument("--require-complete", action="store_true")
args = parser.parse_args()
rows = read_registry(args.registry.resolve())
errors = validate_registry(rows, args.verify_files, args.require_complete)
counts: dict[str, int] = {}
for row in rows:
counts[row["eligibility"]] = counts.get(row["eligibility"], 0) + 1
result = {
"registry": str(args.registry.resolve()),
"status": "FAIL" if errors else "PASS",
"candidate_count": len(rows),
"task_count": len({row["task"] for row in rows}),
"eligibility_counts": dict(sorted(counts.items())),
"verify_files": args.verify_files,
"require_complete": args.require_complete,
"errors": errors,
}
print(json.dumps(result, indent=2, sort_keys=True, ensure_ascii=False))
return 1 if errors else 0
if __name__ == "__main__":
raise SystemExit(main())
|