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:
1 parent
0c4f3c9bbe
commit
1976f6a353
4 files changed
+67
-14
No files matched your search
+13
-3
@@ -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
@@ -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"
|
||||
@@ -73,7 +73,7 @@ The gate rejects on evidence only. A role with an unknown location passes until
|
||||
- A company board with 300 or more roles is asked for the fetch gate at the host: the world and location gates, and the fetch terms, where the host can filter on them. A host that cannot filter on a part sends the board whole for that part.
|
||||
- A board's size is measured once, when it is added or rechecked, not on every read.
|
||||
- One fetch serves all enabled agents. The host is asked for, per agent, its location gate, or its world gate when it sets no location, united over the agents, and for the union of their fetch terms; one enabled agent without fetch terms means no terms. Each agent then applies its own gate to what arrived.
|
||||
- A host that filters on countries but not on remote is asked for the world gate's countries when an agent wants remote roles, so a remote role listed under any country in the world gate still arrives; the read says that remote was not asked.
|
||||
- A host that filters on countries but not on remote is asked for the world gate's countries when an agent wants remote roles, so a remote role listed under any country in the world gate still arrives; the read says that remote was not asked. This holds where the host takes the world in one read; on a host that takes one country a request, the world is the whole board, so the location gate is asked and remote roles elsewhere are not fetched.
|
||||
- A board's own saved params win over the agents' gates on the dimensions they set. With no enabled agent every board is read whole.
|
||||
|
||||
### 1.3 Closing
|
||||
|
||||
+14
-2
@@ -239,14 +239,26 @@ def test_folding_needs_the_same_title_a_link_and_texts_that_can_be_one_job() ->
|
||||
assert fold([pc("1", "Berlin", a), pc("2", "Munich", "")]).placed == {"2"}
|
||||
|
||||
|
||||
def test_the_per_place_fold_keeps_to_one_country() -> None:
|
||||
"""A federal sales role posted in Canberra and in Washington has alike
|
||||
text and is two openings; Berlin and Munich are one job in two offices.
|
||||
A row with no country joins either."""
|
||||
text = "Sell to federal agencies, run the public sector pipeline and partners."
|
||||
got = fold([replace(pc("au", "Canberra", text), country="AU"),
|
||||
replace(pc("us", "Washington", text), country="US"),
|
||||
pc("b", "Berlin", text), pc("m", "Munich", text),
|
||||
replace(pc("n", "", text), country="")])
|
||||
assert got.dup_of == {"au": None, "us": None, "b": None, "m": "b", "n": "au"}
|
||||
|
||||
|
||||
def test_a_remote_listing_is_not_folded_into_an_office_one() -> None:
|
||||
"""The kept role takes a copy's places, not its remote, so the gate would
|
||||
read "Remote, Germany" as an office role in Vienna and reject it for an
|
||||
agent that takes remote roles. Two remote listings still fold."""
|
||||
text = "We build the payment platform for our bank customers in Kotlin."
|
||||
office = replace(pc("v", "Vienna", text), country="AT")
|
||||
remote = replace(pc("r", "Remote, Germany", text), remote=True)
|
||||
other = replace(pc("s", "Remote, Spain", text), country="ES", remote=True)
|
||||
remote = replace(pc("r", "Remote, Berlin", text), remote=True)
|
||||
other = replace(pc("s", "Remote, Hamburg", text), remote=True)
|
||||
got = fold([office, remote, other])
|
||||
assert got.dup_of == {"v": None, "r": None, "s": "r"}
|
||||
assert got.placed == {"s"}
|
||||
|
||||
Reference in new issue
Block a user