Title levels on the ladder: principal, senior manager, distinguished, lead split (WP A)

from_title matches a title twice, for the highest people level and the
highest individual grade. A people level wins on its own rung; a grade
above that rung lifts it one rung (Principal Engineering Manager is a
senior manager). Senior Staff is principal, Senior Principal, Distinguished
and Technical Fellow are distinguished; Associate Director, AVP and Senior
Manager are senior managers. lead is now a team lead only (Team Lead, Shift
Lead, Supervisor, Teamleiter); Tech Lead, Lead X and X Lead(er) are staff.
A slash names two levels, so Senior/Staff is staff.

- Jobylon "lead" maps to staff; Recruitee maps student_college, manager,
  senior_manager and executive.
- extract's prompt describes the ladder and its two tracks; enum from LEVELS.
- prep VERSION 2, so the next prep maps every open role again.
- Migration 25 clears seniority_model where it is staff, lead, manager or
  director, so extract reads those roles again, and sets roles.seniority to
  the first filled of model, stated and title.
- The coverage test of tests/test_seniority.py passes; its xfail is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 13:11:26 +02:00
1 parent ae978594b4
commit 322db49773
16 files changed
+328 -137

No files matched your search

+157 -80
View File
@@ -13,38 +13,58 @@ pattern is a word-bounded regex against that. Patterns are therefore written
folded: `direktör` is `direktor`, `chef d'équipe` is `chef d equipe`; `ø` and
`æ` stay as they are, since NFKD does not decompose them.
The highest level named wins, checked from `exec` down: "Senior Director" is
a director, "Managing Director" an exec, "Lead Project Manager" a lead. The
one exception is `intern`, tried first: a title that says internship or
thesis is one whatever it names after ("Praktikum ... Assistenz des Senior
Vice Presidents"). A C-level or head named as the boss of the person hired
("Executive Assistant to the CEO", "Office of the Head of ...") is cut out
before matching (`_NOISE`). Rules that decide the doubtful cases:
The levels are the ladder of `app.models.LADDER`: from `staff` up, a rung has
an individual-contributor level and a people-lead level. A title is matched
twice, for the highest people level it names (`_PEOPLE`: a head, a manager,
a team lead) and for the highest individual grade (`_GRADES`: Principal,
Staff, Senior). A people level wins over a grade on its own rung or below:
"Staff Engineering Manager" is a manager, "Senior Director" a director. A
grade above the people level's rung lifts it one rung, and one only:
"Principal Engineering Manager" is a senior manager. Without a people level
the grade decides: "Principal Product Manager" is principal, since a product
manager is an individual contributor. A slash names two levels (`_OR`):
"Senior/Staff Engineer" is staff, not a Senior Staff. The one exception is `intern`, tried
first: a title that says internship or thesis is one whatever it names after
("Praktikum ... Assistenz des Senior Vice Presidents"). A C-level or head
named as the boss of the person hired ("Executive Assistant to the CEO",
"Office of the Head of ...") is cut out before matching (`_NOISE`). Rules
that decide the doubtful cases:
- **exec** is C-level ("Chief ... Officer", CTO), "VP" and above (a bank's VP
is mid-level, but a tech company's is not, and the filter is the reader's:
exec), "Managing Director", Geschäftsführer, Vorstand and VD.
- **director** is the word in English, Danish, Swedish, German, French,
Spanish and Italian, "Head of" and a title's own first word "Head", and the
German "Leiter" alone or of a whole department (Bereichsleiter,
Abteilungsleiter). "Senior Director" and "Executive Director" are directors.
- **senior_manager** is "Senior Manager", a senior people manager ("Sr.
Engineering Manager"), "Associate Director", "Assistant Director" and a
bank's "Assistant Vice President" (AVP, Associate VP).
- **manager** is a level only where the word means someone who runs a team:
a bare "Manager", "Senior Manager", "Manager, Data Science" (the word
first, as a level), an "Assistant Store Manager" as a lead, and the compounds whose department or place is what is
managed (`_PEOPLE_MANAGER`: engineering, team, store, general ...). Every
other "X Manager" is an individual contributor by function (Account,
Product, Project, Customer Success, Office, Marketing, Sales ...) and says
nothing, so "Senior Product Manager" is senior. An unlisted compound stays
unknown, which costs a recall the filter's "and no level" makes up.
- **director** is the word in English, Danish, Swedish, German, French, Spanish
and Italian, "Head of" and a title's own first word "Head", and the German
"Leiter" alone or of a whole department (Bereichsleiter, Abteilungsleiter).
"Associate Director" and "Executive Director" are directors. **manager** is
also the Danish, Swedish, German and Dutch head of a shop, site or office
(-chef, -leder, Filialleiter, Kontorchef), French "responsable" and "gérant",
Spanish "jefe" and "gerente". **exec** is C-level ("Chief ... Officer", CTO), "VP" and above
(a bank's VP is mid-level, but a tech company's is not, and the filter is
the reader's: exec), "Managing Director", Geschäftsführer, Vorstand and VD.
A bank's "Assistant Vice President" is a director.
- **lead** is "Lead" as a noun at either end ("Tech Lead", "Lead Engineer";
not "Lead Generation"), "Leader", "Supervisor", and the team-sized German,
Danish, Dutch and French forms (Teamleiter, Teamleider, chef d'équipe).
- **staff** is "Staff" and "Principal". "Staff Nurse", "Staff Accountant"
and their kind are left out; "Principal Investigator" and a
"Staff Scientist" at a lab are taken as staff and are not.
a bare "Manager", "Manager, Data Science" (the word first, as a level), and
the compounds whose department or place is what is managed
(`_PEOPLE_MANAGER`: engineering, team, store, general ...), and a "Tech
Lead Manager". Every other "X
Manager" is an individual contributor by function (Account, Product,
Project, Customer Success, Office, Marketing, Sales ...) and says nothing,
so "Senior Product Manager" is senior. An unlisted compound stays unknown,
which costs a recall the filter's "and no level" makes up. **manager** is
also the head of a shop, site or office: "Store Leader", the Danish,
Swedish, German and Dutch -chef, -leder, Filialleiter, Kontorchef, French
"responsable" and "gérant", Spanish "jefe" and "gerente".
- **lead** is a team lead: "Team Lead", "Team Leader", the floor-sized leads
(`_TEAM_SIZED_LEAD`: shift, crew, kitchen ...), a "People Leader",
"Supervisor", an "Assistant Store Manager" or "Associate Store Leader", and
the team-sized German, Danish, Dutch, Swedish and French forms (Teamleiter,
Teamleider, teamledare, chef d'équipe).
- **distinguished** is "Senior Principal", "Distinguished", "Technical
Fellow", "Engineering Fellow" and SAP's "Chief Expert". "Fellow" alone is
academic ("Research Fellow", "Postdoctoral Fellow") and says nothing.
- **principal** is "Principal" and "Senior Staff".
- **staff** is "Staff", and "Lead" or "Leader" as a noun at either end that
is not a team lead ("Tech Lead", "Lead Engineer", "Marketing Lead", "Sales
Leader"; not "Lead Generation"). "Staff Nurse", "Staff Accountant" and their
kind are left out.
- **project managers stay unknown** in every language (Projektleiter,
Bauleiter, chef de projet, projektleder, prosjektleder): they are Project
Managers. Halbleiter and the other -leiter words for things are cut out too.
@@ -55,9 +75,12 @@ before matching (`_NOISE`). Rules that decide the doubtful cases:
"Mid-level", "Intermediate", "II", "Medior".
Known wrong, and left so: "Senior Care Assistant" and other "senior" that
means elderly; "Level II" outside a role level; "Principal Investigator";
"Staff" on a title with an unlisted staff noun; "Field CTO" taken as unknown;
"Chief of Staff" as unknown; "Assistant Manager" as unknown; French "responsable" is
means elderly; "Level II" outside a role level; "Principal Investigator" and
a "Staff Scientist" at a lab as principal and staff; "Staff" on a title with
an unlisted staff noun; a retail "Lead Store Advisor" and a "Sales Leader"
who runs a team as staff; "Distinguished Engineer, Team Lead" as a senior
manager, one rung above the lead; "Field CTO" taken as unknown; "Chief of
Staff" as unknown; "Assistant Manager" as unknown; French "responsable" is
taken as a manager wherever it stands, and "Directeur" of a small firm as a
director; "VP" as exec at a bank.
"""
@@ -66,7 +89,7 @@ from __future__ import annotations
import re
from app.models import title_key
from app.models import LADDER, title_key
#: A C-level title or abbreviation, for `_NOISE`.
_C_LEVEL = (r"(?:ceo|cto|cfo|coo|cio|ciso|cpo|cdo|chro|caio"
@@ -96,6 +119,7 @@ _NOISE = re.compile(
rf"|office|support|referent\w*|advisor|adviser) (?:\w+ ){{0,3}}?{_C_LEVEL}"
rf"|{_C_LEVEL} (?:assistant|assistenz|office|team|support|founder associate)"
r"|field (?:cto|cio|ciso)"
r"|(?:technical|engineering|technology) fellows? office"
r"|\w*(?:halb|nicht|supra|strom|blitzab)leiter"
r"|\w*(?:projekt|prosjekt|project|bau|bygge|produkt)(?:leiter|leitung|leder|ledare|leider)(?:in)?"
r"|zugchef\w*)\b"
@@ -118,33 +142,40 @@ _HEAD_JOBS = (r"(?:chef|cook|barista|nurse|coach|waiter|bartender|mechanic|garde
r"|teacher|cashier|housekeeper|receptionist|technician|butcher|baker"
r"|stylist|of)")
#: `(level, patterns)`, in the order they are tried: `intern` first, since a
#: title that says internship is one whatever it names after ("Internship, Office
#: of the Head of Product"); then the rest from `exec` down. A title takes the
#: first level with a match, so a rule need not exclude what a later rule claims.
_RULES: tuple[tuple[str, tuple[str, ...]], ...] = (
("intern", (
r"\binterns?\b", r"\binternship\w*", r"\bwerkstudent\w*", r"\bworking students?\b",
r"\bstudent (?:assistant|worker|helper|aide|job|position|trainee|employee)s?\b",
r"\bstudentische\w*", r"\bstudent(?:er)?med(?:hj|arb)\w*",
r"\bstudent\w*job\w*", r"\bjobstudent\b",
r"\w*praktik(?:um|ant\w*|a|ophold|plads)?\b", r"\bpraxissemester\b", r"\bduales? studium\b",
r"\bstagiaires?\b", r"\bstagiair\w*", r"\bstagista\b", r"\btirocin\w*",
r"\bestagiari[oa]s?\b", r"\bbecari[oa]s?\b", r"\bpracticas\b", r"\bpracticante\b",
r"\baprendiz\b", r"\balternan\w*", r"\bapprenti(?:e|es|s)?\b", r"\bapprentice\w*",
r"\bazubi\b", r"\bauszubildende\w*", r"\bausbildung\b", r"\blehr(?:ling|ausbildung|stelle)\b",
r"\w*lærling\w*", r"\b\w*elev\b",
r"\b\w+student\b", r"(?<!phd )(?<!doctoral )(?<!graduate )(?<!masters )\bstudent$",
r"\bvolontar\w*",
r"\b(?:master|bachelor|abschluss)arbeit\b", r"\bthesis\b",
r"\bmasterproef\b", r"\beindwerk\b", r"\bafstudeer\w*",
# French and Dutch "stage": a title that starts or ends with it, or
# says how many months, and not the English stage (Stage Manager, early stage).
r"^stage\b(?! (?:manager|management|hand|crew|technician|director|lighting|door))",
r"(?<!early )(?<!late )(?<!growth )(?<!seed )(?<!mid )(?<!next )(?<!final )"
r"(?<!pre )(?<!first )(?<!phase )\bstage$",
r"\bstage (?:\d+ )?(?:mois|mesi|maanden|months)\b",
)),
#: Floor-sized leads, which run a shift or a crew: "Shift Lead" and "Crew
#: Leader" are team leads where "Marketing Lead" is an individual.
_TEAM_SIZED_LEAD = r"(?:team|shift|crew|group|kitchen|warehouse|floor)"
#: What says the person is still studying or training, tried before
#: anything else: a title that says internship is one whatever it names
#: after ("Internship, Office of the Head of Product").
_INTERN: tuple[str, ...] = (
r"\binterns?\b", r"\binternship\w*", r"\bwerkstudent\w*", r"\bworking students?\b",
r"\bstudent (?:assistant|worker|helper|aide|job|position|trainee|employee)s?\b",
r"\bstudentische\w*", r"\bstudent(?:er)?med(?:hj|arb)\w*",
r"\bstudent\w*job\w*", r"\bjobstudent\b",
r"\w*praktik(?:um|ant\w*|a|ophold|plads)?\b", r"\bpraxissemester\b", r"\bduales? studium\b",
r"\bstagiaires?\b", r"\bstagiair\w*", r"\bstagista\b", r"\btirocin\w*",
r"\bestagiari[oa]s?\b", r"\bbecari[oa]s?\b", r"\bpracticas\b", r"\bpracticante\b",
r"\baprendiz\b", r"\balternan\w*", r"\bapprenti(?:e|es|s)?\b", r"\bapprentice\w*",
r"\bazubi\b", r"\bauszubildende\w*", r"\bausbildung\b", r"\blehr(?:ling|ausbildung|stelle)\b",
r"\w*lærling\w*", r"\b\w*elev\b",
r"\b\w+student\b", r"(?<!phd )(?<!doctoral )(?<!graduate )(?<!masters )\bstudent$",
r"\bvolontar\w*",
r"\b(?:master|bachelor|abschluss)arbeit\b", r"\bthesis\b",
r"\bmasterproef\b", r"\beindwerk\b", r"\bafstudeer\w*",
# French and Dutch "stage": a title that starts or ends with it, or
# says how many months, and not the English stage (Stage Manager, early stage).
r"^stage\b(?! (?:manager|management|hand|crew|technician|director|lighting|door))",
r"(?<!early )(?<!late )(?<!growth )(?<!seed )(?<!mid )(?<!next )(?<!final )"
r"(?<!pre )(?<!first )(?<!phase )\bstage$",
r"\bstage (?:\d+ )?(?:mois|mesi|maanden|months)\b",
)
#: `(level, patterns)` of the people track, from `exec` down. A title takes
#: the first level with a match, so a rule need not exclude what a later rule
#: claims.
_PEOPLE: tuple[tuple[str, tuple[str, ...]], ...] = (
("exec", (
r"\b(?:ceo|cto|cfo|coo|cio|ciso|cpo|cdo|chro|caio)\b",
r"\bchief(?: \w+){0,4}? officer\b", r"\bchief executive\b",
@@ -156,9 +187,9 @@ _RULES: tuple[tuple[str, tuple[str, ...]], ...] = (
r"\bgeschaftsfuhr\w*", r"\bgeschaftsleit\w*", r"\bvorstand\b",
)),
("director", (
r"(?<!associate )(?<!assoc )(?<!assistant )(?<!asst )"
r"\b(?:director(?:a|s|es|in)?|directeur|directrice|direktor(?:in|er)?"
r"|direktør(?:er)?|direttore|direttrice)\b",
r"\bavp\b", r"\b(?:assistant|associate|assoc) (?:vice president|vp)\b",
r"\bhead of\b", r"\b(?:department|division|unit|practice|group|team|country|regional) head\b",
rf"^head (?!{_HEAD_JOBS}\b)", r"\bhead$",
# Leiter(in) alone or of a whole unit (Bereichsleiter), and a title that
@@ -168,10 +199,15 @@ _RULES: tuple[tuple[str, tuple[str, ...]], ...] = (
r"|entwicklungs|werks)leit(?:er|erin|ung)\b",
r"\bhoofd\b",
)),
("senior_manager", (
r"\b(?:associate|assoc|assistant|asst) director\b",
r"\bavp\b", r"\b(?:assistant|associate|assoc) (?:vice president|vp)\b",
rf"\b(?:senior|sr|snr) (?:{_PEOPLE_MANAGER} )?manager\b",
)),
("manager", (
r"^(?:(?:senior|sr|global|regional|group|executive) )*manager\b",
r"\b(?:senior|sr) manager\b",
r"^(?:(?:global|regional|group|executive) )*manager\b",
rf"(?<!assistant )(?<!deputy )(?<!asst )\b{_PEOPLE_MANAGER} manager\b",
r"\btech lead manager\b", r"(?<!associate )\bstore lead(?:er)?\b",
# -leiter / -leder / -leider of a shop, site or department: Filialleiter,
# Afdelingsleder. The team-sized ones are lead (below), and project ones
# are cut out by _NOISE. A -leitung is only these, since "Rohrleitung"
@@ -192,18 +228,33 @@ _RULES: tuple[tuple[str, tuple[str, ...]], ...] = (
r"\bresponsabile\b",
)),
("lead", (
r"\b(?:team|tech|squad)?lead\b", r"\b(?:team|shift)?leader\b",
rf"\b{_TEAM_SIZED_LEAD} ?lead(?:er)?s?\b",
r"\bsupervisor\b", r"\bsuperviseur\b",
rf"\b(?:assistant|deputy|asst) {_PEOPLE_MANAGER} manager\b",
r"\bassociate store leader\b", r"\bpeople leader\b",
r"\b(?:team|gruppen?|schicht|hold|vagt)(?:leit(?:er|erin|ung)|leder|leider)\b",
r"\b(?:team|grupp)?ledare\b", r"\bchef(?: fe)? d equipe\b", r"\blider\b",
r"\bjef[ea] de equipo\b",
r"\b(?:team|grupp)?ledare\b", r"\bchef(?: fe)? d equipe\b",
r"\blider de equip[oe]\b", r"\bjef[ea] de equipo\b",
)),
("staff", (
r"\bstaff\b", r"\bprincipal\b", r"\bdistinguished\b",
)
#: `(level, patterns)` of the individual grades, from the highest down, as
#: `_PEOPLE`: "Senior Principal" is tried before "Principal".
_GRADES: tuple[tuple[str, tuple[str, ...]], ...] = (
("distinguished", (
r"\b(?:senior|sr|snr) principal\b", r"\bdistinguished\b",
r"\b(?:technical|engineering|technology) fellow\b",
# SAP's top individual-contributor grade.
r"\bchief expert\b",
)),
("principal", (
r"\b(?:senior|sr|snr) staff\b", r"\bprincipal\b",
)),
("staff", (
r"\bstaff\b",
# "Lead" the noun at either end; the team leads are `_PEOPLE`'s.
r"\b(?:tech)?lead\b", r"\bleader\b", r"\blider\b",
)),
("senior", (
r"\b(?:senior|sr|snr|iii)\b",
)),
@@ -218,19 +269,45 @@ _RULES: tuple[tuple[str, tuple[str, ...]], ...] = (
)),
)
#: `_RULES`, compiled once, in the same order.
_COMPILED: tuple[tuple[str, tuple[re.Pattern[str], ...]], ...] = tuple(
(level, tuple(re.compile(pattern) for pattern in patterns))
for level, patterns in _RULES)
def _compile(rules: tuple[tuple[str, tuple[str, ...]], ...]
) -> tuple[tuple[str, re.Pattern[str]], ...]:
"""Each level's patterns as one alternation, in the same order."""
return tuple((level, re.compile("|".join(f"(?:{p})" for p in patterns)))
for level, patterns in rules)
_INTERN_RE = re.compile("|".join(f"(?:{p})" for p in _INTERN))
_PEOPLE_RE = _compile(_PEOPLE)
_GRADES_RE = _compile(_GRADES)
#: The people level one rung above each people level, for a grade that lifts it.
_LIFT: dict[str, str] = {
level: next((up for up, (r, t) in LADDER.items() if t == "people" and r == rung + 1), level)
for level, (rung, track) in LADDER.items() if track == "people"}
#: A slash between two words, which `title_key` would fold to a space:
#: "Senior/Principal" names two grades, not a Senior Principal. The gender
#: marker's single letters (m/w/d) are left to `title_key`.
_OR = re.compile(r"(?<=\w\w|\w\.)\s*/\s*(?=\w\w)")
def _first(rules: tuple[tuple[str, re.Pattern[str]], ...], folded: str) -> str:
return next((level for level, pattern in rules if pattern.search(folded)), "")
def from_title(title: str) -> str:
"""The highest level `title` names, one of `SENIORITIES`, or `''` when it
names none. See the module docstring for what counts."""
folded = " ".join(_NOISE.sub(" ", title_key(title)).split())
"""The level `title` names, one of `SENIORITIES`, or `''` when it names
none. See the module docstring for what counts."""
folded = " ".join(_NOISE.sub(" ", title_key(_OR.sub(" or ", title or ""))).split())
if not folded:
return ""
for level, patterns in _COMPILED:
if any(pattern.search(folded) for pattern in patterns):
return level
return ""
if _INTERN_RE.search(folded):
return "intern"
people, grade = _first(_PEOPLE_RE, folded), _first(_GRADES_RE, folded)
if not people:
return grade
if grade and LADDER[grade][0] > LADDER[people][0]:
return _LIFT[people]
return people