Merge branch 'main' into isolate-batches

This commit is contained in:
Wolf committed 2026-09-28 19:42:51 +02:00
commit 074a41c6cf
10 files changed
+143 -28

No files matched your search

+42 -2
View File
@@ -156,12 +156,52 @@ def test_a_require_gate_keeps_the_row_with_a_reason(
scores = store.scores(agent.id)
assert scores[berlin][1] == "" and scores[berlin][0] > 0
assert scores[munich] == (0.0, "place not Berlin")
assert scores[nowhere] == (0.0, "place unknown")
# An empty column is no evidence: the role ranks, and extract can reach it.
assert scores[nowhere][1] == "" and scores[nowhere][0] > 0
shown = store.roles(agent=agent.id)
assert [r.uid for r in shown] == [berlin]
assert {r.uid for r in shown} == {berlin, nowhere}
assert {r.uid for r in store.roles(agent=agent.id, gated=True)} == {berlin, munich, nowhere}
def test_any_gates_are_one_group_a_role_must_match_one_of(
store: Store, config: Config, fake: FakeEmbedder) -> None:
""""In Denmark, or remote": a role passes on either, is gated when it has
evidence against both, and ranks when both columns are empty."""
copenhagen = role(store, "1", place="Copenhagen, Denmark")
remote_de = role(store, "2", place="Berlin, Germany", remote="remote")
onsite_de = role(store, "3", place="Berlin, Germany", remote="onsite")
hybrid_nowhere = role(store, "4", place="Hybrid") # remote from place, no country
blank = role(store, "5")
agent = store.save_agent("Copenhagen 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[copenhagen][1] == "" and scores[remote_de][1] == ""
assert scores[onsite_de] == (0.0, "none of country DK, remote remote")
assert scores[blank][1] == ""
# "Hybrid" is a country-less line the remote lookup reads as hybrid, so
# the group has evidence against remote and none for country: gated.
assert scores[hybrid_nowhere][1].startswith("none of")
def test_failed_gates_reads_evidence_only() -> None:
gates = [Gate(field="country", values=["DK"]),
Gate(field="remote", values=["remote"], mode="any"),
Gate(field="seniority", values=["senior"], mode="any"),
Gate(field="function", values=["engineering"], mode="prefer")]
def cand(*states: int) -> Candidate:
return Candidate(uid="u", first_seen=NOW.isoformat(), affinity=0, gates=list(states))
assert score.failed_gates(cand(1, 1, 0, 0), gates) == []
assert score.failed_gates(cand(-1, -1, -1, 0), gates) == []
assert score.failed_gates(cand(0, 0, -1, 1), gates) == [
"country not DK", "none of remote remote, seniority senior"]
assert score.failed_gates(cand(1, 0, 0, 1), gates) == [
"none of remote remote, seniority senior"]
def test_a_prefer_gate_adds_its_weight_to_the_score(
store: Store, config: Config, fake: FakeEmbedder) -> None:
remote = role(store, "1", remote="remote")
+16 -1
View File
@@ -20,7 +20,7 @@ from plugins import search # noqa: E402
from plugins.search import SearchSource # noqa: E402
from app.config import SearchSeed # noqa: E402
from app.jobs import pull # noqa: E402
from app.models import country_of # noqa: E402
from app.models import country_of, remote_of # noqa: E402
from app.storage import Store # noqa: E402
FIXTURES = ROOT / "tests" / "fixtures" / "search"
@@ -53,6 +53,21 @@ def test_country_of(place: str, code: str) -> None:
assert country_of(place) == code
@pytest.mark.parametrize(("place", "mode"), [
("Remote", "remote"),
("Distributed", "remote"),
("Home based - Worldwide", "remote"),
("Remote - US", "remote"),
("Hybrid", "hybrid"),
("Remote or hybrid, Berlin", "hybrid"),
("In-Office", "onsite"),
("Berlin, Germany", ""),
("", ""),
])
def test_remote_of(place: str, mode: str) -> None:
assert remote_of(place) == mode
def test_upsert_fills_country_from_place_unless_the_plugin_says(store: Store) -> None:
def item(source_id: str, **raw: Any) -> Item:
it = Item(source_id=source_id, location="https://x.example/1", title="Engineer",