Bring the Python side to the ADR: the judge scores 0 to 10 with the cap at 4 and migration 33 clears every judgement, summarise reads the top 30 of the want and the match order, a hidden company's roles are never in the feed, and the company switch is called All locations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-10-04 21:40:32 +02:00
1 parent 6cad9713ac
commit 6d82287402
27 files changed
+390 -247

No files matched your search

+56 -28
View File
@@ -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 == 32
assert LATEST == 33
# 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]
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
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]
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
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]
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
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]
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
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]
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
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]
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32, 33]
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]
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33]
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]
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33]
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
@@ -1005,7 +1005,7 @@ def test_the_newest_feed_query_uses_the_partial_posted_at_index(
upsert(store, posting("1"))
sql, _ = store._roles_from(
company=None, place=None, open_only=True, q=None, function=None, remote=None,
days=None, hide_muted=False, include_read=True, tags=(), tag_mode="any",
days=None, include_read=True, tags=(), tag_mode="any",
agent=None, by_score=True, gated=False, judged=None)
assert "INDEXED BY" not in sql # the hint belongs to roles(), not the shared builder
@@ -1171,7 +1171,7 @@ def test_open_companies_and_places_are_what_the_rail_suggests_from(store: Store)
assert sorted(store.open_places()) == [("Gentofte", "DK", 2), ("Malmö", "SE", 2)]
def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock) -> None:
def test_roles_leave_out_a_hidden_company_before_the_limit(store: Store, clock: Clock) -> None:
agent = store.save_agent("A")
store.add_company("Acme", key="acme")
store.set_affinity(agent.id, "acme", -1)
@@ -1180,18 +1180,18 @@ def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock)
for i in range(3):
upsert(store, posting(f"a{i}", company="Acme"))
clock.tick()
# Acme's roles are the three newest, so a plain limit=1 shows only Acme;
# hide_muted has to reach past all three to find "other" rather than
# just dropping Acme's rows out of an already-limited page.
# Acme's roles are the three newest, so a plain limit=1 would show only
# Acme; leaving it out has to reach past all three to find "other"
# rather than just dropping Acme's rows out of an already-limited page.
listing = {"agent": agent.id, "by_score": False}
assert [r.source_id for r in store.roles(limit=1, **listing)] == ["a2"]
assert [r.source_id for r in store.roles(limit=1, hide_muted=True, **listing)] == ["other"]
assert {r.source_id for r in store.roles(hide_muted=True, **listing)} == {"other"}
assert {r.source_id for r in store.roles(**listing)} == {"a0", "a1", "a2", "other"}
assert [r.source_id for r in store.roles(limit=1, **listing)] == ["other"]
assert {r.source_id for r in store.roles(**listing)} == {"other"}
assert store.count_roles(**listing) == 1
assert sum(n for _, n in store.role_facets(**listing)["seniority"]) == 1
# Hidden is per agent: another agent, or no agent, hides nothing.
other = store.save_agent("B")
assert store.count_roles(hide_muted=True, agent=other.id, by_score=False) == 4
assert store.count_roles(hide_muted=True) == 4
assert store.count_roles(agent=other.id, by_score=False) == 4
assert store.count_roles() == 4
def test_roles_page_by_offset_and_count_the_same_filter(
@@ -1206,7 +1206,7 @@ def test_roles_page_by_offset_and_count_the_same_filter(
agent = store.save_agent("A")
store.add_company("Other", key="other")
store.set_affinity(agent.id, "other", -1)
assert store.count_roles(hide_muted=True, agent=agent.id, by_score=False) == 3
assert store.count_roles(agent=agent.id, by_score=False) == 3
def test_a_vote_is_stamped_cleared_and_filtered(store: Store, clock: Clock) -> None:
@@ -1383,21 +1383,20 @@ def test_roles_filters_by_tags_any_and_all(store: Store) -> None:
store.roles(tags=["python"], tag_mode="maybe")
def test_tag_counts_orders_by_count_then_tag_and_respects_muted(store: Store) -> None:
def test_tag_counts_orders_by_count_then_tag_and_leaves_out_hidden(store: Store) -> None:
store.add_company("Hidden", key="hidden")
agent = store.save_agent("A")
store.set_affinity(agent.id, "hidden", -1)
upsert(store, posting("1", company="Acme"))
upsert(store, posting("2", company="Acme"))
upsert(store, posting("3", company="Hidden"))
uid = {r.source_id: r.uid for r in store.roles(hide_muted=False)}
uid = {r.source_id: r.uid for r in store.roles()}
store.set_tags(uid["1"], ["python", "backend"])
store.set_tags(uid["2"], ["python"])
store.set_tags(uid["3"], ["python", "backend"])
store.set_read(uid["1"])
assert store.tag_counts(agent.id) == [("python", 2, 1), ("backend", 1, 0)]
assert store.tag_counts(agent.id, show_muted=True) == [("python", 3, 2), ("backend", 2, 1)]
assert store.tag_counts() == [("python", 3, 2), ("backend", 2, 1)] # no agent, nothing hidden
@@ -1774,11 +1773,40 @@ def test_summarise_waits_on_the_top_of_each_enabled_agent_by_its_own_limits(
assert [r.uid for r in store.summarise_waiting(10, uids=[d])] == [d]
store.save_agent("Two", "python backend", agent_id=two.id, limits=Limits(summarise_top=0))
assert {r.uid for r in store.summarise_waiting(10)} == {a}
# '{}' is the defaults, 50 deep.
# '{}' is the defaults, 30 deep.
with store.transaction() as conn:
conn.execute("UPDATE agents SET limits = '{}'")
assert {r.uid for r in store.summarise_waiting(10)} == {a, b, c}
assert store.agents()[0].limits == Limits()
assert Limits().summarise_top == 30
def test_summarise_waits_on_the_top_of_the_want_and_the_match_order(store: Store) -> None:
"""An agent with a CV adds the top of its match order to the top of its
want order: the judged roles by `cv_score`, then the rest by `cv_fit`,
as `order=cv` lists them. Without a prompt only the match top counts,
without a CV only the want top, which the vote moves as in the feed."""
for sid in "abcd":
upsert(store, posting(sid))
a, b, c, d = (posting(s).uid for s in "abcd")
both = store.save_agent("Both", "python backend", cv_text="Python engineer.",
limits=Limits(summarise_top=1))
store.replace_scores(both.id, [(a, 0.9, "", "", 0.1), (b, 0.5, "", "", 0.95),
(c, 0.4, "", "", 0.2), (d, 0.3, "remote", "", 0.99)])
assert {r.uid for r in store.summarise_waiting(10)} == {a, b}
# A judged role leads the match order whatever its closeness.
assert store.set_judgement(both.id, c, "key", 6, 6, 6, [], [])
assert {r.uid for r in store.summarise_waiting(10)} == {a, c}
store.save_agent("Both", agent_id=both.id, prompts=[], cv_text="Python engineer.",
limits=Limits(summarise_top=1))
assert {r.uid for r in store.summarise_waiting(10)} == {c}
store.save_agent("Both", "python backend", agent_id=both.id, cv_text="",
limits=Limits(summarise_top=1))
assert {r.uid for r in store.summarise_waiting(10)} == {a}
store.set_vote(both.id, a, -1) # 0.9 halved falls below b's 0.5
assert {r.uid for r in store.summarise_waiting(10)} == {b}
# ------------------------------------------------------------- migration 32
@@ -1827,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]
assert migrated.migrations_applied == [32, 33]
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] == [
@@ -1852,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]
assert Store(path).migrations_applied == [32, 33]
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]
assert again.migrations_applied == [32, 33]
assert again.agent(agent.id).limits == narrow # type: ignore[union-attr]