Merge the seniority ladder's levels: title rules, host tables, extract, migration 25 (wp-sen-a-levels)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	app/prep/hosts/jobylon.py
#	app/prep/hosts/recruitee.py
This commit is contained in:
Wolf committed 2026-09-30 13:14:45 +02:00
commit dd9e359609
16 files changed
+328 -138

No files matched your search

+22 -10
View File
@@ -72,16 +72,28 @@ Fields:
("Berlin", "Greater London"). '' if none is named.
- country: ISO 3166-1 alpha-2 code of that place ("DE", "GB"), or ''.
- remote: "remote", "hybrid" or "onsite" only when the posting says so, else ''.
- seniority: exactly one of {", ".join(s for s in SENIORITIES if s)}, for every
posting; never ''. This is the one field where you decide rather than
extract. Judge the level of the person hired from the title and the text (or
the short teaser when there is no text), weighing years of experience,
scope and who the role reports to. `stated` is the level the job board
itself gave and `title_level` the one a word in the title suggests. Both
are hints: boards use different vocabularies and many state nothing, so
overrule them when the posting says otherwise. When nothing says, choose the
likeliest level for that kind of title; most postings are for individual
contributors, not managers.
- seniority: exactly one of {", ".join(LEVELS)}, for every posting; never ''.
This is the one field where you decide rather than extract. The levels are
one ladder; from staff up each rung has an individual-contributor level and
a people-lead level of equal weight:
intern, junior, mid, senior: no track.
staff (Staff, Tech Lead, "Lead Engineer", "Marketing Lead") |
lead (Team Lead, Supervisor) or manager (manages a team).
principal (Principal, Senior Staff) |
senior_manager (Senior Manager, manages managers, Associate Director).
distinguished (Senior Principal, Distinguished, Technical Fellow) |
director (Director, Head of a function).
exec (VP, C-level, Managing Director).
Choose a people level only when the hire manages people; a Product,
Account or Project Manager is an individual contributor. Judge the level of
the person hired from the title and the text (or the short teaser when
there is no text), weighing years of experience, scope and who the role
reports to. `stated` is the level the job board itself gave and
`title_level` the one a word in the title suggests. Both are hints: boards
use different vocabularies and many state nothing, so overrule them when
the posting says otherwise. When nothing says, choose the likeliest level
for that kind of title; most postings are for individual contributors, not
managers.
- salary_min, salary_max: yearly gross amounts as integers, or null. A stated
monthly figure is multiplied by 12; an hourly or daily rate is null. A single
figure is both min and max.
+3 -2
View File
@@ -2,12 +2,13 @@
#: The embed's `experience`. Only the coarse levels are mapped; "Experienced"
#: sits between "Mid level" and the managerial levels and says too little to
#: place, so it maps to none.
#: place, so it maps to none. "Lead" is a senior individual ("Lead
#: Engineer"), `staff`, beside the managerial "Manager".
SENIORITY: dict[str, str] = {
"student": "intern", "internship": "intern", "trainee": "intern",
"entry level": "junior", "entry-level": "junior", "junior": "junior",
"graduate": "junior", "mid level": "mid", "mid-level": "mid", "mid": "mid",
"senior": "senior", "lead": "lead", "manager": "manager", "director": "director",
"senior": "senior", "lead": "staff", "manager": "manager", "director": "director",
"executive": "exec", "not applicable": "", "experienced": ""}
#: The embed's `employment_type`.
+4 -4
View File
@@ -1,10 +1,10 @@
"""Recruitee's words, for prep."""
#: `experience_code`. `experienced` names no level and is known, so it maps
#: to none.
SENIORITY = {"student_school": "intern", "student_college": "intern", "entry_level": "junior",
"mid_level": "mid", "experienced": "", "manager": "manager",
"senior_manager": "senior_manager", "executive": "exec"}
#: to none. A college student is an intern as a school one is.
SENIORITY = {"student_school": "intern", "student_college": "intern",
"entry_level": "junior", "mid_level": "mid", "experienced": "",
"manager": "manager", "senior_manager": "senior_manager", "executive": "exec"}
#: The words of `employment_type_code` (`fulltime_permanent`), which is
#: lowercased and split at "_" and "-"; the first entry found among its words
+1 -1
View File
@@ -31,7 +31,7 @@ from app.storage import Store
#: Raised when the rules in this package change the way a stored word maps,
#: so every open role is mapped again as it is after a table changes.
VERSION = 1
VERSION = 2
#: The state key the last run's `fingerprint` is kept under.
STATE = "prep:tables"
+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
+12
View File
@@ -611,6 +611,18 @@ ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
(24, "companies.all_countries takes over the All roles tag, and companies.all_roles "
"means no role narrowing; a board's {\"terms\": false} becomes its company's "
"all_roles", lambda conn: _split_all_roles(conn)),
# Seniority became a ladder of two tracks (models.LADDER): staff, lead,
# manager and director each split, so a model level in one of them is
# emptied for extract to read the role again. The level shown is then
# the first filled of the three, as Store.write_prep writes it; the
# title's is mapped again by the next prep (app.prep.stage.VERSION 2).
(25, "roles.seniority_model cleared where it is staff, lead, manager or director, "
"which the ladder splits; roles.seniority from the model, stated and title levels", """
UPDATE roles SET seniority_model = ''
WHERE seniority_model IN ('staff', 'lead', 'manager', 'director');
UPDATE roles SET seniority = COALESCE(NULLIF(seniority_model, ''),
NULLIF(seniority_stated, ''), seniority_title);
"""),
)
#: What a file created from `SCHEMA` today is already at.
+2 -2
View File
@@ -148,7 +148,7 @@ def test_migration_20_seeds_an_old_file_and_leaves_collisions(tmp_path: Path) ->
"VALUES (?, ?, '', '')", (key, name))
conn.execute("PRAGMA user_version = 19")
reopened = Store(path)
assert reopened.migrations_applied == [20, 21, 22, 23, 24]
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25]
assert reopened.duplicate_companies() == [("orsted", ["orsted", "ørsted"])]
assert len(reopened.companies()) == 3
@@ -186,7 +186,7 @@ def test_migration_21_tags_the_favourites_and_the_boards_that_read_all_roles(tmp
conn.execute("ALTER TABLE companies DROP COLUMN all_countries")
conn.execute("PRAGMA user_version = 20")
reopened = Store(path)
assert reopened.migrations_applied == [21, 22, 23, 24]
assert reopened.migrations_applied == [21, 22, 23, 24, 25]
# The tag of 21 is All countries and All roles since 24.
tagged = {"mistral-ai": 1, "acme": 0, "black-forest-labs": 1, "liked": 0}
assert {c.key: c.all_roles for c in reopened.companies()} == tagged
+1 -1
View File
@@ -246,7 +246,7 @@ def test_a_v17_file_gains_dup_of_with_its_first_rebuild(tmp_path: Path) -> None:
migrated = Store(path)
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24]
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25]
assert dup_of(migrated) == {first.uid: None, second.uid: first.uid}
with sqlite3.connect(path) as conn:
assert conn.execute("SELECT 1 FROM sqlite_master WHERE name = 'idx_roles_dup_of'"
+9 -1
View File
@@ -3,6 +3,7 @@ answer writes, and what it may not touch. Nothing here reaches a model."""
from __future__ import annotations
import re
from datetime import UTC, datetime
from pathlib import Path
from typing import Any
@@ -14,7 +15,7 @@ from desk.models import Item
from desk.tools import agent
from app.config import Config
from app.jobs import extract
from app.models import Limits
from app.models import LEVELS, Limits
from app.storage import Store
from prepped import upsert
@@ -263,6 +264,13 @@ def test_the_prompt_carries_the_hints_and_the_teaser_when_there_is_no_text(
assert "" not in schema["enum"], "the afterburner must pick a level"
def test_the_prompt_names_every_level_of_the_ladder() -> None:
schema = extract.SCHEMA["properties"]["roles"]["items"]["properties"]["seniority"]
assert schema["enum"] == list(LEVELS)
section = extract.SYSTEM.split("- seniority:")[1].split("- salary_min")[0]
assert all(re.search(rf"\b{level}\b", section) for level in LEVELS)
def test_an_answer_with_no_level_is_charged_until_given_up(
store: Store, config: Config, monkeypatch: pytest.MonkeyPatch) -> None:
item = posting("1")
+1 -1
View File
@@ -437,7 +437,7 @@ def test_migration_23_gives_every_agent_no_terms(tmp_path: Path) -> None:
conn.execute("ALTER TABLE agents DROP COLUMN fetch_terms")
conn.execute("PRAGMA user_version = 22")
migrated = Store(path)
assert migrated.migrations_applied == [23, 24]
assert migrated.migrations_applied == [23, 24, 25]
assert migrated.agents()[0].fetch_terms == []
+1 -1
View File
@@ -120,7 +120,7 @@ def test_migration_24_splits_the_tag_and_moves_terms_off(tmp_path: Path) -> None
conn.execute("UPDATE companies SET all_roles=1 WHERE key='mistral-ai'")
conn.execute("PRAGMA user_version = 23")
migrated = Store(path)
assert migrated.migrations_applied == [24]
assert migrated.migrations_applied == [24, 25]
flags = {c.key: (c.all_countries, c.all_roles) for c in migrated.companies()}
assert flags == {"mistral-ai": (1, 1), "acme": (0, 1), "plain": (0, 0)}
params = {s.target: s.params for s in migrated.subscriptions(source="ats")}
+1 -1
View File
@@ -314,7 +314,7 @@ def test_migration_22_fills_the_host_words_from_raw(tmp_path: Path) -> None:
migrated = Store(path)
assert migrated.migrations_applied == [22, 23, 24]
assert migrated.migrations_applied == [22, 23, 24, 25]
one = row(migrated, "1")
assert (one["seniority_host"], one["employment_host"], one["remote_host"],
one["country_host"]) == ("senior", "full_time", "true", "DK")
+1 -1
View File
@@ -27,7 +27,7 @@ def test_the_table_keys_are_lowercase_and_the_values_in_the_vocabulary(table: st
assert set(words.values()) <= {*VOCABULARY[table], ""}
@pytest.mark.parametrize(("word", "value"), [('mid level', 'mid'), ('student', 'intern'), ('entry level', 'junior'), ('executive', 'exec'), ('not applicable', '')])
@pytest.mark.parametrize(("word", "value"), [('mid level', 'mid'), ('student', 'intern'), ('entry level', 'junior'), ('executive', 'exec'), ('not applicable', ''), ('lead', 'staff'), ('manager', 'manager')])
def test_seniority_words(word: str, value: str) -> None:
assert hosts.SENIORITY[word] == value
+2
View File
@@ -18,6 +18,8 @@ def test_experience_codes_read() -> None:
assert [seniority[w] for w in ("student_school", "entry_level", "mid_level")] == [
"intern", "junior", "mid"]
assert seniority["experienced"] == ""
assert [seniority[w] for w in ("student_college", "manager", "senior_manager",
"executive")] == ["intern", "manager", "senior_manager", "exec"]
assert "senior_level" not in seniority
+67 -24
View File
@@ -42,9 +42,6 @@ TITLES: list[tuple[str, str]] = [
("Sr. Director, Enterprise Data", "director"),
("Director of Engineering (Data Infrastructure)", "director"),
("Director, Pricing", "director"),
("Associate Director, AI Strategy", "director"),
("Assoc Director, Oral Sema", "director"),
("Associate VP, Drug Product Manufacturing US Quality", "director"),
("Head of Data & AI Platforms", "director"),
("Head, Logistics Performance", "director"),
("Head ASP Management", "director"),
@@ -60,12 +57,19 @@ TITLES: list[tuple[str, str]] = [
# "Head Chef"-like titles and a duty that is only mentioned are not heads.
("Augenoptikermeister mit technischer Leitung (m/w/d) in Berlin WILMA", ""),
("Sous Chef", ""),
# ---- senior_manager
("Associate Director, AI Strategy", "senior_manager"),
("Assoc Director, Oral Sema", "senior_manager"),
("Associate Director/Director in Investment Banking - Infrastructure Leveraged Finance", "director"),
("Associate VP, Drug Product Manufacturing US Quality", "senior_manager"),
("Sr. Engineering Manager - Notebook Dataplane", "senior_manager"),
("Senior Engineering Manager - Enterprise Trust & Reliability", "senior_manager"),
("Senior Manager, Strategic Planning", "senior_manager"),
("Sr. Manager, Technical Delivery", "senior_manager"),
("Business Development Sr. Manager", "senior_manager"),
# ---- manager
("Engineering Manager - Security Engineering", "manager"),
("Sr. Engineering Manager - Notebook Dataplane", "manager"),
("Senior Manager, Strategic Planning", "manager"),
("Sr. Manager, Technical Delivery", "manager"),
("Business Development Sr. Manager", "manager"),
("Store Leader, Shopping Leblon", "manager"),
("Data Science Manager, Finance Analytics", "manager"),
("Manager, Bid Management", "manager"),
("Manager Sales Enablement", "manager"),
@@ -94,20 +98,25 @@ TITLES: list[tuple[str, str]] = [
("Office Manager - 9 month fixed term contract", ""),
("Sales Manager (m/w/d) – Photovoltaik, Wärmepumpe & intelligente Energiesysteme - 1KOMMA5° Kiel", ""),
("Technical Program Manager, Data Centers", ""),
("Lead Project Manager (German speaker)", "lead"),
("Assistant Store Manager (efood market) - Θεσσαλονίκη", "lead"),
("Lead Project Manager (German speaker)", "staff"),
("Responsable de projets - Expériences Fever Originals", ""),
("Chef de projet SEO et Marketing Digital H/F", ""),
("Bauleiter AC (m/w/d) für Photovoltaik - 1KOMMA5° Handwerk - Region Bayern", ""),
("Projektleder til produktion af færdigretter", ""),
("Prosjektleder DTO", ""),
("Technologie-Forschungsingenieur für Leistungshalbleiter (w/m/div.)", ""),
# ---- lead
("Tech Lead, Deployment & Operations — Custom Infrastructure", "lead"),
("Lead Data Engineer", "lead"),
("Lead Engineer", "lead"),
("Technical Lead- AI Cockpit", "lead"),
# ---- lead: a team lead
("Engineering Team Lead - GateManager Platform", "lead"),
("Team Lead - Technical Support", "lead"),
("Team Leader, Operations", "lead"),
("Delivery Station Supervisor", "lead"),
("Warehouse Lead", "lead"),
("[US-DC] Kitchen Lead", "lead"),
("Assistant Store Manager (efood market) - Θεσσαλονίκη", "lead"),
("Augenoptiker (m/w/d) als Assistant Store Manager in Dresden", "lead"),
("Associate Store Leader, Tyson's Corner", "lead"),
("People Leader - Model Design, LEGO® Design", "lead"),
("Chef d'Equipe Mecanique (H/F)", "lead"),
("Teamlead Winkel Schoten (36u)", "lead"),
("Complaints Team Leader - Claims", "lead"),
("Supervisor, Wind Site - Sunzia, NM", "lead"),
@@ -118,15 +127,29 @@ TITLES: list[tuple[str, str]] = [
("Chef d'équipe Entrepôt Magasin", "lead"),
("Chef·fe d’équipe - Modélisation (Unreal)", "lead"),
("Superviseur magasin", "lead"),
# "Lead" the noun is a level, "lead" the sales lead is not.
("B2B Demand Generation Specialist", ""),
# ---- staff
# ---- distinguished
("Senior Principal Engineer, Central Ops & Systems", "distinguished"),
("Principal/Senior Principal Investment Accounting Solution Consultant – IAS Value Team", "distinguished"),
("Distinguished Engineer, Core DevOps", "distinguished"),
("Business Process Chief Expert CIS", "distinguished"),
# "Fellow" alone is academic; the Technical Fellow's office is not the grade.
("Postdoctoral Fellow in Robotics and Computer Vision", ""),
("Principal Engineer, Enterprise AI — Technical Fellow Office", "principal"),
# ---- principal
("Senior Staff Software Engineer- Search Quality", "principal"),
("Senior Staff Applications Engineer", "principal"),
("Principal Software Engineer - Platform Engineering", "principal"),
("Principal Product Manager - Audio and Media Playback", "principal"),
# ---- staff: Staff, and "Lead" the noun that is not a team lead
("Staff Software Engineer - Money Movement", "staff"),
("Senior Staff Software Engineer- Search Quality", "staff"),
("Staff+ Software Engineer, Safeguards", "staff"),
("Principal Software Engineer - Platform Engineering", "staff"),
("Principal/Senior Principal Investment Accounting Solution Consultant – IAS Value Team", "staff"),
("Business Process Chief Expert CIS", "staff"),
("Tech Lead, Deployment & Operations — Custom Infrastructure", "staff"),
("Lead Data Engineer", "staff"),
("Lead Engineer", "staff"),
("Technical Lead- AI Cockpit", "staff"),
("Product Marketing Lead, Experience", "staff"),
("Payroll Lead", "staff"),
("Member of Technical Staff - Research Infrastructure Engineer", ""),
("Chief of Staff (m/w/d)", ""),
("Staff Accountant", ""),
@@ -213,6 +236,27 @@ SYNTHETIC: list[tuple[str, str]] = [
("Projectleider Logistiek", ""),
("Software Engineer III, Platform", "senior"),
("Manager, Data Science", "manager"),
# A grade on a people title lifts it one rung only when it is above the
# title's own rung.
("Staff Engineering Manager", "manager"),
("Principal Engineering Manager", "senior_manager"),
("Senior Staff Engineering Manager", "senior_manager"),
("Senior Principal Engineering Manager", "senior_manager"),
("Principal Team Lead", "senior_manager"),
("Staff Tech Lead Manager, Machine Learning, Vision Models", "manager"),
# A slash names two levels, the higher of which wins.
("Senior/Principal Unity Developer | New Games", "principal"),
("Senior/Staff Backend Engineer", "staff"),
("Lead/Principal Cloud Engineer – Data Platform", "principal"),
("Assistant Vice President, Credit Risk", "senior_manager"),
("AVP, Operations", "senior_manager"),
("Assistant Director of Finance", "senior_manager"),
("Research Fellow in Economics", ""),
("Fellow", ""),
("Technical Fellow", "distinguished"),
("Engineering Fellow, Silicon", "distinguished"),
("Shift Leader", "lead"),
("Supervisor", "lead"),
]
@@ -221,8 +265,6 @@ def test_title(title: str, level: str) -> None:
assert from_title(title) == level
@pytest.mark.xfail(strict=True, reason="WP A of docs/plan-seniority.md adds the title rules "
"for principal, senior_manager and distinguished, and drops this marker")
def test_table_covers_every_level_and_at_least_eighty_titles() -> None:
assert len(TITLES) >= 80
assert {level for _, level in TITLES} == set(SENIORITIES)
@@ -239,8 +281,9 @@ def test_gender_marker_and_case_do_not_matter() -> None:
def test_highest_level_named_wins() -> None:
assert from_title("Senior Director of Engineering") == "director"
assert from_title("Senior Lead Engineer") == "lead"
assert from_title("Junior Principal Engineer") == "staff"
assert from_title("Senior Lead Engineer") == "staff"
assert from_title("Junior Principal Engineer") == "principal"
assert from_title("Senior Director, Principal Engineering") == "director"
assert from_title("Vice President and Managing Director") == "exec"
+44 -9
View File
@@ -70,7 +70,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
"application_events", "agents", "scores", "state"} <= tables
assert "idx_roles_cluster" in indexes
assert store.migrations_applied == []
assert LATEST == 24
assert LATEST == 25
# A second open finds it current and applies nothing.
assert Store(path).migrations_applied == []
@@ -187,7 +187,7 @@ def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
migrated = Store(path)
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
acme = migrated.company("acme")
assert acme is not None
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
@@ -392,7 +392,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
migrated = Store(path)
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
Prompt(name="Backend", text="python backend")]
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
@@ -416,7 +416,7 @@ def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None
migrated = Store(path)
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24]
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
acme = migrated.company("acme")
assert acme is not None
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
@@ -445,7 +445,7 @@ def test_v17_folds_every_place_and_levels_the_titles_extract_has_not_read(
migrated = Store(path)
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24]
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25]
with sqlite3.connect(path) as conn:
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
"SELECT uid, place_fold, seniority FROM roles")}
@@ -681,13 +681,14 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
_undo_v19(conn)
# A role whose own page was read is pulled with an empty place in raw.
conn.execute("UPDATE roles SET raw = '{}' WHERE uid = ?", (detailed.uid,))
conn.execute("UPDATE roles SET extracted_at = '2026-09-23', seniority = 'staff' "
# A level 25 does not clear, so the split is what is checked here.
conn.execute("UPDATE roles SET extracted_at = '2026-09-23', seniority = 'mid' "
"WHERE uid = ?", (extracted.uid,))
conn.execute("PRAGMA user_version = 18")
migrated = Store(path)
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24]
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25]
assert [p.name for p in migrated.role_places(joined.uid)] == ["Copenhagen", "Malmö"]
assert [p.name for p in migrated.role_places(detailed.uid)] == ["Aarhus"]
assert migrated.role_places(stated.uid) == []
@@ -699,10 +700,44 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
joined.uid: ["senior", "", "", "senior", ""],
detailed.uid: ["senior", "", "", "senior", ""],
stated.uid: ["lead", "", "lead", "senior", ""],
extracted.uid: ["staff", "staff", "", "senior", ""],
extracted.uid: ["mid", "mid", "", "senior", ""],
}
def test_v25_clears_the_model_levels_the_ladder_splits_and_sets_the_level(
tmp_path: Path) -> None:
path = tmp_path / "v24.db"
store = Store(path)
# (model, stated, title) before 25, and what 25 leaves: the model level
# of the four split words is emptied, and the level is the first filled.
cases = {
"staff": (("staff", "", "senior"), ("", "", "senior", "senior")),
"lead": (("lead", "mid", "senior"), ("", "mid", "senior", "mid")),
"manager": (("manager", "", ""), ("", "", "", "")),
"director": (("director", "", "director"), ("", "", "director", "director")),
"senior": (("senior", "junior", "lead"), ("senior", "junior", "lead", "senior")),
"exec": (("exec", "", ""), ("exec", "", "", "exec")),
"none": (("", "", "lead"), ("", "", "lead", "lead")),
}
for sid in cases:
upsert(store, posting(sid))
with sqlite3.connect(path) as conn:
for sid, ((model, stated, title), _) in cases.items():
conn.execute("UPDATE roles SET seniority_model = ?, seniority_stated = ?, "
"seniority_title = ?, seniority = 'stale', extracted_at = '2026-09-23' "
"WHERE source_id = ?", (model, stated, title, sid))
conn.execute("PRAGMA user_version = 24")
migrated = Store(path)
assert migrated.migrations_applied == [25]
with sqlite3.connect(path) as conn:
found = {sid: rest for sid, *rest in conn.execute(
"SELECT source_id, seniority_model, seniority_stated, seniority_title, seniority "
"FROM roles")}
assert found == {sid: list(after) for sid, (_, after) in cases.items()}
def test_upsert_unpacks_raw_and_keeps_filled_columns(store: Store) -> None:
upsert(store, posting(place="Berlin", remote=True, salary_min="80000",
salary_max=95000, currency="EUR", department="Eng"))
@@ -1028,7 +1063,7 @@ def test_roles_filter_by_place_tokens_on_whole_words(store: Store) -> None:
def test_roles_filter_by_seniority_and_keep_the_unknown_unless_told(store: Store) -> None:
for sid, title in (("senior", "Senior Engineer"), ("junior", "Junior Engineer"),
("lead", "Tech Lead"), ("none", "Engineer")):
("lead", "Team Lead"), ("none", "Engineer")):
item = posting(sid)
item.title = title
upsert(store, item)