Metadata-Version: 2.4
Name: ai-act-inventory
Version: 0.1.0
Summary: AI Act / GDPR AI System Inventory & Risk Register — data model, risk-scoring engine, and Excel workbook generator
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openpyxl>=3.1
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Dynamic: license-file

# ai-act-inventory

A small Python library for building and maintaining an **AI Act / GDPR AI
System Inventory & Risk Register** — the same document previously maintained
as a hand-built Excel workbook (`AI_Act_GDPR_AI_System_Inventory_and_Risk_Register.xlsx`),
now backed by a reusable data model and generator.

## What it does

- **Data model** (`ai_act_inventory.models`): `AISystem` and `RiskAssessment`
  dataclasses mirroring the inventory and risk sheets. `RiskAssessment`
  computes the AI Act risk category, base risk score, regulatory tier
  multiplier, final risk score and risk level in pure Python — the same
  formulas that live in the Excel sheet, so you can query/filter/report on
  your register without opening Excel.
- **Workbook generator** (`ai_act_inventory.workbook.build_workbook`): renders
  any list of `AISystem`/`RiskAssessment` objects into the same styled
  workbook (Instructions, AI System Inventory, Risk Assessment, Dashboard with
  live charts, hidden Lists sheet with drop-downs) as the original template.
  The Risk Assessment sheet's derived columns stay live Excel formulas, so
  rows added by hand in Excel keep auto-calculating.
- **I/O** (`ai_act_inventory.io`): load/save systems and risks as JSON or CSV,
  so the register can be version-controlled or edited outside Excel.
- **CLI** (`ai-act-inventory`): generate the workbook from the command line.

## Install

```bash
cd Work/AI_Act_Inventory
python3 -m venv .venv   # if not already created
source .venv/bin/activate
pip install -e ".[dev]"
```

## CLI usage

```bash
# Generate the workbook straight from the 9 built-in example systems
ai-act-inventory build --output register.xlsx

# Start your own register from the examples, then edit the JSON files
ai-act-inventory init --data-dir ./data
# ... edit ./data/systems.json and ./data/risks.json ...
ai-act-inventory build --data-dir ./data --output register.xlsx
```

## Library usage

```python
import datetime
from ai_act_inventory import AISystem, RiskAssessment, build_workbook

system = AISystem(
    system_id="AI-010",
    system_name="Invoice OCR Extractor",
    acquisition_type="Developed In-House",
    ai_act_role="Provider",
    business_owner="Finance",
    description="Extracts line items from scanned supplier invoices.",
    ai_technique="Computer Vision",
)

risk = RiskAssessment(
    system_id="AI-010",
    annex_iii_domain="None",
    severity=2, likelihood=2, scale_reach=2, vulnerability=1, autonomy=3, data_sensitivity=1,
    mitigation_measures="Human review of extracted totals before posting.",
    risk_owner="Finance Manager",
    next_review_date=datetime.date(2027, 1, 1),
)

print(risk.risk_category, risk.final_risk_score, risk.risk_level)
# Minimal Risk 1.83 Low

build_workbook([system], [risk], "register.xlsx")
```

## Tests

```bash
pytest
```

## Legacy script

`build_workbook.py` is the original standalone script this library was
extracted from; it is kept for reference but superseded by
`ai_act_inventory.workbook.build_workbook` and the `ai-act-inventory` CLI.
