Tag a company All roles to read its big boards with the agents' wide reach; favourite scores only

Migration 21 adds companies.all_roles, tags every favourite of any agent and each company whose board had params {"reach": "all"} (logged per board, the param removed). reach.plan reads a tagged company's boards with the union of the enabled agents' require reach and the base reach; favourite no longer widens the fetch. POST /api/companies/{key}/all-roles sets it and queues a pull when on. The Companies list, the reader and the company strip draw the toggle beside the affinity buttons, the list filters on it, and the board's reach editor drops its All roles option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 10:44:41 +02:00
1 parent 8d9a059e24
commit 5d5b7e7d3f
20 files changed
+422 -124

No files matched your search

+81 -14
View File
@@ -1,5 +1,5 @@
"""The reach of a pull (`app.jobs.reach`): from the enabled agents' gates and
favourites to each board's `reach`, and through the pull's batches to the
All roles tags to each board's `reach`, and through the pull's batches to the
runner's `Ask`. No network: the runner's listing is stubbed."""
from __future__ import annotations
@@ -107,31 +107,72 @@ def test_the_require_reach_intersects_and_expands_europe(store: Store) -> None:
# ------------------------------------------------------------- per board
def test_a_favourite_is_read_across_the_require_reach(store: Store) -> None:
def test_a_company_tagged_all_roles_is_read_across_the_require_reach(store: Store) -> None:
_wolf(store)
_board(store, "workday:mistral.wd3/Jobs", "Mistral AI")
_board(store, "workday:acme.wd3/Jobs", "Acme")
store.set_all_roles("mistral-ai", True)
plan = reach.plan(store)
subs = {s.target.split(".")[0]: s for s in store.subscriptions(source="ats")}
wide, why = plan.why(subs["workday:mistral"])
# Europe, and the base's remote, which a tag never reads less than.
assert why == "tag" and {"DE", "FR", "DK"} <= wide.countries and wide.remote
assert reach.line(plan, subs["workday:mistral"]) == \
f"{len(wide.countries)} countries, remote · company tag"
assert plan.why(subs["workday:acme"]) == (plan.base, "agents")
def test_a_favourite_does_not_widen_the_fetch(store: Store) -> None:
wolf = _wolf(store)
_board(store, "smartrecruiters:mistral", "Mistral AI")
_board(store, "smartrecruiters:acme", "Acme")
store.set_affinity(wolf, "mistral-ai", 2)
plan = reach.plan(store)
subs = {s.target: s for s in store.subscriptions(source="ats")}
favourite, why = plan.why(subs["smartrecruiters:mistral"])
assert why == "favourite" and {"DE", "FR", "DK"} <= favourite.countries
assert plan.why(subs["smartrecruiters:acme"]) == (plan.base, "agents")
[sub] = store.subscriptions(source="ats")
assert plan.why(sub) == (plan.base, "agents")
def test_a_company_starred_by_one_agent_keeps_the_others_reach(store: Store) -> None:
wolf = _wolf(store)
@pytest.mark.parametrize("host", ["smartrecruiters", "successfactors", "eightfold"])
def test_a_tag_too_wide_for_a_one_host_reads_the_board_whole(store: Store, host: str) -> None:
_wolf(store)
_board(store, f"{host}:mistral", "Mistral AI")
store.set_all_roles("mistral-ai", True)
[sub] = store.subscriptions(source="ats")
assert reach.line(reach.plan(store), sub) == \
"all roles · company tag, too many countries to ask"
def test_a_tag_asks_phenom_for_europe_in_one_request(store: Store) -> None:
_wolf(store)
_board(store, "phenom:mistral", "Mistral AI")
store.set_all_roles("mistral-ai", True)
[sub] = store.subscriptions(source="ats")
found = reach.plan(store)
assert reach.line(found, sub) == f"{len(found.wide.countries)} countries · company tag"
def test_an_agent_without_a_required_place_makes_the_tag_everywhere(store: Store) -> None:
_wolf(store)
store.save_agent("Anywhere", gates=[Gate(field="country", values=["US"], mode="any")])
_board(store, "smartrecruiters:mistral", "Mistral AI")
store.set_affinity(wolf, "mistral-ai", 2)
favourite = reach.plan(store).favourites["mistral-ai"]
assert "US" in favourite.countries and "FR" in favourite.countries
_board(store, "workday:mistral.wd3/Jobs", "Mistral AI")
store.set_all_roles("mistral-ai", True)
plan = reach.plan(store)
[sub] = store.subscriptions(source="ats")
assert plan.why(sub) == (reach.EVERYWHERE, "tag")
assert plan.for_subscription(sub) is None
assert reach.line(plan, sub) == "all roles · company tag"
def test_a_boards_own_reach_wins_over_the_tag(store: Store) -> None:
_wolf(store)
_board(store, "workday:mistral.wd3/Jobs", "Mistral AI", params={"countries": ["FR"]})
store.set_all_roles("mistral-ai", True)
[sub] = store.subscriptions(source="ats")
assert reach.line(reach.plan(store), sub) == "FR · set here"
@pytest.mark.parametrize("size, params, why", [
(299, {}, "small"),
(None, {}, "unknown"),
(5000, {"reach": "all"}, "override"),
(5000, {"countries": ["DE"]}, "override"),
(300, {}, "agents"),
])
@@ -202,6 +243,32 @@ def test_the_pull_hands_each_board_its_reach_and_the_runner_narrows_it(
assert store.state["ats:size:smartrecruiters:BoschGroup"] == "1000"
def test_the_pull_reads_a_tagged_company_with_the_wide_reach(
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
_wolf(store)
_board(store, "phenom:jobs.mistral.ai/global/en", "Mistral AI")
_board(store, "smartrecruiters:bfl", "Black Forest Labs")
store.set_all_roles("mistral-ai", True)
store.set_all_roles("black-forest-labs", True)
asked: dict[str, Ask] = {}
def fake(module: object, slug: str, get: object, ask: Ask, **kwargs: object
) -> _runner.Listing:
asked[slug] = ask
return _runner.Listing([_row("1")], True, ["1"], _runner.filtered(ask)) # type: ignore[list-item]
monkeypatch.setattr(_runner, "read_listing", fake)
[batch] = _pull(store)
phenom = "phenom:jobs.mistral.ai/global/en"
assert set(batch["reach"]) == {phenom, "smartrecruiters:bfl"}
europe = set(batch["reach"][phenom]["countries"])
assert {"DE", "FR", "DK"} <= europe
assert set(asked["jobs.mistral.ai/global/en"].countries) == europe
# Europe is more series than SmartRecruiters is asked one by one: whole.
assert asked["bfl"] == Ask()
assert not store.state.get("ats:filtered:smartrecruiters:bfl")
def test_a_batch_queued_before_the_reach_existed_still_runs(
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
_board(store, "smartrecruiters:acme", "Acme")