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:
WolfandClaude Fable 5.1 committed 2026-10-05 09:25:43 +02:00
1 parent 1127d06f03
commit 3388b97cf4
4 files changed
+150 -22

No files matched your search

+16 -6
View File
@@ -9,16 +9,19 @@ good for a given search. Each agent first applies its fetch gate:
lifts
any gates one group, the place part: a role that matches none of
them, and has the column filled for at least one, is
gated ("none of country DK / remote remote"); skipped for
a company set to All locations
gated ("none of country DK / remote remote"), unless its
location is unknown; skipped for a company set to All
locations
exclude gates a role that matches one of the values keeps its row, with
score 0 and the value ("title account executive"); those
on `title` are skipped for a company set to All roles
A gate rejects on evidence, never on absence: a role whose column is empty
is not gated by it. `extract` is what fills an empty column, and it reads
only the roles in the cut, so gating on an empty column would keep those
roles out of extract's reach for good. A hidden company (`affinity = -1`)
is not gated by it, and a place the gazetteer could not resolve, or one
that holds the agent's places (Øresund for Copenhagen), is no evidence.
`extract` is what fills an empty column, and it reads only the roles in
the cut, so gating on an empty column would keep those roles out of
extract's reach for good. A hidden company (`affinity = -1`)
is not scored at all; a favourite passes the gate like any other company.
The final score, the feed's order, is the weighted sum of four terms over
@@ -181,6 +184,10 @@ def failed_gates(candidate: Candidate, gates: Sequence[Gate]) -> list[str]:
it fails, every exclude gate it matches, and the `any` group when it
matches none of them. A gate with an empty column (state -1) neither
passes nor fails, so the group fails only when some member had evidence.
A role whose location is unknown, every `country` and `place` member
empty, passes the group whatever its remote says: a hybrid role with no
place may still be in one of the agent's towns, and extract reads it
only in the cut. A group of remote alone still fails a hybrid role.
A company set to All locations skips the `any` group, the place part,
and one set to All roles the exclude gates on `title`, the titles to
leave out; the require gates, the region, apply to every company."""
@@ -190,7 +197,10 @@ def failed_gates(candidate: Candidate, gates: Sequence[Gate]) -> list[str]:
if g.mode == "exclude" and state > 0
and not (candidate.all_roles and g.field == "title")]
group = [(g, state) for g, state in states if g.mode == "any"]
if not candidate.all_countries and group and not any(state == 1 for _, state in group) \
located = [state for g, state in group if g.field in ("country", "place")]
unknown = bool(located) and all(state == -1 for state in located)
if not candidate.all_countries and group and not unknown \
and not any(state == 1 for _, state in group) \
and any(state == 0 for _, state in group):
reasons.append("none of " + ", ".join(_wanted(g) for g, _ in group))
return reasons
+31 -12
View File
@@ -289,14 +289,22 @@ def _gate_sql(gate: Gate, gaz: places.Gazetteer) -> tuple[str, str, list[Any]]:
`params` belong to `match`; `empty` takes none.
`country` and `place` match over the gazetteer, as the feed's Place
filter does (`_places_sql`): a country gate is met by a role whose
`country` is one of its codes or that has a place in one of them, so
`DK` is met by `Copenhagen; London`. Its column is empty only when the
role has neither. A `require` gate on country reads a remote role whose
filter does (`_places_sql`), and also on a role place that holds one of
the gate's places (`wider`): a country gate is met by a role whose
`country` is one of its codes or that has a place in or around one of
them, so `DK` is met by `Copenhagen; London`, and by Øresund or Europe
alone, which are no evidence the role is outside Denmark; a town in
Germany is. Its column is empty only when the role has neither a country
nor a resolved place. A `require` gate on country reads a remote role whose
area is stated through the area alone, as the remote chips do
(`Gazetteer.overlap`): "Home Based - Worldwide" and "Germany (Remote)"
meet Europe, "Remote US" does not, and neither is empty. A place gate's
value is a place token, bare text a `place:`.
value is a place token, bare text a `place:`. Its column is empty when
the role has no place the gazetteer resolved, as "Storkøbenhavn" or
"Headquarters" are not: that is no evidence the role is elsewhere. Such
a role can still match, by its country or by whole words of its line
for a town the gazetteer does not know, so a place gate's `match` is
tested before its `empty` (`Store.score_candidates`).
`remote_from` takes place tokens without their `remote:` (`country:DK`,
`anywhere`) and matches as the remote chips do. It is empty for a role
@@ -314,7 +322,8 @@ def _gate_sql(gate: Gate, gaz: places.Gazetteer) -> tuple[str, str, list[Any]]:
return f"(r.remote = '' OR (r.remote = 'remote' AND NOT {_HAS_AREA}))", match, params
if gate.field == "country":
tokens = [f"country:{v}" for v in values]
match, params = _places_sql(tokens, gaz, table="r", codes=[v.upper() for v in values])
match, params = _places_sql(tokens, gaz, table="r", codes=[v.upper() for v in values],
wider=True)
empty = f"(r.country = '' AND {_unplaced(gaz)})"
if gate.mode != "require":
return empty, match, params
@@ -323,8 +332,8 @@ def _gate_sql(gate: Gate, gaz: places.Gazetteer) -> tuple[str, str, list[Any]]:
return (f"({empty} AND NOT {_HAS_AREA})",
f"(CASE WHEN {_HAS_AREA} THEN {area} ELSE {match} END)", [*more, *params])
if gate.field == "place":
match, params = _places_sql(values, gaz, table="r")
return "r.place = ''", match, params
match, params = _places_sql(values, gaz, table="r", wider=True)
return _unplaced(gaz), match, params
if gate.field == "title":
# Whole words of the folded title: " account executive " inside
# " enterprise account executive uk ". A fold drops `%` and `_`, so a
@@ -344,13 +353,19 @@ def _gate_sql(gate: Gate, gaz: places.Gazetteer) -> tuple[str, str, list[Any]]:
def _places_sql(tokens: Sequence[str], gaz: places.Gazetteer, *, table: str = "roles",
codes: Sequence[str] = (), scope: Sequence[Gate] = ()) -> tuple[str, list[Any]]:
codes: Sequence[str] = (), scope: Sequence[Gate] = (),
wider: bool = False) -> tuple[str, list[Any]]:
"""Any of the place tokens over `table`, as a join over the gazetteer: a
role with a place under one of the places the tokens name (`country:DK`
every place in Denmark, `region:skane` every town in Skåne, `place:malmo`
Malmö by any spelling), or whose `country` is one of their countries (a
role whose board gave a country and no place). `codes` are more values of
`country` to accept. A `place:` token the gazetteer does not know is
`country` to accept. `wider` also takes a role place that holds one of
them (`Gazetteer.overlap`): Øresund, Europe or Anywhere meet
`country:DK`, as the fetch gate reads them (`_gate_sql`); the feed's
Place filter leaves it off. The `country` column is not widened, as
Sweden would then meet Malmö for a role in Stockholm. A `place:` token
the gazetteer does not know is
matched on whole words of the role's folded line (`places.match_sql`),
so a town nobody has entered yet is still found.
@@ -381,7 +396,7 @@ def _places_sql(tokens: Sequence[str], gaz: places.Gazetteer, *, table: str = "r
params += values
continue
under = gaz.under(named)
ids |= under
ids |= gaz.overlap(named) if wider else under
found |= gaz.codes(under)
if ids:
clauses.insert(0, f"{table}.uid IN (SELECT uid FROM role_places "
@@ -2317,7 +2332,11 @@ class Store:
empty, match, values = _gate_sql(part, gaz)
whens.append(f"WHEN {match} THEN {k}")
params += values
columns.append(f"CASE WHEN {empty} THEN -1 {' '.join(whens)} ELSE 0 END AS g{n}")
# A place gate's match goes first: an unresolved place can still
# meet one of its values (`_gate_sql`).
case = (f"{' '.join(whens)} WHEN {empty} THEN -1" if gate.field == "place"
else f"WHEN {empty} THEN -1 {' '.join(whens)}")
columns.append(f"CASE {case} ELSE 0 END AS g{n}")
select = ", ".join(["r.uid", "r.posted_at",
"COALESCE(ac.affinity, 0) AS affinity",
"COALESCE(c.all_countries, 0) AS all_countries",