Skip to content

Commit 5c9848a

Browse files
Merge pull request #64 from OneFineStarstuff/codex/develop-agi-governance-blueprint-for-financial-institutions
Add governance artifacts package with validation, manifest tooling, tests, and CI workflow
2 parents d32ee78 + b413fcf commit 5c9848a

22 files changed

Lines changed: 1802 additions & 0 deletions
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Artifact Validation
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- 'artifacts/**'
8+
- 'unit_tests/**'
9+
- 'pytest.ini'
10+
- '.github/workflows/artifact-validation.yml'
11+
pull_request:
12+
paths:
13+
- 'artifacts/**'
14+
- 'unit_tests/**'
15+
- 'pytest.ini'
16+
- '.github/workflows/artifact-validation.yml'
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
validate:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.12'
33+
34+
- name: Install deps
35+
run: make -C artifacts deps
36+
37+
- name: Run artifact validation via Makefile
38+
run: make -C artifacts all

artifacts/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.PHONY: deps manifest-check validate check-all test all
2+
3+
PYTHON ?= python
4+
5+
deps:
6+
$(PYTHON) -m pip install -r requirements-artifacts.txt
7+
8+
manifest-check:
9+
$(PYTHON) build_manifest.py --check --json
10+
11+
validate:
12+
$(PYTHON) validate_artifacts.py --json
13+
14+
check-all:
15+
$(PYTHON) check_all.py --json
16+
17+
test:
18+
cd .. && $(PYTHON) -m pytest -q unit_tests/test_artifacts_validation.py
19+
20+
# `check-all` already runs semantic validation and manifest verification.
21+
all: manifest-check check-all test

artifacts/README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Governance Artifacts Usage Guide
2+
3+
This folder contains machine-readable assets for enterprise and regulator-facing AI governance workflows.
4+
5+
## Files
6+
7+
- `annex-iv-dossier-schema-v1.json`: JSON Schema for EU AI Act Annex IV dossier payloads.
8+
- `control-catalog-v1.json`: control inventory with ownership, cadence, severity, and framework mappings.
9+
- `roadmap-2026-2030.yaml`: phased implementation and milestone plan.
10+
- `regulator-report-template.xml`: regulator-ready report skeleton.
11+
- `enterprise-civilizational-agi-asi-blueprint-2026-2030.md`: implementation blueprint narrative.
12+
- `examples/annex-iv-dossier-example.json`: sample payload conforming to Annex IV schema.
13+
- `manifest-targets-v1.json`: canonical tracked-file list used by manifest build and validation.
14+
- `schemas/manifest-targets-schema-v1.json`: JSON Schema for manifest-target metadata.
15+
- `schemas/artifact-manifest-schema-v1.json`: JSON Schema for produced checksum manifests.
16+
- `schemas/check-all-result-schema-v1.json`: JSON Schema for unified check JSON output.
17+
- `artifact-manifest-v1.json`: SHA-256 checksum manifest for tamper-evident packaging.
18+
- `validate_artifacts.py`: parser + semantic validation utility.
19+
- `build_manifest.py`: manifest regeneration utility.
20+
- `requirements-artifacts.txt`: pinned runtime/test dependencies for artifact checks.
21+
- `Makefile`: convenience targets for local artifact validation workflows.
22+
23+
## Validation
24+
25+
Human-readable mode:
26+
27+
```bash
28+
python artifacts/validate_artifacts.py
29+
```
30+
31+
Machine-readable JSON mode:
32+
33+
```bash
34+
python artifacts/validate_artifacts.py --json
35+
```
36+
37+
Skip checksum validation (for local editing before manifest regeneration):
38+
39+
```bash
40+
python artifacts/validate_artifacts.py --skip-manifest
41+
```
42+
43+
On validation failure with `--json`, output is `{ "status": "error", "error": "..." }` and exit code is `1`.
44+
45+
Exit behavior: all CLI tools return `0` on success and `1` on validation/check failure.
46+
47+
The validator performs:
48+
1. JSON/YAML/XML parse checks.
49+
2. Required key checks for schema, roadmap, and controls.
50+
3. Annex IV sample semantic checks (types, required fields, enum values, date format).
51+
4. Control mapping cross-reference checks (no unknown control IDs).
52+
5. Regulator XML required section checks.
53+
6. Roadmap milestone date-range checks (2026–2030).
54+
7. Manifest checksum checks for all tracked artifacts.
55+
8. Manifest coverage checks (no missing or unexpected files).
56+
57+
## Regenerate checksum manifest
58+
59+
```bash
60+
python artifacts/build_manifest.py
61+
```
62+
63+
Supports reproducible builds via `SOURCE_DATE_EPOCH`.
64+
65+
Verify manifest freshness without rewriting:
66+
67+
```bash
68+
python artifacts/build_manifest.py --check
69+
python artifacts/build_manifest.py --check --json
70+
```
71+
72+
## Install dependencies
73+
74+
```bash
75+
pip install -r artifacts/requirements-artifacts.txt
76+
# or:
77+
cd artifacts && make deps
78+
# or from repo root:
79+
make -C artifacts deps
80+
```
81+
82+
## Unified check
83+
84+
```bash
85+
python artifacts/check_all.py
86+
python artifacts/check_all.py --json
87+
```
88+
89+
`check_all --json` includes `schema_version`, `checked_at` (UTC ISO-8601), `manifest_fresh`, `validation_ok`, and `errors`.
90+
91+
## Makefile shortcuts
92+
93+
```bash
94+
cd artifacts
95+
make all
96+
# Optional: override interpreter, e.g. PYTHON=python3.12 make all
97+
# or from repo root:
98+
make -C artifacts all
99+
```
100+
101+
Other useful shortcuts:
102+
- `make manifest-check`
103+
- `make validate`
104+
- `make check-all`
105+
- `make test`
106+
107+
## Test
108+
109+
```bash
110+
python -m pytest -q unit_tests/test_artifacts_validation.py
111+
# or from artifacts/: make test
112+
```
113+
114+
115+
CI note: `.github/workflows/artifact-validation.yml` supports `workflow_dispatch` for on-demand re-validation, runs `make -C artifacts all` as the canonical validation entrypoint, and triggers on changes to `artifacts/**`, `unit_tests/**`, `pytest.ini`, and the workflow file itself.

artifacts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Governance artifacts tooling package."""
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://example.org/schemas/annex-iv-dossier-schema-v1.json",
4+
"title": "EU AI Act Annex IV Dossier",
5+
"type": "object",
6+
"required": [
7+
"provider",
8+
"system",
9+
"intended_purpose",
10+
"architecture",
11+
"training_data",
12+
"performance",
13+
"oversight",
14+
"post_market_monitoring",
15+
"change_log"
16+
],
17+
"properties": {
18+
"provider": {
19+
"type": "object",
20+
"required": ["legal_name", "jurisdiction", "accountable_officer"],
21+
"properties": {
22+
"legal_name": {"type": "string"},
23+
"jurisdiction": {"type": "string"},
24+
"accountable_officer": {"type": "string"}
25+
}
26+
},
27+
"system": {
28+
"type": "object",
29+
"required": ["name", "version", "risk_tier"],
30+
"properties": {
31+
"name": {"type": "string"},
32+
"version": {"type": "string"},
33+
"risk_tier": {"type": "string", "enum": ["low", "limited", "high", "frontier"]}
34+
}
35+
},
36+
"intended_purpose": {"type": "string"},
37+
"architecture": {"type": "string"},
38+
"training_data": {"type": "string"},
39+
"performance": {"type": "string"},
40+
"oversight": {"type": "string"},
41+
"post_market_monitoring": {"type": "string"},
42+
"change_log": {
43+
"type": "array",
44+
"items": {
45+
"type": "object",
46+
"required": ["date", "change", "approver"],
47+
"properties": {
48+
"date": {"type": "string", "format": "date"},
49+
"change": {"type": "string"},
50+
"approver": {"type": "string"}
51+
}
52+
}
53+
}
54+
}
55+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"files": {
3+
"annex-iv-dossier-schema-v1.json": "191c3442f4b372e8fb400640648841fb4d63aecdfb791d0b1b230a65a384ffe1",
4+
"control-catalog-v1.json": "56328ecaed2af4d832e993accb3b85d63d69f93eece4f10de08f0c82f71729d8",
5+
"enterprise-civilizational-agi-asi-blueprint-2026-2030.md": "12684e460b4f33a49d74e66eaa1400aab85e4dd6879e262e06ac932be7c3f3e3",
6+
"examples/annex-iv-dossier-example.json": "fd914a07bf2691d9de262907953890ba353b23fe159d07a8b53eee1e6d16b1e2",
7+
"regulator-report-template.xml": "62c55a96b60bbc4592f0ad273ee1cca6e25eac6a437fb047dfb08bdf5baeab2d",
8+
"roadmap-2026-2030.yaml": "2297c95faefe22ff03cb9aa7d104be232fa0269b831cb231f5b7f0ab0ed86369"
9+
},
10+
"generated_at": "2026-04-26T03:26:37+00:00",
11+
"version": "1.1"
12+
}

artifacts/build_manifest.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""Build checksum manifest for governance artifacts.
2+
3+
Supports reproducible timestamps via SOURCE_DATE_EPOCH.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
import argparse
9+
import json
10+
from pathlib import Path
11+
12+
ARTIFACTS_DIR = Path(__file__).resolve().parent
13+
14+
if __package__ in (None, ""):
15+
from manifest_utils import load_manifest_targets_from_dir, sha256_file, timestamp_iso8601
16+
else:
17+
from .manifest_utils import load_manifest_targets_from_dir, sha256_file, timestamp_iso8601
18+
19+
20+
def load_manifest_targets() -> list[str]:
21+
return load_manifest_targets_from_dir(ARTIFACTS_DIR)
22+
23+
24+
def build_manifest_payload() -> dict:
25+
manifest = {
26+
"version": "1.1",
27+
"generated_at": timestamp_iso8601(),
28+
"files": {},
29+
}
30+
for rel in load_manifest_targets():
31+
manifest["files"][rel] = sha256_file(ARTIFACTS_DIR / rel)
32+
return manifest
33+
34+
35+
def parse_args() -> argparse.Namespace:
36+
parser = argparse.ArgumentParser(description="Build or check artifact checksum manifest")
37+
parser.add_argument("--check", action="store_true", help="Exit non-zero if manifest is out of date")
38+
parser.add_argument("--json", action="store_true", help="Emit machine-readable JSON output")
39+
return parser.parse_args()
40+
41+
42+
def emit(args: argparse.Namespace, payload: dict) -> None:
43+
if args.json:
44+
print(json.dumps(payload, indent=2, sort_keys=True))
45+
else:
46+
print(payload["message"])
47+
48+
49+
def run_cli(args: argparse.Namespace) -> int:
50+
try:
51+
out = ARTIFACTS_DIR / "artifact-manifest-v1.json"
52+
payload = build_manifest_payload()
53+
rendered = json.dumps(payload, indent=2, sort_keys=True) + "\n"
54+
55+
if args.check:
56+
if not out.exists():
57+
emit(args, {"status": "error", "message": "Manifest missing. Run: python artifacts/build_manifest.py"})
58+
return 1
59+
try:
60+
existing = json.loads(out.read_text(encoding="utf-8"))
61+
except json.JSONDecodeError:
62+
emit(args, {"status": "error", "message": "Manifest file is invalid JSON. Run: python artifacts/build_manifest.py"})
63+
return 1
64+
if not isinstance(existing, dict):
65+
emit(args, {"status": "error", "message": "Manifest file has invalid structure. Run: python artifacts/build_manifest.py"})
66+
return 1
67+
if existing.get("version") != payload.get("version") or existing.get("files") != payload.get("files"):
68+
emit(args, {"status": "error", "message": "Manifest is out of date. Run: python artifacts/build_manifest.py"})
69+
return 1
70+
emit(args, {"status": "ok", "message": "Manifest is up to date."})
71+
return 0
72+
73+
out.write_text(rendered, encoding="utf-8")
74+
emit(args, {"status": "ok", "message": f"Wrote {out}"})
75+
return 0
76+
except ValueError as exc:
77+
emit(args, {"status": "error", "message": str(exc)})
78+
return 1
79+
80+
81+
def main() -> None:
82+
args = parse_args()
83+
raise SystemExit(run_cli(args))
84+
85+
86+
if __name__ == "__main__":
87+
main()

0 commit comments

Comments
 (0)