Ask a host that cannot filter on remote for the agents' world where it takes the world in one read, and keep the per-office fold within one country, as ADR 1.2 and 1.4 have it

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-10-06 13:56:01 +02:00
1 parent 0c4f3c9bbe
commit 1976f6a353
4 files changed
+67 -14

No files matched your search

+39 -8
View File
@@ -283,9 +283,18 @@ class Plan:
return self._big(sub)
def _big(self, sub: Subscription) -> tuple[Reach, str]:
"""The reach of `sub` as a board of `SMALL` roles or more."""
"""The reach of `sub` as a board of `SMALL` roles or more. A host
that cannot filter on remote while the agents want remote roles is
asked for the wide reach, the agents' world (ADR Fetch prep and
score 1.2): asked for "DK, SE" alone it would never list a remote
role filed under Germany, and the gate sorts the rest out. Only
where the host takes the world in one read, a list of countries or
their ids: on a host that takes one country a request, Europe is
the whole board, so the location read stays and remote is not asked."""
if company_key(sub.company or sub.label) in self.all_countries:
return self.wide, "countries"
if self.base.remote and not _filters_remote(sub) and _takes_world(sub, self.wide):
return self.wide, "world"
return self.base, "agents"
def narrows_roles(self, sub: Subscription) -> bool:
@@ -305,15 +314,34 @@ class Plan:
if why == "unknown":
found, why = self._big(sub)
out = found.params()
if self.terms and why in ("countries", "agents") and self.narrows_roles(sub):
if self.terms and why in ("countries", "agents", "world") and self.narrows_roles(sub):
out = (out or {}) | {"terms": list(self.terms)}
if why == "countries":
if why in ("countries", "world"):
out["wide"] = True
if sub.target not in self.sizes:
out = (out or {}) | {"unsized": True, "small": SMALL}
return out
def _filters_remote(sub: Subscription) -> bool:
"""Whether `sub`'s host declares a remote filter at all. A host that
declares one by ids may still lack the facet on a site, which the
runner finds out when it asks (`_runner.ask_for`)."""
module = readers.HOSTS.get(sub.target.partition(":")[0])
return module is None or module.READS.filters.remote != "none"
def _takes_world(sub: Subscription, wide: Reach) -> bool:
"""Whether `sub`'s host can be asked for the wide reach in one read: a
country filter that takes a list (`many`, `ids`), or one value a request
with the countries within `MAX_SERIES`; never everywhere."""
module = readers.HOSTS.get(sub.target.partition(":")[0])
if module is None or wide.everywhere or not wide.countries:
return False
reach = module.READS.filters.country
return reach in ("many", "ids") or (reach == "one" and len(wide.countries) <= _runner.MAX_SERIES)
def sizes(store: Store, subs: Iterable[Subscription]) -> dict[str, int]:
"""Each board's size as kept (`ats:size:<target>`); a board never sized
has none."""
@@ -381,7 +409,7 @@ def reaches(store: Store, subs: Iterable[Subscription]) -> Mapping[str, dict[str
#: Why a board is read whole, as the Companies list says it.
_WHOLE = {"small": f"under {SMALL} roles", "unknown": "size not known yet",
"override": "set here", "countries": "all locations (everywhere)",
"agents": "an agent takes any place"}
"world": "the agents' world (everywhere)", "agents": "an agent takes any place"}
def _codes(codes: Iterable[str]) -> list[str]:
@@ -486,6 +514,9 @@ def line(found: Plan, sub: Subscription) -> str:
if why == "countries":
named = found.wide_names or f"{len(found.wide.countries)} countries"
return f"all locations ({named}){unasked} · {roles}"
if why == "world":
named = found.wide_names or f"{len(found.wide.countries)} countries"
return f"follows agents' world ({named}){unasked} · {roles}"
if why == "override":
return f"set here: {_places(ask)}{unasked} · {roles}"
return f"follows agents: {_places(ask)}{unasked} · {roles}"
@@ -494,14 +525,14 @@ def line(found: Plan, sub: Subscription) -> str:
what = "all locations (everywhere)" if why == "countries" else _WHOLE[why]
return f"{what} · {roles}"
return f"all places, too many countries to ask · {roles}"
if why in ("agents", "countries") and given.everywhere:
if why in ("agents", "countries", "world") and given.everywhere:
return f"{_WHOLE[why]}: read whole"
if why in ("agents", "countries", "override") and not module.READS.filters.declared():
if why in ("agents", "countries", "world", "override") and not module.READS.filters.declared():
return f"{module.LABEL} cannot filter: read whole"
reads = module.READS.filters
if why in ("agents", "countries") and reads.country == "one" \
if why in ("agents", "countries", "world") and reads.country == "one" \
and len(given.countries) > _runner.MAX_SERIES:
return "too many countries to ask: read whole"
if why in ("agents", "countries"):
if why in ("agents", "countries", "world"):
return f"{module.LABEL} cannot ask for these: read whole"
return f"{_WHOLE[why]}: read whole"