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

+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)