Chapter 22 — Onboarding automation lab
Lesson map
Lesson 22 published. Map, example, EX064.
flowchart TD
N0["Learning outcomes"]
N1["22.1 The check"]
N2["Lab — Role mapping"]
N3["22.2 Interpreting results"]
N4["22.3 Improving the mapping"]
N5["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5
N5 --> EX["Worked example"]
EX --> Q["Exercise EX064"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["22.1 The check"]
N2["Lab — Role mapping"]
N3["22.2 Interpreting results"]
N4["22.3 Improving the mapping"]
N5["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX064"]
[Learning outcomes]
|
v
[22.1 The check]
|
v
[Lab — Role mapping]
|
v
[22.2 Interpreting results]
|
v
[22.3 Improving the mapping]
|
v
[Synthesis]
|
v
[Worked example] --> [Exercise EX064]
Learning outcomes
You will (1) run a role mapping check on synthetic joiners; (2) interpret manual review cases; (3) improve the mapping.
22.1 The check
Using only Python's standard library, Kai builds a small mapper over a synthetic list of new starters with their HR job titles and maps each title to a role group using a mapping table. Titles that do not match any mapping are sent to manual review rather than guessed. The script reads only synthetic HR data and prints the proposed role for each person, so a person approves each result before any account is created. He tests it with known titles before using new data. Results are saved with the run date.
Lab — Role mapping
"""Generate group assignments for synthetic new starters from a role-to-groups mapping (stdlib only)."""
mapping = {"vet": ["vets-all", "clinic-{site}-staff"], "nurse": ["nurses-all", "clinic-{site}-staff"],
"receptionist": ["reception-all", "clinic-{site}-staff"], "finance": ["finance"]}
starters = [("t.ward", "vet", "north"), ("l.osei", "receptionist", "south"), ("r.kim", "nurse", "north"), ("b.gray", "groomer", "south")]
for user, role, site in starters:
if role not in mapping: print(f"{user}: role '{role}' not in mapping -> manual review"); continue
print(f"{user}: {[g.format(site=site) for g in mapping[role]]}")
Run with python3 lab_onboard.py. Verified output:
t.ward: ['vets-all', 'clinic-north-staff']
l.osei: ['reception-all', 'clinic-south-staff']
r.kim: ['nurses-all', 'clinic-north-staff']
b.gray: role 'groomer' not in mapping -> manual review
22.2 Interpreting results
The run maps t.ward, l.osei and r.kim to role groups, and sends b.gray, whose title is groomer, to manual review because no groomer role exists. Kai is pleased the script did not guess: matching groomer to nurse, for example, would have granted clinical write access. He checks the three mapped people against HR and their managers, and all are correct. The manual review list is short, which shows the mapping covers most roles. He also notes that each mapping is easy to read and explain. The managers confirm the results quickly.
22.3 Improving the mapping
Kai and the practice manager agree that groomers need booking access and basic animal record viewing, not clinical write. He adds a new role, role-groomer, with those permissions and a mapping from the groomer title. He adds a test to the script with each known title to confirm the mapping. Each new job title in future goes through the same path: manual review first, then a deliberate decision to create or reuse a role. The tests run each time the mapping table changes.
Worked example
The lab maps three joiners and sends one groomer to manual review; a new role-groomer is created with limited access.
Synthetic case. Joiners, titles and roles are synthetic.
Errors and limits
Mapping unknown titles to the nearest role risks granting access nobody approved.
Exercises
- EX064 — Unmapped person. Who went to manual review? Rubric: 3 = b.gray, a groomer;; 2 = b.gray;; 1 = t.ward;; 0 = none.
- EX065 — Guess risk. Why not guess the groomer's role? Rubric: 3 = might grant clinical write access;; 2 = clinical write;; 1 = vague;; 0 = none.
- EX066 — Groomer access. What access does role-groomer get? Rubric: 3 = booking and basic record viewing;; 2 = booking;; 1 = full;; 0 = none.
Synthesis
Mapping by table with manual review for unknowns keeps automated onboarding safe.
Continue studying — chapter 22 of 30
← Chapter 21 (draft) · Course chapter index · Chapter 23 (draft) →