33
44import argparse
55import json
6- from pathlib import Path
76import sys
7+ from pathlib import Path
88
99import yaml
1010
@@ -21,9 +21,18 @@ def run_checks(artifacts_dir: Path) -> list[dict[str, str]]:
2121 checks : list [dict [str , str ]] = []
2222
2323 def record (name : str , ok : bool , detail : str ) -> None :
24- checks .append ({"name" : name , "status" : "PASS" if ok else "FAIL" , "detail" : detail })
25-
26- presence_ok = all ([yaml_file .exists (), json_file .exists (), rego_file .exists (), schema_file .exists ()])
24+ checks .append (
25+ {"name" : name , "status" : "PASS" if ok else "FAIL" , "detail" : detail }
26+ )
27+
28+ presence_ok = all (
29+ [
30+ yaml_file .exists (),
31+ json_file .exists (),
32+ rego_file .exists (),
33+ schema_file .exists (),
34+ ]
35+ )
2736 record ("presence" , presence_ok , "Required YAML/JSON/Rego/schema artifacts exist" )
2837 if not presence_ok :
2938 return checks
@@ -35,7 +44,9 @@ def record(name: str, ok: bool, detail: str) -> None:
3544 j = json .load (f )
3645 r = rego_file .read_text ()
3746 schema = json .loads (schema_file .read_text ())
38- record ("parseability" , True , "YAML/JSON/schema parse and Rego file read succeeded" )
47+ record (
48+ "parseability" , True , "YAML/JSON/schema parse and Rego file read succeeded"
49+ )
3950 except (OSError , json .JSONDecodeError , yaml .YAMLError ) as exc :
4051 record ("parseability" , False , f"Artifact parse/read failure: { exc } " )
4152 return checks
@@ -47,38 +58,61 @@ def record(name: str, ok: bool, detail: str) -> None:
4758 and profile .get ("thresholds" , {}).get ("drift_psi_max" ) == 0.20
4859 and profile .get ("thresholds" , {}).get ("sev1_regulator_notification_hours" ) == 24
4960 )
50- record ("yaml_invariants" , yaml_ok , "Profile name, tier controls, and thresholds match expected contract" )
61+ record (
62+ "yaml_invariants" ,
63+ yaml_ok ,
64+ "Profile name, tier controls, and thresholds match expected contract" ,
65+ )
5166
5267 json_ok = (
5368 j .get ("artifact_type" ) == "annex_iv_technical_documentation"
5469 and "EU_AI_Act_Annex_IV" in j .get ("regulatory_scope" , [])
5570 and j .get ("monitoring" , {}).get ("drift" , {}).get ("threshold" ) == 0.20
5671 )
57- record ("json_invariants" , json_ok , "Artifact type, Annex IV scope, and drift threshold match expected contract" )
72+ record (
73+ "json_invariants" ,
74+ json_ok ,
75+ "Artifact type, Annex IV scope, and drift threshold match expected contract" ,
76+ )
5877
5978 schema_ok = (
6079 isinstance (schema , dict )
6180 and set (schema .get ("required" , [])) == {"ok" , "checks" }
6281 and schema .get ("properties" , {}).get ("checks" , {}).get ("type" ) == "array"
6382 )
64- record ("report_schema" , schema_ok , "Validator report schema exposes ok/checks contract" )
83+ record (
84+ "report_schema" , schema_ok , "Validator report schema exposes ok/checks contract"
85+ )
6586
6687 rego_ok = (
6788 "default allow := false" in r
6889 and 'input.tier == "Tier-4"' in r
6990 and "input.frontier.containment_certified" in r
7091 and "input.board.systemic_signoff" in r
7192 )
72- record ("rego_guardrails" , rego_ok , "Deny-by-default and Tier-4 containment/signoff guards are present" )
93+ record (
94+ "rego_guardrails" ,
95+ rego_ok ,
96+ "Deny-by-default and Tier-4 containment/signoff guards are present" ,
97+ )
7398
7499 return checks
75100
76101
77102def main () -> int :
78- parser = argparse .ArgumentParser (description = "Validate regulator blueprint artifacts" )
103+ parser = argparse .ArgumentParser (
104+ description = "Validate regulator blueprint artifacts"
105+ )
79106 parser .add_argument ("--json" , action = "store_true" , help = "Emit JSON check results" )
80- parser .add_argument ("--list-checks" , action = "store_true" , help = "List checks without executing" )
81- parser .add_argument ("--base-dir" , type = Path , default = DEFAULT_ART , help = "Artifact directory to validate" )
107+ parser .add_argument (
108+ "--list-checks" , action = "store_true" , help = "List checks without executing"
109+ )
110+ parser .add_argument (
111+ "--base-dir" ,
112+ type = Path ,
113+ default = DEFAULT_ART ,
114+ help = "Artifact directory to validate" ,
115+ )
82116 args = parser .parse_args ()
83117
84118 check_names = [
0 commit comments