Mark a role whose title or text says remote while no field does, in prep with no model, and let it meet a gate on remote until extract has read it (migration 35, roles.remote_text)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
f141cffc3c
commit
49929372c7
14 files changed
+144
-36
No files matched your search
@@ -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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
# 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
|
||||
|
||||
@@ -95,7 +95,7 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [28, 29, 30, 31, 32, 33, 34, 35]
|
||||
rows = {r["source_id"]: r for r in migrated._rows(
|
||||
"SELECT source_id, languages_required, deadline_host, deadline FROM roles")}
|
||||
assert (rows["a"]["deadline_host"], rows["a"]["deadline"]) == ("2026-10-18", None)
|
||||
@@ -106,7 +106,7 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
|
||||
assert migrated.role(posting("a").uid).deadline == "2026-10-18"
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 27")
|
||||
assert Store(path).migrations_applied == [28, 29, 30, 31, 32, 33, 34]
|
||||
assert Store(path).migrations_applied == [28, 29, 30, 31, 32, 33, 34, 35]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- deadline
|
||||
@@ -260,7 +260,7 @@ def test_v34_drops_the_must_haves_and_runs_twice(tmp_path: Path) -> None:
|
||||
|
||||
for _ in range(2): # runs twice without harm
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [34]
|
||||
assert migrated.migrations_applied == [34, 35]
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert "must_text" not in {r[1] for r in conn.execute("PRAGMA table_info(agents)")}
|
||||
assert not {"musts", "broken"} & {
|
||||
@@ -280,12 +280,12 @@ def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [30, 31, 32, 33, 34, 35]
|
||||
[data] = migrated.agents()
|
||||
assert (data.like_text, data.avoid_text) == ("", "Reporting.")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 29")
|
||||
assert Store(path).migrations_applied == [30, 31, 32, 33, 34]
|
||||
assert Store(path).migrations_applied == [30, 31, 32, 33, 34, 35]
|
||||
|
||||
|
||||
def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
|
||||
@@ -313,7 +313,7 @@ def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
|
||||
|
||||
for _ in range(2): # runs twice without harm
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [33, 34]
|
||||
assert migrated.migrations_applied == [33, 34, 35]
|
||||
assert migrated.judgement(old.id, item.uid) is None
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = conn.execute(
|
||||
|
||||
@@ -282,7 +282,7 @@ def test_migration_31_adds_the_column_and_the_table_and_runs_twice(tmp_path: Pat
|
||||
conn.execute("DROP TABLE agent_cv_vectors")
|
||||
conn.execute("ALTER TABLE scores DROP COLUMN cv_fit")
|
||||
conn.execute("PRAGMA user_version = 30")
|
||||
assert Store(path).migrations_applied == [31, 32, 33, 34]
|
||||
assert Store(path).migrations_applied == [31, 32, 33, 34, 35]
|
||||
step = {v: s for v, _, s in MIGRATIONS}[31]
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert callable(step)
|
||||
|
||||
@@ -281,7 +281,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
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'"
|
||||
|
||||
@@ -520,7 +520,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
assert migrated.agents()[0].fetch_terms == []
|
||||
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ def _read(store: Store, target: str) -> tuple[Ask, str]:
|
||||
|
||||
|
||||
@pytest.mark.parametrize("countries, roles, line", [
|
||||
(False, False, "follows agents: DK, SE · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(False, True, "follows agents: DK, SE · remote not asked on Phenom · all roles"),
|
||||
(False, False, "follows agents' world (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(False, True, "follows agents' world (Europe) · remote not asked on Phenom · all roles"),
|
||||
(True, False, "all locations (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(True, True, "all locations (Europe) · remote not asked on Phenom · all roles"),
|
||||
], ids=["neither", "all roles alone", "all locations alone", "both"])
|
||||
@@ -122,7 +122,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
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")}
|
||||
|
||||
+26
-2
@@ -224,7 +224,31 @@ def test_the_model_level_and_remote_win_over_the_host_and_the_place_line(
|
||||
("senior", "lead", "onsite")
|
||||
|
||||
|
||||
def test_the_company_resolves_through_its_aliases(store: Store) -> None:
|
||||
def test_remote_in_the_text_is_marked_and_a_denial_is_not() -> None:
|
||||
yes = ("Fully-remote within the EU, we meet twice a year.",
|
||||
"Work from home or from our Berlin office, as you like.",
|
||||
"Dette er en stilling med mulighed for fjernarbejde.")
|
||||
no = ("No remote work: this role is on site in Munich.",
|
||||
"Remote sensing analyst for our satellite team.",
|
||||
"A great office in Copenhagen with free lunch.")
|
||||
assert all(words.remote_in_text("Engineer", text) for text in yes)
|
||||
assert not any(words.remote_in_text("Engineer", text) for text in no)
|
||||
assert words.remote_in_text("Backend Developer, remote-first team", "")
|
||||
|
||||
|
||||
def test_prep_marks_a_role_whose_text_says_remote(store: Store) -> None:
|
||||
said = item("1", title="Engineer", place="Berlin")
|
||||
said.body = "Fully remote within Germany, with a Berlin office."
|
||||
silent = item("2", title="Engineer", place="Berlin")
|
||||
silent.body = "On site in Berlin."
|
||||
store.upsert_role(said)
|
||||
store.upsert_role(silent)
|
||||
prep.run(store, tables=TABLES)
|
||||
assert (row(store, "1")["remote"], row(store, "1")["remote_text"]) == ("", 1)
|
||||
assert (row(store, "2")["remote"], row(store, "2")["remote_text"]) == ("", 0)
|
||||
|
||||
|
||||
|
||||
store.add_company("Ørsted")
|
||||
store.upsert_role(item("1", company="ORSTED A/S"))
|
||||
assert row(store, "1")["company_key"] != "ørsted"
|
||||
@@ -316,7 +340,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
one = row(migrated, "1")
|
||||
assert (one["seniority_host"], one["employment_host"], one["remote_host"],
|
||||
one["country_host"]) == ("senior", "full_time", "true", "DK")
|
||||
|
||||
@@ -534,7 +534,7 @@ def test_migration_27_keeps_an_older_readers_remote_as_the_hosts_word(tmp_path:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
assert migrated.gazetteer().anywhere is not None
|
||||
row = migrated._row("SELECT remote_host, remote_model, remote_where_model FROM roles "
|
||||
"WHERE uid = ?", (board,))
|
||||
@@ -544,7 +544,7 @@ def test_migration_27_keeps_an_older_readers_remote_as_the_hosts_word(tmp_path:
|
||||
assert area(migrated, search.uid) == ("", "")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 26")
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
|
||||
|
||||
def test_a_role_waits_for_extract_until_it_was_asked_where(store: Store) -> None:
|
||||
|
||||
@@ -417,6 +417,30 @@ def test_a_region_that_holds_the_agents_places_is_no_evidence_against(
|
||||
assert oresund not in {r.uid for r in store.roles(places=["country:DK"])}
|
||||
|
||||
|
||||
def test_a_role_whose_text_says_remote_passes_a_gate_on_remote_until_extract_reads_it(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""Berlin is evidence against Denmark, but a text that says remote while
|
||||
no field does makes the role possibly remote (`remote_text`, prep): it
|
||||
meets the remote member. Once extract says onsite, it fails again."""
|
||||
said = role(store, "1", place="Berlin, Germany", remote="")
|
||||
silent = role(store, "2", place="Berlin, Germany", remote="")
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET remote_text = 1 WHERE uid = ?", (said,))
|
||||
agent = store.save_agent("DK or remote", "", [
|
||||
Gate(field="country", values=["DK"], mode="any"),
|
||||
Gate(field="remote", values=["remote"], mode="any")])
|
||||
|
||||
run(config, store, score.run_score)
|
||||
scores = store.scores(agent.id)
|
||||
assert scores[said][1] == ""
|
||||
assert scores[silent] == (0.0, "none of country DK, remote remote")
|
||||
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET remote = 'onsite' WHERE uid = ?", (said,))
|
||||
run(config, store, score.run_score)
|
||||
assert store.scores(agent.id)[said] == (0.0, "none of country DK, remote remote")
|
||||
|
||||
|
||||
def test_a_wider_place_beside_a_place_elsewhere_is_no_match(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""Europe alone is no evidence against Denmark; `London; Europe` is in
|
||||
|
||||
+12
-12
@@ -71,7 +71,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 == 34
|
||||
assert LATEST == 35
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -191,7 +191,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
|
||||
@@ -396,7 +396,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
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]
|
||||
@@ -420,7 +420,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
|
||||
@@ -449,7 +449,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, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
|
||||
"SELECT uid, place_fold, seniority FROM roles")}
|
||||
@@ -691,7 +691,7 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
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) == []
|
||||
@@ -733,7 +733,7 @@ def test_v25_clears_the_model_levels_the_ladder_splits_and_sets_the_level(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
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 "
|
||||
@@ -751,12 +751,12 @@ def test_v26_adds_posting_url_empty_and_runs_twice_without_harm(tmp_path: Path)
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
role = migrated.role(posting("a").uid)
|
||||
assert role is not None and role.posting_url == ""
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 25") # the column is there already
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33, 34]
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
||||
|
||||
|
||||
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
|
||||
@@ -1855,7 +1855,7 @@ def test_v32_resets_the_limits_drops_prefer_gates_and_renames_enrich(tmp_path: P
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [32, 33, 34]
|
||||
assert migrated.migrations_applied == [32, 33, 34, 35]
|
||||
by_name = {a.name: a for a in migrated.agents()}
|
||||
assert by_name["Wolf"].limits == Limits() == by_name["Bare"].limits
|
||||
assert [(g.field, g.mode) for g in by_name["Wolf"].gates] == [
|
||||
@@ -1880,14 +1880,14 @@ def test_v32_runs_twice_and_keeps_limits_set_since(tmp_path: Path) -> None:
|
||||
store = Store(path)
|
||||
agent = store.save_agent("Wolf", limits=Limits(cut_fit_top=900))
|
||||
_v31(path)
|
||||
assert Store(path).migrations_applied == [32, 33, 34]
|
||||
assert Store(path).migrations_applied == [32, 33, 34, 35]
|
||||
assert Store(path).agent(agent.id).limits == Limits() # type: ignore[union-attr]
|
||||
narrow = Limits(cut_fit_top=900, summarise_top=10)
|
||||
store.save_agent("Wolf", agent_id=agent.id, limits=narrow)
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 31") # the columns are there already
|
||||
again = Store(path)
|
||||
assert again.migrations_applied == [32, 33, 34]
|
||||
assert again.migrations_applied == [32, 33, 34, 35]
|
||||
assert again.agent(agent.id).limits == narrow # type: ignore[union-attr]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user