Merge the remote area: remote tokens, role_remote, remote_from, model wins for remote (wp-remote-a)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	app/models.py
This commit is contained in:
Wolf committed 2026-09-30 16:21:57 +02:00
commit e5572cab9d
21 files changed
+1250 -143

No files matched your search

+40 -7
View File
@@ -7,9 +7,11 @@ Sharing the backlog out a call at a time, the give-up count, splitting a
refused batch, and failing with a notice when no model is reachable are
`desk.modeltask`'s.
`extract` is also the afterburner for the level. A role is waiting while it is
open, has not been given up on, has never been answered (`extracted_at IS
NULL`) or has no model level (`seniority_model` empty), and is in the best of an enabled agent's
`extract` is also the afterburner for the level and the remote area. A role
is waiting while it is open, has not been given up on, has never been
answered (`extracted_at IS NULL`), has no model level (`seniority_model`
empty) or was never asked where a remote hire may live (`remote_where_model`
NULL), and is in the best of an enabled agent's
ungated scores as deep and as low as that agent's own `limits` say
(`extract_top`, `extract_min`). That bound is what keeps the cost
proportional to the rankings rather than to the boards:
@@ -20,7 +22,10 @@ fills columns that are still empty: a board's structured field wins over what
a model read out of the prose. The exception is the level, which the model
always gives (the board's word and the title's go in as hints) and which
overrules them; both stay in `seniority_stated` and `seniority_title`, so
`Store.seniority_agreement` can compare them. See `Store.set_extracted`.
`Store.seniority_agreement` can compare them. Remote is the other: the
model's `remote` and `remote_where` are kept as they come, and prep composes
the role's `remote` (the model's first) and its area from them
(`prep.run_roles`) before the rescore reads them. See `Store.set_extracted`.
Off by default (`extract.enabled: false`), because on the API backend every
batch is a paid call. Whether it runs is `stages.stage_on`: the switch under
@@ -39,6 +44,7 @@ from typing import Any
from desk import modeltask
from desk.modeltask import ModelTask
from pipeline import NULL, RunContext, Task, job
from app import prep
from app.config import Config
from app.jobs import stages
from app.models import LEVELS, PERMITS, REMOTE, SENIORITIES, ExtractResult, Role
@@ -72,6 +78,15 @@ Fields:
("Berlin", "Greater London"). '' if none is named.
- country: ISO 3166-1 alpha-2 code of that place ("DE", "GB"), or ''.
- remote: "remote", "hybrid" or "onsite" only when the posting says so, else ''.
"remote" when the hire works from home most of the time, even with a
regular office week (one week a month, a few days a quarter); "hybrid" when
there are set office days every week; "onsite" when the work is at the
office or the site.
- remote_where: where a remote hire may live, as the posting states it: the
countries, regions or continents by their English names (["Denmark"],
["Europe"], ["United States", "Canada"]), or ["anywhere"] for worldwide.
An office location is not this, only where the hire may work from. [] when
the role is not remote or the posting does not say.
- seniority: exactly one of {", ".join(LEVELS)}, for every posting; never ''.
This is the one field where you decide rather than extract. The levels are
one ladder; from staff up each rung has an individual-contributor level and
@@ -119,6 +134,7 @@ SCHEMA: dict[str, Any] = {
"place": _TEXT,
"country": _TEXT,
"remote": {"type": "string", "enum": list(REMOTE)},
"remote_where": {"type": "array", "items": _TEXT},
"seniority": {"type": "string", "enum": list(LEVELS)},
"salary_min": _SALARY,
"salary_max": _SALARY,
@@ -127,7 +143,7 @@ SCHEMA: dict[str, Any] = {
"permit": {"type": "string", "enum": list(PERMITS)},
"languages_required": {"type": "array", "items": _TEXT},
},
"required": ["uid", "place", "country", "remote", "seniority",
"required": ["uid", "place", "country", "remote", "remote_where", "seniority",
"salary_min", "salary_max", "currency", "function",
"permit", "languages_required"],
"additionalProperties": False,
@@ -186,15 +202,28 @@ def _salary(value: Any) -> int | None:
return int(value) if value > 0 else None
#: How many names `remote_where` keeps, and how long each may be.
_WHERE_NAMES, _WHERE_LEN = 12, 60
def _names(value: Any) -> list[str]:
"""`remote_where` checked: strings, whitespace collapsed, each once."""
found = [" ".join(str(name).split())[:_WHERE_LEN]
for name in (value if isinstance(value, list) else [])]
return list(dict.fromkeys(name for name in found if name))[:_WHERE_NAMES]
def fields(answer: dict[str, Any]) -> dict[str, Any]:
"""One answer, checked field by field. Anything outside a field's
vocabulary is '' or None, which `set_extracted` never writes."""
vocabulary is '' or None, which `set_extracted` never writes, except
for `remote` and `remote_where`, which it writes as they come."""
languages = [code for raw in answer.get("languages_required") or []
if (code := _code(raw, _LANGUAGE, upper=False))]
return {
"place": " ".join(str(answer.get("place") or "").split())[:200],
"country": _code(answer.get("country"), _COUNTRY, upper=True),
"remote": _pick(answer.get("remote"), REMOTE),
"remote_where": _names(answer.get("remote_where")),
"seniority": _pick(answer.get("seniority"), SENIORITIES),
"salary_min": _salary(answer.get("salary_min")),
"salary_max": _salary(answer.get("salary_max")),
@@ -211,8 +240,10 @@ def apply_batch(store: Store, answer: dict[str, Any],
"""Write the answers back. A uid the batch did not carry is rejected
rather than written, so a reply cannot reach a role it was not shown. A
role the reply leaves out keeps `extracted_at` NULL and is charged a
turn by `modeltask.one`."""
turn by `modeltask.one`. The roles answered are mapped again
(`prep.run_roles`), so their remote and area follow the model's."""
wanted = {row["uid"] for row in (batch or {}).get("roles", [])}
answered: list[str] = []
stats = ExtractResult()
for one in answer.get("roles") or []:
uid = str(one.get("uid") or "")
@@ -228,8 +259,10 @@ def apply_batch(store: Store, answer: dict[str, Any],
stats.rejected.append(uid)
continue
wanted.discard(uid)
answered.append(uid)
stats.extracted += 1
stats.filled += filled
prep.run_roles(store, answered)
return stats
+9 -5
View File
@@ -6,17 +6,19 @@ on. Computed once per pull (`plan`) and handed to each board's batch as the
- **Base reach**: the union of the enabled agents' `any` gates on country,
place (a town or region, mapped to its country through the gazetteer) and
remote. An agent whose `any` group is empty, or holds any other member (a
function, a remote value other than `remote`, a place the gazetteer does
not know), can take a role from anywhere, so the base reach is then
everywhere.
remote; a `remote_from` gate is remote. An agent whose `any` group is
empty, or holds any other member (a function, a remote value other than
`remote`, a place the gazetteer does not know), can take a role from
anywhere, so the base reach is then everywhere.
- **Wide reach, for the companies set to All countries**
(`companies.all_countries`, global): the union over the enabled agents of
their `require` reach, the intersection of each one's `require` gates on
country and place, Europe today, expanded to its countries through the
gazetteer, and the base reach, so the override never reads less than the
board would without it. An agent with no `require` gate on place makes it
everywhere. A role in Freiburg may be open to remote, or worth asking the
everywhere. A `require` gate on remote or `remote_from` next to one on
country adds nothing to it, so remote never widens it past the countries.
A role in Freiburg may be open to remote, or worth asking the
company about for Denmark. Favourite (affinity 2) is scoring only, where
it skips the `any` gates; it does not widen what is fetched.
- **Board override**: a board whose subscription `params` name a country, a
@@ -145,6 +147,8 @@ def gate_reach(gate: Gate, gaz: places.Gazetteer) -> Reach:
everywhere for a gate that says nothing of place or names one the
gazetteer does not know."""
values = [str(v).strip() for v in gate.values if str(v).strip()]
if gate.field == "remote_from":
return Reach(remote=True)
if gate.field == "remote":
return Reach(remote=True) if values and all(v.lower() == "remote" for v in values) \
else EVERYWHERE