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

+13 -3
View File
@@ -111,6 +111,12 @@ def same_posting(a: Copy, b: Copy) -> bool:
return not ta or not tb or bool(ta & tb)
def _same_country(a: Copy, b: Copy) -> bool:
"""Whether two rows can be in one country: equal, or either unknown."""
ca, cb = _country(a), _country(b)
return not ca or not cb or ca == cb
def keep_order(c: Copy) -> tuple[bool, bool, bool, str, str]:
"""The sort key that picks the kept copy of a group, smallest first: a
board over a search provider, then one with a description, then the
@@ -193,12 +199,16 @@ def fold(rows: Iterable[Copy]) -> Folded:
Within a `(company_key, title_key)` the kept rows of `assign` are grouped
again, in `keep_order`: a row joins the first group whose members are all
of its host, `similar` to it and remote as it is or not. Only a row with
of its host, in its country (equal, or either unknown, as `same_posting`
reads it), `similar` to it and remote as it is or not. Only a row with
a link can be folded, as its link is what the kept role keeps. Every row
of a merged group points at its first row, the rows that pointed at a
folded one included.
A remote listing and an office listing stay two roles: the kept role
One country, as ADR Fetch prep and score 1.4 has it: a job posted once
per office in several countries is several roles, one per country, which
keeps a different opening with an alike text (a federal sales role in
the US and one in Australia) from merging. A remote listing and an office listing stay two roles: the kept role
takes a copy's places and not its remote, so the fetch gate, which reads
a remote role by its area, would reject the remote listing with an
office role elsewhere, and the office one with a remote role elsewhere."""
@@ -216,7 +226,7 @@ def fold(rows: Iterable[Copy]) -> Folded:
for row in sorted(part, key=keep_order):
for group in groups:
if all(m.host == row.host and m.remote == row.remote
and similar(m.text, row.text) for m in group):
and _same_country(m, row) and similar(m.text, row.text) for m in group):
group.append(row)
break
else:
+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"