The location gate rejects on evidence only: a place gate is empty for a role with no place the gazetteer resolved, an any group whose country and place members are all empty passes whatever remote says, and a role place that holds one of a country or place gate's places (Øresund, Sweden, Europe) meets it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
1127d06f03
commit
3388b97cf4
4 files changed
+150
-22
No files matched your search
@@ -328,8 +328,9 @@ def test_a_place_gate_matches_over_the_gazetteer(store: Store,
|
||||
several: dict[str, str]) -> None:
|
||||
found = gates(store, Gate(field="place", values=["Malmö", "Lund", "oberkochen"],
|
||||
mode="any"))
|
||||
# "Remote (SE)" is placed at Sweden, which holds Malmö: no evidence against.
|
||||
assert {uid for uid, g in found.items() if g == 1} == {
|
||||
several["malmo"], several["lund"], several["zeiss"]}
|
||||
several["malmo"], several["lund"], several["zeiss"], several["remote"]}
|
||||
|
||||
|
||||
# ------------------------------------------------------------ unresolved texts
|
||||
|
||||
+101
-3
@@ -346,9 +346,89 @@ def test_any_gates_are_one_group_a_role_must_match_one_of(
|
||||
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")
|
||||
# "Hybrid" is a country-less line the remote lookup reads as hybrid: the
|
||||
# role may still be in Denmark, so it passes until extract reads it.
|
||||
assert scores[hybrid_nowhere][1] == ""
|
||||
|
||||
|
||||
def test_an_unknown_location_passes_the_any_group_whatever_its_remote(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""A place line the gazetteer cannot resolve is no evidence the role is
|
||||
elsewhere, for the country and for the place gate: the role passes,
|
||||
hybrid or not. One whose unknown line names a gate value by whole words
|
||||
matches it, and a role in a resolved place elsewhere is still gated, its
|
||||
remote unknown or not."""
|
||||
jobbank = role(store, "1", place="Storkøbenhavn; Udlandet (øvrige)", remote="hybrid")
|
||||
office = role(store, "2", place="Fleet Place Office", remote="onsite")
|
||||
avedore = role(store, "3", place="Avedøre Holme")
|
||||
berlin = role(store, "4", place="Berlin, Germany")
|
||||
berlin_hybrid = role(store, "5", place="Berlin, Germany", remote="hybrid")
|
||||
agent = store.save_agent("Malmö, Avedøre or remote", "", [
|
||||
Gate(field="country", values=["SE"], mode="any"),
|
||||
Gate(field="remote", values=["remote"], mode="any"),
|
||||
Gate(field="place", values=["Malmö", "Avedøre Holme"], mode="any")])
|
||||
|
||||
run(config, store, score.run_score)
|
||||
|
||||
states = {c.uid: c.gates for c in store.score_candidates(agent.id, agent.gates)}
|
||||
assert states[jobbank] == [-1, 0, -1] and states[office] == [-1, 0, -1]
|
||||
assert states[avedore] == [-1, -1, 1]
|
||||
assert states[berlin] == [0, -1, 0]
|
||||
scores = store.scores(agent.id)
|
||||
assert all(scores[uid][1] == "" for uid in (jobbank, office, avedore))
|
||||
reason = "none of country SE, remote remote, place Malmö / Avedøre Holme"
|
||||
assert scores[berlin] == (0.0, reason) and scores[berlin_hybrid] == (0.0, reason)
|
||||
|
||||
|
||||
def test_a_remote_only_group_still_gates_a_hybrid_role(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""With no country or place in the group, remote is the only evidence:
|
||||
a hybrid role is gated, one whose remote is unknown passes."""
|
||||
hybrid = role(store, "1", place="Headquarters", remote="hybrid")
|
||||
unknown = role(store, "2", place="Headquarters")
|
||||
agent = store.save_agent("Remote", "", [Gate(field="remote", values=["remote"], mode="any")])
|
||||
|
||||
run(config, store, score.run_score)
|
||||
|
||||
scores = store.scores(agent.id)
|
||||
assert scores[hybrid] == (0.0, "none of remote remote")
|
||||
assert scores[unknown][1] == ""
|
||||
|
||||
|
||||
def test_a_region_that_holds_the_agents_places_is_no_evidence_against(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""Øresund holds the Capital Region and Skåne, so a role placed only
|
||||
there meets a gate on Denmark and one on Copenhagen; Berlin meets
|
||||
neither. The feed's Place filter still reads only what lies under."""
|
||||
oresund = role(store, "1", place="Øresundsregionen", remote="onsite")
|
||||
berlin = role(store, "2", place="Berlin, Germany", remote="onsite")
|
||||
by_country = store.save_agent("Denmark", "", [
|
||||
Gate(field="country", values=["DK"], mode="any")])
|
||||
by_town = store.save_agent("Copenhagen", "", [
|
||||
Gate(field="place", values=["copenhagen"], mode="any")])
|
||||
world = store.save_agent("Denmark only", "", [Gate(field="country", values=["DK"])])
|
||||
|
||||
run(config, store, score.run_score)
|
||||
|
||||
for agent in (by_country, by_town, world):
|
||||
scores = store.scores(agent.id)
|
||||
assert scores[oresund][1] == ""
|
||||
assert scores[berlin][1] != ""
|
||||
assert oresund not in {r.uid for r in store.roles(places=["country:DK"])}
|
||||
|
||||
|
||||
def test_a_country_that_holds_the_agents_town_is_no_match_for_a_role_placed_elsewhere(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""Sweden holds Malmö, yet a role in Stockholm is evidence against it."""
|
||||
stockholm = role(store, "1", place="Stockholm, Sweden", remote="onsite")
|
||||
malmo = role(store, "2", place="Malmö, Sweden", remote="onsite")
|
||||
agent = store.save_agent("Malmö", "", [Gate(field="place", values=["Malmö"], mode="any")])
|
||||
|
||||
run(config, store, score.run_score)
|
||||
|
||||
scores = store.scores(agent.id)
|
||||
assert scores[stockholm] == (0.0, "none of place Malmö")
|
||||
assert scores[malmo][1] == ""
|
||||
|
||||
|
||||
def test_failed_gates_reads_evidence_only() -> None:
|
||||
@@ -365,6 +445,24 @@ def test_failed_gates_reads_evidence_only() -> None:
|
||||
"none of remote remote, seniority senior"]
|
||||
|
||||
|
||||
def test_an_any_group_with_every_place_member_empty_does_not_fail() -> None:
|
||||
"""Remote is no evidence against a role whose location is unknown; a
|
||||
known location elsewhere is, also with remote unknown."""
|
||||
gates = [Gate(field="country", values=["DK"], mode="any"),
|
||||
Gate(field="remote", values=["remote"], mode="any"),
|
||||
Gate(field="place", values=["Malmö"], mode="any")]
|
||||
def cand(*states: int) -> Candidate:
|
||||
return Candidate(uid="u", posted_at=NOW.isoformat(), gates=list(states))
|
||||
assert score.failed_gates(cand(-1, 0, -1), gates) == []
|
||||
assert score.failed_gates(cand(0, -1, -1), gates) == [
|
||||
"none of country DK, remote remote, place Malmö"]
|
||||
assert score.failed_gates(cand(-1, -1, 0), gates) == [
|
||||
"none of country DK, remote remote, place Malmö"]
|
||||
remote_only = [Gate(field="remote", values=["remote"], mode="any")]
|
||||
assert score.failed_gates(cand(0), remote_only) == ["none of remote remote"]
|
||||
assert score.failed_gates(cand(-1), remote_only) == []
|
||||
|
||||
|
||||
def test_a_gate_is_require_any_or_exclude_and_has_no_weight() -> None:
|
||||
"""Prefer gates left the agent: hybrid is a feed filter now."""
|
||||
with pytest.raises(ValidationError):
|
||||
|
||||
Reference in new issue
Block a user