Advanced / AI governance for engineers
AI governance for engineers cheat sheet
Set up (lesson 0)
| Task | Command or code |
|---|---|
| Make the lab folder | mkdir -p ~/krlab/ai-governance |
| Make and switch on the environment | python3 -m venv .venv, source .venv/bin/activate |
| Install the pinned versions | pip install -r requirements.txt |
| Write the synthetic data | python makedata.py |
| Prove that the lab works | python labcheck.py |
Accountability (lesson 1)
| Task | Command or code |
|---|---|
| Check a RACI table (one A for each activity) | python raci_check.py raci.csv |
| Check a policy file | python policy_check.py policy.md |
| End a checker with a count and an exit code | finish(problems) from govlib.py |
| Read the exit code of the last command | echo "exit code $?" |
| Change text in a copy | sed 's/old/new/' file > copy |
| Change a file in place (lesson 8 uses it) | sed -i 's/old/new/' file |
| Print the lines without a word | grep -v word file |
| Make an empty file | touch file |
| Copy a file | cp a b |
| Print the first four lines | head -4 file |
| Add a line at the end of a file | echo "text" >> file |
Inventory and shadow AI (lesson 2)
| Task | Command or code |
|---|---|
| Check the inventory | python inventory.py check inventory.csv |
| Find unlisted AI use | python inventory.py shadow inventory.csv data/records.csv ai_rules.json |
| Match a domain and its subdomains | item == d or item.endswith("." + d) |
| Match a product as a whole word | re.search(r"\b" + re.escape(name) + r"\b", item, re.I) |
| Count the lines with a text | grep -c text file |
Risk register (lesson 3)
| Task | Command or code |
|---|---|
| Score and list, worst first | python register.py report register.csv |
| Score of a risk | likelihood * impact, bands 15, 10, 5, 1 |
| Add a row to a copy | echo "R9,..." >> test.csv |
| Send output into the next command, and show its last lines | command | tail -4 |
Fairness (lesson 4)
| Task | Command or code |
|---|---|
| Accuracy, selection rate, true positive rate by group | python fairness.py |
| Selection-rate ratio | lower rate divided by higher rate |
| Compare two mitigations and their cost | python mitigate.py |
| Count the values of one column | cut -d, -f2 file | sort | uniq -c |
| Fixed train and test rows | train_test_split(..., test_size=0.3, random_state=0) |
Explanations (lesson 5)
| Task | Command or code |
|---|---|
| Importance, decisions and explanation records | python explain.py |
| Check that each decision has a record | python explain_check.py decisions.csv explanations.jsonl |
| Reason for one decision, linear model | coef_ * scaler.transform([row])[0] |
| Print the first line that holds a word | grep -m 1 word file |
EU AI Act triage (lesson 6)
| Task | Command or code |
|---|---|
| Class and start date of each system | python classify.py report systems.csv aiact_rules.json |
| Artefacts that one system owes | python classify.py duties systems.csv aiact_rules.json LoanScore |
| Compare declared and computed class | python classify.py check systems.csv aiact_rules.json |
| Take dates and duties from | the current official text on EUR-Lex |
NIST AI RMF (lesson 7)
| Task | Command or code |
|---|---|
| Four functions | Govern, Map, Measure, Manage |
| Check the plan and its files | python plan_check.py rmf_plan.csv [folder] |
| Check the incident log | python incident_check.py incidents.csv |
| Fairness report as a file | python mitigate.py > fairness_report.txt |
| Profile for generative AI | NIST AI 600-1 |
Management system (lesson 8)
| Task | Command or code |
|---|---|
| Report overdue reviews on the fixed date | python overdue.py ams_records.csv |
| Report them for another date | python overdue.py ams_records.csv 2027-01-01 |
| Due date of a record | last_done + timedelta(days=every_days) |
Third parties and data location (lesson 9)
| Task | Command or code |
|---|---|
| Score a provider (0 to 12) | python vendor.py score vendor.json location_rules.json |
| Check the data flows | python vendor.py flows flows.csv location_rules.json |
| A record that cannot be scored | reported as a problem, with no score printed |
| Decision from the points | 10 or more and no zero: accept; 7 or more: conditions; else reject |
| Require an assessment for personal data | python dpia_check.py . LoanScore |
Model card and data sheet (lesson 10)
| Task | Command or code |
|---|---|
| Render Markdown from the JSON | python card.py render model_card.json datasheet.json |
| Check fields and approval | python card.py check model_card.json datasheet.json approvals.jsonl |
| Record an approval | python card.py approve model_card.json approvals.jsonl Elif 2026-11-15 |
| Fingerprint of a document | card.digest(card.load("model_card.json")) |
Governance body (lesson 11)
| Task | Command or code |
|---|---|
| Check that jobs fit the RACI table and training is current | python people_check.py people.csv raci.csv jobs.json |
| Same check for another date | people_check.problems(people, raci, jobs, date(2027, 1, 1)) |
| Change two things in one pass | sed 's/a/b/; s/c/d/' file > copy |
Principles and evidence (lesson 12)
| Task | Command or code |
|---|---|
| Check one control, owner and evidence file for each principle | python controls_check.py controls.csv people.csv register.csv |
| Show a count with noise, a demonstration with a fixed seed (small epsilon, more privacy) | python dp_count.py data/loans.csv B | tee dp_release.txt |
| Fingerprint of a file, 16 characters | sha256sum decisions.csv | cut -c1-16 |
| Count the different lines of a file | sort -u file | wc -l |
| Mark a principle as not applicable | n/a in evidence, and a reason of five words or more |
| Move or rename a file | mv old new |
The governance pack (lesson 13)
| Task | Command or code |
|---|---|
| Check the whole pack (13 parts) | python check_pack.py [folder] |
| Name who approved a group cut-off | "group_cut_off_approved_by" in pack.json |
| Test the check on a broken copy | mkdir copy, cp *.csv *.json *.jsonl *.md *.txt copy/, edit, python check_pack.py copy |
Scenario test (lesson 14)
| Task | Command or code |
|---|---|
| Write the half-finished pack | python scenario_pack.py |
| Check it | python check_pack.py scenario |
| Run your own retraining script (the model solution has one) | python retrain.py |
| Score the two providers | python vendor.py score scenario/vendor.json location_rules.json |
| Approve the repaired card | python card.py approve scenario/model_card.json scenario/approvals.jsonl NAME DATE |
Safety habits
- Use only synthetic data in a lab, so that no real person is put at risk.
- Take dates, duties and article numbers from the current official text. Law and frameworks change.
- Treat a classification table as a first triage, not as legal advice. Your legal team decides.
- Give each activity exactly one accountable person. Two or none means nobody answers.
- Break a checker on purpose once. A check that never failed is not proven.
- Choose the fairness metric and the limit before you see the result, and write down who chose.
- Compute a number from raw data instead of trusting a report. A report is a claim.
- Change a date in a record only after the work is done. A date is a claim of work.
- Keep group labels apart from model inputs and restrict access to them.
- Give each principle a control, an owner and an evidence file. A principle with no file is a slogan.
- Never approve your own work. Give each job only the activities it may hold, and keep training dated.
- Treat a different threshold for each group as a legal question, not as the fix to ship. If you ship it, record who approved it.