Scenario test · 90 minutes
Review a half-finished governance pack and decide go or no-go
- Find the gaps in a governance pack with the checkers of the course and with your own judgement
- Complete the pack, with evidence that code produces
- Write a one-page go or no-go memo with measured results
The lab folder as it stands after this lesson. Unzip it in ~/krlab.
More
The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.
Scenario
Alder Staffing is an invented recruitment company. Its team built HireRank, a tool that ranks candidate CVs for recruiters, and wants to launch it on Monday. The builder, Ivo, says that the governance pack is done. Your lead gives you the day: "Find what is missing or wrong, complete the pack as far as the evidence allows, and tell me in one page whether we go or not. I will sign the memo." You have the pack as a folder, the tools of the course, and the invented data.
The rules of the setting: every person, company, vendor and data set here is invented. As in lesson 5, a "decision" in the pack is the recommendation that HireRank gives to the recruiter (the column approved is 1 when a candidate goes on the shortlist), and the recruiter makes the final choice. The fairness data is the synthetic data/screening.csv of lesson 4. The date of the check is fixed at 2026-11-21 in pack.json.
Your tasks
Work in ~/krlab/ai-governance with the environment on. Save the generator below, then run it with python scenario_pack.py. It writes the folder scenario/ with 22 files. It is the colleague's pack: read it before you trust it.
scenario_pack.py
"""scenario_pack.py: write scenario/, the half-finished governance pack of Alder Staffing (an invented company).
Run it once: python3 scenario_pack.py It overwrites scenario/. Do not edit this file: fix the files in scenario/.
"""
import csv
import json
from pathlib import Path
import numpy as np
import card
from explain import explain_one
from fairness import fit, load, split
OUT = Path("scenario")
FEATURES = ["test_score", "years", "gap_months"]
FILES = {
"raci.csv": """system,activity,person,raci
HireRank,build,Ivo,R
HireRank,build,Hana,A
HireRank,review,Jada,R
HireRank,review,Kofi,A
HireRank,approve,Ivo,A
HireRank,run,Lena,R
HireRank,run,Hana,A
""",
"policy.md": """# AI use policy of Alder Staffing
Owner: Hana
Version: 1.0
Next review: 2027-06-01
### Purpose
This policy says which AI systems Alder Staffing may use for hiring work and who answers for them.
### Scope
It covers every AI system that ranks, filters or summarises candidates, whether we build it or buy it.
### Roles
Each system has one owner who answers for it. A builder makes it, a reviewer tests it, an approver decides on launch.
### Rules
Each system is in the inventory and the risk register. Systems that rank people are tested for fairness every month.
""",
"inventory.csv": """id,name,owner,purpose,vendor,data_class,match,status
S1,HireRank,Hana,Ranks candidate CVs for recruiters,in-house,personal,,trial
S2,ChatDesk,Lena,,ModelHost,internal,,approved
""",
"register.csv": """id,risk,cause,impact,likelihood,owner,control,res_impact,res_likelihood
A1,The ranking is unfair to group B,Career gaps count against a candidate,4,4,Hana,Check the selection rate before each release,4,3
A2,Hidden text in a CV steers the ranking,Prompt injection through the CV file,4,3,Ivo,Strip hidden text before scoring,4,2
A3,Candidate data is kept too long,No deletion job,3,3,,Delete after 12 months,3,1
A4,The CV parser vendor changes its terms,Terms are not watched,2,3,Kofi,Review the terms every year,2,4
""",
"systems.csv": """id,name,role,area,practice,annex_i_product,narrow_task,profiling,talks_to_people,makes_content,declared
S1,HireRank,provider,employment,none,n,n,y,n,n,minimal
S3,InterviewNotes,deployer,none,none,n,n,n,n,y,transparency
""",
"context.md": "# Context map of HireRank\n\nHireRank ranks CVs for recruiters. A recruiter always makes the final choice. Candidates see only the recruiter's answer.\n",
"response.md": "# Response plan for HireRank\n\nIf the selection-rate ratio falls below the limit, the owner switches HireRank off the same day and the builder finds the cause.\n",
"rmf_plan.csv": """function,artefact,file,owner,status
Govern,AI use policy,policy.md,Hana,done
Govern,Accountability table,raci.csv,Hana,done
Map,Context map,context.md,Ivo,done
Map,Risk register,register.csv,Hana,done
Measure,Fairness measurement,fairness_report.txt,Jada,done
Manage,Response plan,response.md,Lena,done
""",
"ams_records.csv": """record,area,owner,last_done,every_days
AI policy,Leadership,Hana,2026-06-01,365
Internal audit,Performance,Kofi,2025-10-01,365
Monitoring report,Performance,,2026-11-10,30
""",
"vendor.json": json.dumps({"vendor": "TalentParse", "service": "CV parsing API", "data_class": "personal",
"data_use": "opt_out", "retention_days": 60, "regions": ["eu-west", "us-east"], "subprocessors": "listed",
"incident_notice_hours": 72, "audit_right": "report_only", "reviewed": "2026-11-05", "reviewer": "Jada"}, indent=2) + "\n",
"vendor-alt.json": json.dumps({"vendor": "EuParse", "service": "CV parsing API, EU only", "data_class": "personal",
"data_use": "no_training", "retention_days": 30, "regions": ["eu-north"], "subprocessors": "listed_with_notice",
"incident_notice_hours": 24, "audit_right": "report_only", "reviewed": "2026-11-12", "reviewer": "Jada"}, indent=2) + "\n",
"flows.csv": """system,data_class,destination,region
HireRank,personal,TalentParse,us-east
HireRank,internal,Mail server,eu-west
""",
"incidents.csv": """id,date,system,severity,reported_to,closed
I1,2026-10-08,HireRank,serious,,2026-10-12
I2,2026-11-03,ChatDesk,minor,,
""",
"dpia.md": """# Data protection impact assessment of HireRank
Owner: Hana
Reviewed by:
### Purpose
HireRank ranks candidate CVs for a recruiter, who makes the final choice.
### Data
CV data of job candidates: test score, years of experience and months of career gap. The group label is kept apart from the model inputs and is used only to measure fairness.
### Risks to people
A candidate can be ranked low because of a career gap, which is longer in group B. A leak of CV data would harm candidates.
### Measures
Fairness test each month. Recruiters see the reasons for each ranking. Candidates can ask for their data to be deleted.
""",
"model_card.json": json.dumps({"name": "HireRank", "version": "1.0", "owner": "Hana", "builder": "Ivo",
"purpose": "Ranks candidate CVs for a recruiter. It does not decide alone.",
"out_of_scope": "Automatic rejection. Roles outside logistics and warehousing.",
"model_type": "Logistic regression on test score, years of experience and months of career gap",
"training_data": "screening.csv, described in datasheet.json",
"metrics": {"accuracy": "0.82", "tested_on": "240 held-out rows"},
"limits": "Trained on past hiring decisions."}, indent=2) + "\n",
"datasheet.json": json.dumps({"name": "screening.csv", "owner": "Hana", "purpose": "Train and test the CV ranking.",
"collection": "Generated by makedata.py with seed 11. No real person is in it.", "rows": 800,
"fields": ["id", "group", "test_score", "years", "gap_months", "hired"], "personal_data": "none, synthetic",
"known_issues": ["Past managers penalised career gaps, which are longer in group B."]}, indent=2) + "\n",
"people.csv": """person,job,trained
Hana,business owner,2026-09-01
Ivo,machine learning engineer,2026-09-01
Jada,AI security architect,2026-09-15
Kofi,approver,2026-09-15
Lena,platform engineer,2025-08-30
""",
"controls.csv": """item,control,evidence,owner,reason
fairness,Selection rate checked each month,fairness_report.txt,Jada,
reliability and safety,A recruiter makes every final choice,response.md,Hana,
transparency,Approved model card,model_card.json,Hana,
privacy and security,Impact assessment,dpia.md,Hana,
differential privacy,Noise on released counts,dp_release.txt,Jada,
explainability,A record of reasons for each ranking,explanations.jsonl,Ivo,
inclusiveness,Known limits written down,context.md,Ivo,
accountability,One A for each activity,raci.csv,Hana,
consistency,Repeat run gives the same decisions,consistency.txt,Ivo,
awareness training,Training each year,people.csv,Hana,
""",
"pack.json": '{"system": "HireRank", "fairness_threshold": 0.80, "today": "2026-11-21"}\n',
}
def main():
OUT.mkdir(exist_ok=True)
for name, text in FILES.items():
(OUT / name).write_text(text)
X, y, g = load("data/screening.csv", FEATURES, "hired")
with open("data/screening.csv", newline="") as f:
ids = np.array([r["id"] for r in csv.DictReader(f)])
X_train, X_test, y_train, y_test, _, g_test, _, id_test = split(X, y, g, ids)
model = fit(X_train, y_train)
lines, kept = ["id,group,approved"], []
for i, row in enumerate(X_test):
record = explain_one(model, row, FEATURES)
lines.append(f"{id_test[i]},{g_test[i]},{int(record['decision'] == 'approve')}")
kept.append({"id": str(id_test[i]), **record})
(OUT / "decisions.csv").write_text("\n".join(lines) + "\n")
del kept[200], kept[120], kept[40] # three decisions lost their record
kept[10]["reasons"] = [] # one record has no reasons
(OUT / "explanations.jsonl").write_text("".join(json.dumps(r) + "\n" for r in kept))
stale = json.loads(FILES["model_card.json"])
stale["limits"] = "Trained on past hiring decisions. Not tested for fairness."
approval = {"version": "1.0", "card_sha256": card.digest(stale), "approver": "Kofi", "date": "2026-11-12"}
(OUT / "approvals.jsonl").write_text(json.dumps(approval) + "\n")
print("wrote", len(list(OUT.iterdir())), "files in", OUT)
if __name__ == "__main__":
main()1. Find the gaps
Run the pack check on the folder.
python check_pack.py scenarioRead every line, then answer.
For the next three answers, use your tools of the course on the files of the pack.
The check cannot see everything. Read model_card.json, datasheet.json, context.md and the register as a person. Write down at least two things that a script would not find, for example two files that disagree, or a claim that nothing enforces.
2. Repair the fairness gap
The ratio fails the limit of 0.80, and the data sheet says that past managers penalised career gaps. Train the model again without the input gap_months, using the functions of lessons 4 and 5 (load, split, fit, explain_one, by_group, show). Keep the same split and the threshold 0.50. Write retrain.py. It must write, into scenario/, a new decisions.csv, a new explanations.jsonl with a record for every decision, and fairness_report.txt with the table. End that file with one more line: the word accuracy and the overall accuracy of the test rows to two decimals (the form is accuracy 0.51, with your own number).
3. Choose the provider
The provider TalentParse cannot change its terms. Procurement offers EuParse (scenario/vendor-alt.json). Score both with vendor.py and the location rules, and decide.
4. Complete the rest
Fix what the check reports, without lying. Give each missing owner a real name from the pack. Where a date or a number needs work, do the work and record it, as lesson 8 did. Where nobody was told or nobody reviewed, a person must do it, and you record the name. Update the model card so that its metrics match your new model, and approve it with a person who neither owns nor built HireRank. Two principles of the part governance body need work in scenario/controls.csv. Consistency needs evidence that code makes (fairness gets its file from your retraining): keep the fingerprint of scenario/decisions.csv after two runs of your retrain.py, one line after each run, in scenario/consistency.txt (lesson 12). Write the file into scenario/: the check looks only in that folder, and a copy in the lab folder leaves the problem in place. HireRank releases no statistics, so noise on released counts is a ritual for it: mark the row of differential privacy n/a (lesson 12), with a reason of your own and an owner who decided, and do not make evidence for it. A person must do the late training, and you record the date. Run python check_pack.py scenario until it ends with exit code 0.
Hand in
Hand in two things.
- The folder
scenario/with your repairs andretrain.py. - A one-page
decision-memo.mdwith these headings, in this order.
| Heading | What it holds |
|---|---|
| Decision | One line: go, go with conditions, or no-go. |
| What the pack shows | Three sentences: what HireRank does, its class and role, and what the check reported at the start and at the end. |
| Gaps found and fixed | Each gap, the file or check that showed it, and what you changed. Include the two that a script cannot find. |
| Measured results | A table with the ratio, the accuracy, the vendor scores and the problem counts, before and after, with the data set and the date. |
| What is still open | What your evidence does not cover. Give the limits of a ratio on synthetic data and the decisions that people must make. |
| Conditions | What must stay true after launch, who checks it, and how often. |
Review your work
Model solution: commands and results
The first run of the pack check, as the colleague left it:
python check_pack.py scenarioaccountability 2 problem(s)
HireRank: Ivo builds and approves
section missing: Review
inventory 2 problem(s)
S2: purpose is empty
InterviewNotes is named in a file but not in the inventory
risk register 2 problem(s)
A3: no owner
A4: residual risk 8 is above the inherent risk 6
fairness 1 problem(s)
selection-rate ratio 0.56 is below the limit 0.80
explanations 4 problem(s)
P0015: the record has no reasons
P0579: no explanation record
P0476: no explanation record
P0417: no explanation record
classification 1 problem(s)
HireRank: declared minimal, the rules say high-risk-annex-iii
framework plan 2 problem(s)
Measure: no artefact exists
Fairness measurement: marked done, but fairness_report.txt is missing or empty
incident log 1 problem(s)
I1: a serious incident, and nobody was told
management system 2 problem(s)
Internal audit: due 2026-10-01, days late 51 (owner Kofi)
Monitoring report: no owner
vendor and location 2 problem(s)
TalentParse: rejected, 5 of 12 points
HireRank sends personal data to TalentParse in us-east
data protection 1 problem(s)
dpia.md: no 'Reviewed by' line
model card 1 problem(s)
the card changed after its approval: approve it again
governance body 5 problem(s)
Lena: AI awareness training is older than 365 days
Ivo (machine learning engineer) holds approve, which this job may not
fairness: evidence file fairness_report.txt is missing or empty
differential privacy: evidence file dp_release.txt is missing or empty
consistency: evidence file consistency.txt is missing or empty
pack: 26 problem(s)Twenty-six problems. The governance body part has five: a training date that is too old, an engineer who approves, and three principles whose evidence files do not exist yet. The explanations part has four: three decisions without a record and one record without reasons. The selection-rate ratio of 0.56 comes from a model that uses gap_months, an input that past managers penalised and that group B has more of. The classification says minimal for a system that ranks candidates, which the rules put in Annex III (employment). The internal audit was due on 2026-10-01. The incident log has a serious incident that nobody was told about, and the data protection assessment names no reviewer.
The retraining script, written with the functions of lessons 4 and 5:
import csv
import json
from contextlib import redirect_stdout
import numpy as np
from explain import explain_one
from fairness import by_group, fit, load, show, split
FEATURES = ["test_score", "years"]
X, y, g = load("data/screening.csv", FEATURES, "hired")
with open("data/screening.csv", newline="") as f:
ids = np.array([r["id"] for r in csv.DictReader(f)])
X_train, X_test, y_train, y_test, _, g_test, _, id_test = split(X, y, g, ids)
model = fit(X_train, y_train)
records = [{"id": str(id_test[i]), **explain_one(model, row, FEATURES)} for i, row in enumerate(X_test)]
chosen = np.array([int(r["decision"] == "approve") for r in records])
with open("scenario/decisions.csv", "w") as f:
f.write("id,group,approved\n")
for r, group, c in zip(records, g_test, chosen):
f.write(f"{r['id']},{group},{c}\n")
with open("scenario/explanations.jsonl", "w") as f:
f.writelines(json.dumps(r) + "\n" for r in records)
with open("scenario/fairness_report.txt", "w") as f, redirect_stdout(f):
show(by_group(y_test, chosen, g_test))
print("accuracy", round(float((chosen == y_test).mean()), 2))python retrain.py
cat scenario/fairness_report.txtgroup rows accuracy selected true-pos
A 146 0.77 0.26 0.53
B 94 0.80 0.31 0.75
selection-rate ratio 0.84
accuracy 0.78The ratio is 0.84 and accuracy 0.78. Accuracy fell from 0.82, the figure on the card, to 0.78. Group B now has the higher selection rate, which a reviewer should note as well: the metric is a ratio of the lower rate to the higher one, and it does not say which group is ahead.
The provider scores, and the repairs:
python vendor.py score scenario/vendor.json location_rules.json | tail -2
python vendor.py score scenario/vendor-alt.json location_rules.json | tail -2
cd scenario
cp vendor-alt.json vendor.json
sed -i 's/TalentParse,us-east/EuParse,eu-north/' flows.csv
sed -i 's/^HireRank,approve,Ivo,A/HireRank,approve,Kofi,A/' raci.csv
printf '\n### Review\n\nThe owner reads this policy every six months and records the new version and the date of the next review.\n' >> policy.md
sed -i 's/^I1,2026-10-08,HireRank,serious,,/I1,2026-10-08,HireRank,serious,Hana,/' incidents.csv
sed -i 's/^Reviewed by:$/Reviewed by: Jada, 2026-11-21/' dpia.md
sed -i 's/^S2,ChatDesk,Lena,,/S2,ChatDesk,Lena,Answers staff questions,/' inventory.csv
echo 'S3,InterviewNotes,Lena,Drafts notes from interviews,NoteWell,personal,,trial' >> inventory.csv
sed -i 's/,3,3,,/,3,3,Lena,/; s/,2,4$/,2,2/' register.csv
sed -i 's/minimal$/high-risk-annex-iii/' systems.csv
sed -i 's/^Internal audit,Performance,Kofi,2025-10-01/Internal audit,Performance,Kofi,2026-11-21/; s/^Monitoring report,Performance,,/Monitoring report,Performance,Jada,/' ams_records.csv
sed -i 's/"accuracy": "0.82"/"accuracy": "0.78", "selection_rate_ratio": "0.84"/; s/Trained on past hiring decisions\./Trained on past hiring decisions, without the career gap input. Tested for fairness./' model_card.json
cd ..
python retrain.py
sha256sum scenario/decisions.csv | cut -c1-16 > scenario/consistency.txt
python retrain.py
sha256sum scenario/decisions.csv | cut -c1-16 >> scenario/consistency.txt
sed -i 's/^Lena,platform engineer,2025-08-30/Lena,platform engineer,2026-11-21/' scenario/people.csv
sed -i 's|^differential privacy,.*|differential privacy,HireRank releases no statistics,n/a,Jada,No count or other statistic is released from the data of HireRank|' scenario/controls.csv
python card.py approve scenario/model_card.json scenario/approvals.jsonl Kofi 2026-11-21
python check_pack.py scenario
echo "exit code $?"PROBLEM TalentParse: rejected, 5 of 12 points
problems: 1
total 11 of 12: accept
problems: 0
approved version 1.0
accountability ok
inventory ok
risk register ok
fairness ok
explanations ok
classification ok
framework plan ok
incident log ok
management system ok
vendor and location ok
data protection ok
model card ok
governance body ok
pack: 0 problem(s)
exit code 0The provider TalentParse scores 5 and is rejected, and sends personal data to us-east, which the rule does not allow. EuParse scores 11 and keeps data in eu-north. Switching providers fixes both problems at once, and it is a business decision with a cost that the memo must name. The evidence file for consistency comes from the tools of lesson 12, and the row of differential privacy says n/a with a reason and an owner. The date in people.csv records training that a person must really do.
A model decision memo, in short form:
Decision: GO WITH CONDITIONS, as a trial in which a recruiter makes every final choice. NO GO for a launch
as a high-risk system until the provider artefacts (risk management, logging, data governance and the rest)
exist and legal confirms the class. For Annex III systems the amended Act starts those duties on 2 December 2027.
What the pack shows: HireRank ranks CVs for recruiters. In the rules of this course it is a high-risk system
of Annex III (employment), and Alder is its provider. The pack check reported 26 problems at the start and 0 at the end.
Gaps found and fixed: 26 reported (the builder approving his own work, a platform engineer with out-of-date training, three principles without evidence files, missing owners, a classification of minimal, a ratio of
0.56, 3 missing explanation records, a late audit, a rejected provider with a flow to us-east, a serious incident that nobody was told about,
an assessment with no reviewer, a stale approval).
Two that no script found: the card's limits did not mention the career-gap bias that the data sheet records,
and the context map says the recruiter always decides, but nothing in the pack shows how that is enforced.
Measured results: ratio 0.56 to 0.84, accuracy 0.82 to 0.78, provider score 5 to 11, on
data/screening.csv, held-out 240 rows, 2026-11-21.
What is still open: Kofi reviewed and also approved, because every other person in the pack built, owns, reviews or runs HireRank; in a real team
an outsider should approve. Jada's review of the assessment of personal data is a name in a file, and the data protection officer has not read it. Jada marked the differential privacy row `n/a` because HireRank releases no statistics, and nobody outside the team has confirmed that. The data is synthetic, and one ratio on 240 rows is a weak signal. The limit 0.80 and the metric
are choices that people made. Take the dates of the duties from the current official text.
Conditions: the owner reports the ratio and the accuracy each month; any change of model or input needs a new
approval; legal confirms the classification before the high-risk duties apply; the data protection officer reads the assessment
before launch; the recruiter must see the reasons.Mark your report
You mark this yourself, or you ask a colleague or a mentor to mark it. The page checks the numbers above; it cannot read your report.
| Criterion | Not yet | Meets the standard | Strong |
|---|---|---|---|
| Findings | Copies only the checker output. | The 26 problems, and two that no script finds. | Also finds a claim with no evidence, or a metric chosen after the result. |
| Evidence | A claim with no number, file or check line. | Ratio, accuracy, vendor scores, problem counts before and after; data set, model version, date. | retrain.py and commands in the pack; another person gets 0.84 and exit 0. |
| Judgement | Calls 0.84 proof of fairness, or hides that Kofi reviewed and approved. | Synthetic data, 240 rows, a chosen limit and metric, group B now ahead. | Says who decides each open point. |
| Decision | "Go" with no conditions. | Go with conditions, or no-go; each condition has an owner and a frequency. | Names the cost of the provider switch. |
| Legal caveat | States the class or a date as settled. | The class is a triage; legal and the current official text decide. | Lists the missing high-risk duties for legal to confirm. |
| Writing | Over one page, or blames Ivo. | One page, six headings, dated; signable from the decision line. | An outsider can explain the decision after one read. |
Meets the standard in every row: you can show this report as a work sample. Remove names and data that are not yours to share.
The report proves your work on this scenario only, done on your own machine without a proctor.