Merge the ADR follow-up in Python: judge on 0 to 10, summarise the top of both orders, hidden companies never shown, All locations (wp-adr-py)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
1b5a38b61c
27 files changed
+390
-247
No files matched your search
+2
-2
@@ -55,8 +55,8 @@ class ExtractConfig(ModelTaskConfig):
|
||||
class SummariseConfig(ModelTaskConfig):
|
||||
"""About 60 words on a role, for the list and the read page. See
|
||||
app/jobs/summarise.py. Off by default like extract; on, a pull summarises
|
||||
the best `summarise_top` final scores of each enabled agent (its
|
||||
`limits`), so the cost is bounded whatever the backlog, and every role
|
||||
the top `summarise_top` (its `limits`) of each enabled agent's want order
|
||||
and of its match order, so the cost is bounded whatever the backlog, and every role
|
||||
that is saved or liked, whatever its rank. The read page's Summarise button asks for one
|
||||
role whether this is on or not."""
|
||||
|
||||
|
||||
+3
-2
@@ -22,8 +22,9 @@ it filled none, `step` passes over all three. Extract reads the cut; the
|
||||
score after it applies the fetch gate and the cut again with the columns
|
||||
extract filled, so a role can drop out or enter (one that enters is
|
||||
extracted on the next pull). Judge reads each agent's cut as recomputed,
|
||||
against its CV. Summarise runs last, on the top of each agent's feed by
|
||||
final score and the roles liked or saved: it is no part of any score.
|
||||
against its CV. Summarise runs last, on the top of each agent's feed in
|
||||
the want order and in the match order, and the roles liked or saved: it is
|
||||
no part of any score.
|
||||
|
||||
A batch that failed, or a stage somebody killed, does not stop the chain: the
|
||||
work comes round on the next pull, and a rescore of what did arrive is worth
|
||||
|
||||
+30
-21
@@ -2,15 +2,17 @@
|
||||
|
||||
A `ModelTask` beside `summarise`, after the `/rank` of
|
||||
github.com/MadsLorentzen/ai-job-search: the model reads a posting against a
|
||||
written profile and scores skills, experience and career 0 to 100, with one
|
||||
to three strengths and gaps. The total is `app.models.cv_score`, the three
|
||||
numbers under the agent's `cv_*` weights, worked out when a role is served and
|
||||
not stored, so the weights are no part of `input_key`; it is what the feed's
|
||||
CV match sorts by. The model also reports a verdict on each of the
|
||||
written profile and scores skills, experience and career 0 to 10, with one
|
||||
to three strengths and gaps. A model's rating is an estimate, so the scale is
|
||||
coarse. The total is `app.models.cv_score`, the three numbers under the
|
||||
agent's `cv_*` weights times 10, so 0 to 100, worked out when a role is served
|
||||
and not stored, so the weights are no part of `input_key`; it is what the
|
||||
feed's CV match sorts by. The model also reports a verdict on each of the
|
||||
agent's must-haves (one per line of its must text, numbered M1..Mn in the
|
||||
prompt); it does not apply them. The rule is code's: a "broken" one makes
|
||||
career count as at most `app.models.BROKEN_CAP`, when the role is served. Culture and location are left out: the first
|
||||
is guessed from ad text, the second is what the fetch gate does.
|
||||
career count as at most `app.models.BROKEN_CAP` (4), when the role is
|
||||
served. Culture and location are left out: the first is guessed from ad text,
|
||||
the second is what the fetch gate does.
|
||||
|
||||
The work is pairs, `(agent, role)`: an enabled agent with a CV and a prompt,
|
||||
and an open role in its cut (`scores.cut`, see `app.jobs.score`: the best by
|
||||
@@ -63,7 +65,8 @@ EXCERPT = 8000
|
||||
#: 2: the verdict on each numbered must-have (`musts`), the cap in code.
|
||||
#: 3: what the person likes (`like_text`) beside what they do not, and the
|
||||
#: career rubric reading both.
|
||||
FORMAT = 3
|
||||
#: 4: the three numbers 0 to 10 rather than 0 to 100.
|
||||
FORMAT = 4
|
||||
|
||||
#: How many strengths and gaps are kept, and how long each may be.
|
||||
MOST, LONGEST = 3, 300
|
||||
@@ -75,20 +78,20 @@ what they do not like (the work, the workplace, situations), and their
|
||||
must-haves and deal-breakers when they gave any. Each item is one posting with a key, its title, company, place
|
||||
and text. Answer one judgement per item.
|
||||
|
||||
Score three dimensions, each 0 to 100:
|
||||
- skills: 80-100 the core requirements are the person's primary skills; 60-79
|
||||
most requirements match, with 1-2 gaps that are learnable; 40-59 a partial
|
||||
match, significant upskilling needed; 0-39 a fundamental mismatch.
|
||||
Score three dimensions, each a whole number from 0 to 10:
|
||||
- skills: 8-10 the core requirements are the person's primary skills; 6-7
|
||||
most requirements match, with 1-2 gaps that are learnable; 4-5 a partial
|
||||
match, significant upskilling needed; 0-3 a fundamental mismatch.
|
||||
- experience: match on the function and nature of the work performed, not the
|
||||
literal job title, and on its level. 80-100 direct experience in the same
|
||||
domain and role type; 60-79 related, with transferable skills clear; 40-59
|
||||
adjacent, the person would need to make the case; 0-39 unrelated.
|
||||
literal job title, and on its level. 8-10 direct experience in the same
|
||||
domain and role type; 6-7 related, with transferable skills clear; 4-5
|
||||
adjacent, the person would need to make the case; 0-3 unrelated.
|
||||
- career: against what the person wants (the prompts), what they like and
|
||||
what they do not like. 80-100 strongly
|
||||
aligned with their direction, with clear growth; 60-79 a good role, partly
|
||||
aligned; 40-59 a decent job that does not build toward their goals; 0-39 a
|
||||
dead end or a step backwards. Judge whether the tasks and the setting would
|
||||
energise them, not only whether they could do them.
|
||||
what they do not like. 8-10 strongly aligned with their direction, with
|
||||
clear growth; 6-7 a good role, partly aligned; 4-5 a decent job that does
|
||||
not build toward their goals; 0-3 a dead end or a step backwards. Judge
|
||||
whether the tasks and the setting would energise them, not only whether
|
||||
they could do them.
|
||||
|
||||
Their must-haves and deal-breakers are numbered M1, M2 and so on. Give a
|
||||
verdict on every one of them, in `musts`, for each item:
|
||||
@@ -269,10 +272,16 @@ def build_batch(config: Config, store: Store, limit: int = 5,
|
||||
|
||||
# -------------------------------------------------------------------- answer
|
||||
|
||||
#: The top of the judge's scale.
|
||||
TOP = 10
|
||||
|
||||
|
||||
def _mark(value: Any) -> int | None:
|
||||
"""One of the three numbers, rounded and held to 0..`TOP`; None for
|
||||
anything not a number."""
|
||||
if isinstance(value, bool) or not isinstance(value, int | float):
|
||||
return None
|
||||
return max(0, min(100, round(value)))
|
||||
return max(0, min(TOP, round(value)))
|
||||
|
||||
|
||||
def _lines(value: Any) -> list[str]:
|
||||
|
||||
+9
-9
@@ -10,7 +10,7 @@ on. Computed once per pull (`plan`) and handed to each board's batch as the
|
||||
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**
|
||||
- **Wide reach, for the companies set to All locations**
|
||||
(`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
|
||||
@@ -272,7 +272,7 @@ class Plan:
|
||||
def why(self, sub: Subscription) -> tuple[Reach, str]:
|
||||
"""The reach `sub` is read with, and why: `override`, `small`,
|
||||
`unknown` (a board never read whole), `countries` (its company is
|
||||
set to All countries) or `agents`."""
|
||||
set to All locations) or `agents`."""
|
||||
if OVERRIDE_KEYS & set(sub.params or {}):
|
||||
return EVERYWHERE, "override"
|
||||
size = self.sizes.get(sub.target)
|
||||
@@ -296,7 +296,7 @@ class Plan:
|
||||
def for_subscription(self, sub: Subscription) -> dict[str, Any] | None:
|
||||
"""The `reach` a board's batch hands `ask_for`; None for none. With
|
||||
fetch terms, and unless its company is set to All roles, a big board
|
||||
carries them, and `wide` when its company is set to All countries, for
|
||||
carries them, and `wide` when its company is set to All locations, for
|
||||
`ask_for` to decide which side gives way over `MAX_SERIES` (see the
|
||||
module docstring). A board with no size carries
|
||||
`unsized` and `small`, and the reach of a big board unless its params
|
||||
@@ -360,7 +360,7 @@ def plan(store: Store, subs: Iterable[Subscription] | None = None) -> Plan:
|
||||
base = wide = EVERYWHERE
|
||||
subs = list(store.subscriptions(source="ats") if subs is None else subs)
|
||||
rows = store.companies()
|
||||
# All countries never reads less than the board would without it: the
|
||||
# All locations never reads less than the board would without it: the
|
||||
# base's remote, which a `require` of Europe does not name, is kept.
|
||||
return Plan(base, wide | base, sizes(store, subs),
|
||||
all_countries=frozenset(c.key for c in rows if c.all_countries),
|
||||
@@ -380,7 +380,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 countries (everywhere)",
|
||||
"override": "set here", "countries": "all locations (everywhere)",
|
||||
"agents": "an agent takes any place"}
|
||||
|
||||
|
||||
@@ -452,8 +452,8 @@ def line(found: Plan, sub: Subscription) -> str:
|
||||
"follows agents: DK, SE, remote · follows agents' terms: engineer,
|
||||
product", "follows agents: DK, SE, remote · all roles" (a company set to
|
||||
All roles, or a reader without a query, or terms over `MAX_SERIES`),
|
||||
"all countries (Europe) · follows agents' terms: engineer, product,
|
||||
data", "all countries (Europe) · all roles", "set here: DE · all roles",
|
||||
"all locations (Europe) · follows agents' terms: engineer, product,
|
||||
data", "all locations (Europe) · all roles", "set here: DE · all roles",
|
||||
"all places, too many countries to ask · follows agents' terms:
|
||||
engineer", or, for a board read whole, why: "under 300 roles: read
|
||||
whole", "Greenhouse cannot filter: read whole". A board with no size yet
|
||||
@@ -485,13 +485,13 @@ def line(found: Plan, sub: Subscription) -> str:
|
||||
else "")
|
||||
if why == "countries":
|
||||
named = found.wide_names or f"{len(found.wide.countries)} countries"
|
||||
return f"all countries ({named}){unasked} · {roles}"
|
||||
return f"all locations ({named}){unasked} · {roles}"
|
||||
if why == "override":
|
||||
return f"set here: {_places(ask)}{unasked} · {roles}"
|
||||
return f"follows agents: {_places(ask)}{unasked} · {roles}"
|
||||
if ask.terms:
|
||||
if given.everywhere:
|
||||
what = "all countries (everywhere)" if why == "countries" else _WHOLE[why]
|
||||
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:
|
||||
|
||||
+4
-4
@@ -10,7 +10,7 @@ good for a given search. Each agent first applies its fetch gate:
|
||||
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 countries
|
||||
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
|
||||
@@ -42,8 +42,8 @@ all there is, when it is gated as "no vector". An agent with no votes scores
|
||||
every role without `taste`; the direction is newsdesk's
|
||||
`centroid(liked) - centroid(disliked)`. An agent with no prompt that has
|
||||
text has no `fit` either, so nothing of it enters the cut by fit and its
|
||||
scores do not decide what summarise reads (`Store._summarise_top`); a run
|
||||
names such agents in one notice.
|
||||
want order does not decide what summarise reads (`Store._summarise_top`); a
|
||||
run names such agents in one notice.
|
||||
|
||||
Beside the score, `fit` is stored as it is, and for an agent with a CV,
|
||||
`cv_fit`: how close the role is to the CV, the best cosine between the role
|
||||
@@ -181,7 +181,7 @@ 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 company set to All countries skips the `any` group, the place part,
|
||||
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."""
|
||||
states = list(zip(gates, candidate.gates, strict=True))
|
||||
|
||||
@@ -7,8 +7,10 @@ answer), and running it is `desk.modeltask`'s.
|
||||
|
||||
A role is waiting while it has no summary, has some text, is open and no copy,
|
||||
and is either in the top of an enabled agent's feed, the best `summarise_top`
|
||||
final scores among the roles its fetch gate passes (its `limits`), or one the
|
||||
owner cares about whatever its rank: saved (it has an application, the star)
|
||||
(its `limits`, 30 by default) by the want feed score and the best
|
||||
`summarise_top` by the match order (CV match, then CV closeness) among the
|
||||
roles its fetch gate passes, so at most twice that many, or one the owner
|
||||
cares about whatever its rank: saved (it has an application, the star)
|
||||
or voted up by an enabled agent. Summarise is no part of any score and runs
|
||||
last in the pull, once the final scores are set. The limit keeps the cost
|
||||
flat: a pull summarises the roles somebody will look at, not the 30k that are
|
||||
|
||||
+24
-17
@@ -1008,11 +1008,12 @@ def language_flag(required: list[RoleLanguage],
|
||||
return "", ""
|
||||
|
||||
|
||||
#: What career counts as at most when a posting breaks one of the agent's
|
||||
#: must-haves: the top of the rubric's 0-39 band for a dead end. The model
|
||||
#: What career counts as at most, on the judge's 0 to 10, when a posting
|
||||
#: breaks one of the agent's must-haves: the foot of the rubric's 4-5 band,
|
||||
#: a decent job that does not build toward the person's goals. The model
|
||||
#: reports whether each must-have is met; this cap is applied in code, when a
|
||||
#: role is served (`cv_score`, `Store.judgement`, `store._cv_sql`).
|
||||
BROKEN_CAP = 39
|
||||
BROKEN_CAP = 4
|
||||
|
||||
#: A must-have's verdict, as the judge answers it.
|
||||
MUST_VERDICTS = ("met", "broken", "unclear")
|
||||
@@ -1040,17 +1041,18 @@ def capped_career(career: int, broken: int = 0) -> int:
|
||||
|
||||
def cv_score(skills: int, experience: int, career: int,
|
||||
weights: Weights | None = None, broken: int = 0) -> float | None:
|
||||
"""The one number of a CV match, 0 to 100: the three numbers of the
|
||||
judge averaged by the agent's `cv_skills`, `cv_experience` and
|
||||
`cv_career` weights (30, 25 and 30 by default), career as
|
||||
`capped_career` has it. None when all three weights are 0."""
|
||||
"""The one number of a CV match, 0 to 100 for sorting and display: the
|
||||
judge's three numbers, each 0 to 10, averaged by the agent's
|
||||
`cv_skills`, `cv_experience` and `cv_career` weights (30, 25 and 30 by
|
||||
default), career as `capped_career` has it, times 10. None when all
|
||||
three weights are 0."""
|
||||
w = weights or Weights()
|
||||
total = w.cv_skills + w.cv_experience + w.cv_career
|
||||
if not total:
|
||||
return None
|
||||
career = capped_career(career, broken)
|
||||
return round((w.cv_skills * skills + w.cv_experience * experience
|
||||
+ w.cv_career * career) / total, 1)
|
||||
return round(10 * (w.cv_skills * skills + w.cv_experience * experience
|
||||
+ w.cv_career * career) / total, 1)
|
||||
|
||||
|
||||
class Must(Model):
|
||||
@@ -1064,8 +1066,9 @@ class Must(Model):
|
||||
|
||||
class Judgement(Model):
|
||||
"""What `judge` read of one role for one agent (`role_judgements`): the
|
||||
three dimensions 0 to 100 as the model gave them, `cv_score`
|
||||
(`cv_score`) and 1 to 3 strengths and gaps grounded in the posting.
|
||||
three dimensions 0 to 10 as the model gave them, `cv_score`
|
||||
(`cv_score`, 0 to 100) and 1 to 3 strengths and gaps grounded in the
|
||||
posting.
|
||||
`musts` is the verdict on each must-have and `broken` how many are
|
||||
broken; any makes `career_capped` the lower of `career` and
|
||||
`BROKEN_CAP`. `cv_score` and `career_capped` are not read from the
|
||||
@@ -1387,7 +1390,8 @@ class Company(Model):
|
||||
#: not on that list.
|
||||
hand_reason: str = ""
|
||||
#: The two fetch overrides (`app/jobs/reach.py`), global rather than an
|
||||
#: agent's, since fetching is shared. `all_countries` 1: every big board
|
||||
#: agent's, since fetching is shared. `all_countries` 1 (All locations,
|
||||
#: as the switch is called; the column keeps its name): every big board
|
||||
#: of the company is read with the agents' wide reach, Europe today,
|
||||
#: rather than their places. `all_roles` 1: no role-type narrowing, no
|
||||
#: fetch terms today, on any of its boards.
|
||||
@@ -1459,7 +1463,7 @@ class Gate(Model):
|
||||
fails it (the row is kept with the reason); the `any` gates together are
|
||||
one group a role must match at least one of ("in Denmark, or remote");
|
||||
`exclude` gates a role that matches any of its values ("title account
|
||||
executive"). A company set to All countries skips the `any` group and one
|
||||
executive"). A company set to All locations skips the `any` group and one
|
||||
set to All roles skips the `exclude` gates on `title` (`score.failed_gates`).
|
||||
A gate rejects on evidence only: a role whose column is empty is not
|
||||
rejected, since `extract` fills the column later for the roles in the
|
||||
@@ -1497,14 +1501,16 @@ class Limits(Model):
|
||||
leaves out, then every role liked or saved. Both levels are calibrated
|
||||
(`score.scale`) with the company's affinity as a small bonus, so a
|
||||
minimum means the same in every run. For a broad agent the count stops a
|
||||
list, for a narrow one the minimum. Summarise reads the best
|
||||
`summarise_top` by final score, and every role liked or saved."""
|
||||
list, for a narrow one the minimum. Summarise reads the top
|
||||
`summarise_top` of the want feed score (the score order) and the top
|
||||
`summarise_top` of the match order (CV match, then CV closeness), so at
|
||||
most twice as many, and every role liked or saved."""
|
||||
|
||||
cut_fit_top: int = Field(500, ge=0)
|
||||
cut_fit_min: float = Field(0.6, ge=0, le=1)
|
||||
cut_cv_top: int = Field(150, ge=0)
|
||||
cut_cv_min: float = Field(0.6, ge=0, le=1)
|
||||
summarise_top: int = Field(50, ge=0)
|
||||
summarise_top: int = Field(30, ge=0)
|
||||
|
||||
|
||||
class Prompt(Model):
|
||||
@@ -1616,7 +1622,8 @@ class Candidate(Model):
|
||||
uid: str
|
||||
posted_at: str
|
||||
affinity: int = 0
|
||||
#: `companies.all_countries`: the `any` group (the place part) is skipped.
|
||||
#: `companies.all_countries`, All locations: the `any` group (the place
|
||||
#: part) is skipped.
|
||||
all_countries: bool = False
|
||||
#: `companies.all_roles`: the `exclude` gates on `title` are skipped.
|
||||
all_roles: bool = False
|
||||
|
||||
+29
-3
@@ -431,12 +431,14 @@ CREATE TABLE IF NOT EXISTS agent_cv_vectors (
|
||||
|
||||
-- One agent's judge reading of a role against its CV. Its own table, since
|
||||
-- replace_scores rewrites scores every run and a judgement outlives that
|
||||
-- and the role closing. skills, experience and career are 0 to 100,
|
||||
-- cv_score their weighted total, strengths and gaps JSON lists. input_key
|
||||
-- and the role closing. skills, experience and career are 0 to 10 (0 to
|
||||
-- 100 until migration 33), cv_score their weighted total times 10 at the
|
||||
-- default weights (not read: app.models.cv_score is worked out when a role
|
||||
-- is served), strengths and gaps JSON lists. input_key
|
||||
-- is a hash of the CV, prompts, avoid text and the role's text it read: a
|
||||
-- different one is read again. musts is a JSON list of {id, text, verdict},
|
||||
-- the model's verdict on each of the agent's must-haves (one per line of its
|
||||
-- must text), broken how many are "broken": career counts as at most 39 then
|
||||
-- must text), broken how many are "broken": career counts as at most 4 then
|
||||
-- (app.models.BROKEN_CAP), applied when the role is served. tries counts
|
||||
-- replies that left the role without one since; at 3 it is given up until the agent is saved again. A
|
||||
-- row with judged_at NULL holds only tries.
|
||||
@@ -758,6 +760,9 @@ UPDATE roles SET seniority = COALESCE(NULLIF(seniority_model, ''),
|
||||
(32, "the cut: scores.fit and scores.cut, agents' limits reset to the cut's defaults, "
|
||||
"prefer gates gone, saved_filters, and enrich renamed fetch text",
|
||||
lambda conn: _add_cut(conn)),
|
||||
# A Python step: JSON limits, and a count for the log.
|
||||
(33, "the judge on 0 to 10: every judgement cleared to be made again, and summarise_top "
|
||||
"50 becomes 30", lambda conn: _judge_out_of_ten(conn)),
|
||||
)
|
||||
|
||||
#: What a file created from `SCHEMA` today is already at.
|
||||
@@ -1191,6 +1196,27 @@ def _add_cut(conn: sqlite3.Connection) -> None:
|
||||
"dropped", reset, dropped)
|
||||
|
||||
|
||||
def _judge_out_of_ten(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 33's step. The judge scores 0 to 10 rather than 0 to 100
|
||||
(`judge.FORMAT` 4), so every judgement is cleared: its numbers, the
|
||||
verdicts, strengths and gaps, `input_key`, `judged_at` and `tries`, and no
|
||||
old number is shown on the new scale. The rows stay, as rows of no
|
||||
judgement, and the judge reads every pair again. An agent whose
|
||||
`summarise_top` is 50, migration 32's default, takes 30, the new one.
|
||||
Runs twice without harm."""
|
||||
cleared = conn.execute(
|
||||
"""UPDATE role_judgements
|
||||
SET skills = NULL, experience = NULL, career = NULL, cv_score = NULL,
|
||||
strengths = '[]', gaps = '[]', musts = '[]', broken = 0,
|
||||
input_key = '', tries = 0, judged_at = NULL""").rowcount
|
||||
lowered = conn.execute(
|
||||
"""UPDATE agents SET limits = json_set(limits, '$.summarise_top', 30)
|
||||
WHERE json_valid(limits) AND json_type(limits) = 'object'
|
||||
AND json_extract(limits, '$.summarise_top') = 50""").rowcount
|
||||
log.info("migration 33: %d judgements cleared for the 0 to 10 scale, %d agents' "
|
||||
"summarise_top 50 set to 30", cleared, lowered)
|
||||
|
||||
|
||||
def _add_all_roles(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 21's step. The column; the tag for every company that is a
|
||||
favourite of any agent, since favourite no longer widens what a pull
|
||||
|
||||
+75
-62
@@ -138,8 +138,9 @@ _WITH_JUDGEMENTS = ("LEFT JOIN role_judgements j ON j.uid = roles.uid AND j.agen
|
||||
|
||||
|
||||
def _cv_sql(weights: Weights | None) -> str:
|
||||
"""`cv_score` as SQL for one agent's weights, unrounded (`app.models.cv_score`
|
||||
rounds it): NULL for a role not judged, and for all three weights 0. Career
|
||||
"""`cv_score` as SQL for one agent's weights, 0 to 100 from the judge's
|
||||
three numbers 0 to 10, unrounded (`app.models.cv_score` rounds it): NULL
|
||||
for a role not judged, and for all three weights 0. Career
|
||||
counts as at most `BROKEN_CAP` when the judgement holds a broken
|
||||
must-have (`j.broken`), as `app.models.capped_career` has it. The
|
||||
numbers are the model's validated, finite floats, so they are written in
|
||||
@@ -150,7 +151,7 @@ def _cv_sql(weights: Weights | None) -> str:
|
||||
return "NULL"
|
||||
career = (f"(CASE WHEN j.broken > 0 AND j.career > {BROKEN_CAP} THEN {BROKEN_CAP} "
|
||||
"ELSE j.career END)")
|
||||
return (f"(({w.cv_skills!r} * j.skills + {w.cv_experience!r} * j.experience "
|
||||
return (f"(10.0 * ({w.cv_skills!r} * j.skills + {w.cv_experience!r} * j.experience "
|
||||
f"+ {w.cv_career!r} * {career}) / {total!r})")
|
||||
|
||||
|
||||
@@ -1134,7 +1135,7 @@ class Store:
|
||||
place: str | None = None, open_only: bool = True,
|
||||
q: str | None = None, function: str | None = None,
|
||||
remote: str | None = None, days: int | None = None,
|
||||
hide_muted: bool = False, include_read: bool = True,
|
||||
include_read: bool = True,
|
||||
tags: Sequence[str] = (), tag_mode: str = "any",
|
||||
agent: int | None = None, by_score: bool = True, gated: bool = False,
|
||||
fetch_gate: bool = False, judged: str | None = None, pay: str | None = None,
|
||||
@@ -1161,18 +1162,18 @@ class Store:
|
||||
|
||||
`agent` says whose votes, hidden companies and scores are meant. Each
|
||||
row carries that agent's `vote` and `voted_at`; `judged` (a key of
|
||||
`JUDGED`: liked, unjudged or passed) filters on them. `hide_muted`
|
||||
excludes the companies that agent hid, before `limit` is applied, in
|
||||
SQL rather than after the fact: a company that has published a lot,
|
||||
all at once — a fresh board added, a re-pull that finally reached
|
||||
it — can otherwise fill the whole page with roles that then all turn
|
||||
out to be from the one company someone hid, leaving nothing to show
|
||||
for a default query that would otherwise have plenty. With no agent
|
||||
`JUDGED`: liked, unjudged or passed) filters on them. The companies
|
||||
that agent hid are always left out, in every order and count: a
|
||||
hidden company's roles are never shown. That is done before `limit`,
|
||||
in SQL rather than after the fact: a company that has published a
|
||||
lot, all at once — a fresh board added, a re-pull that finally
|
||||
reached it — could otherwise fill the whole page with roles that then
|
||||
all turn out to be from the one company someone hid. With no agent
|
||||
every vote is None, nothing is hidden and `judged` reads as such.
|
||||
|
||||
`include_read` set False excludes a role `set_read` or `set_vote` has
|
||||
stamped, the same way and for the same reason as `hide_muted`:
|
||||
before `limit`, not after. `tags` keeps only roles carrying at least
|
||||
stamped, the same way and for the same reason as the hidden
|
||||
companies: before `limit`, not after. `tags` keeps only roles carrying at least
|
||||
one of them (`tag_mode="any"`, the default) or every one
|
||||
(`tag_mode="all"`), also before `limit`.
|
||||
|
||||
@@ -1201,7 +1202,7 @@ class Store:
|
||||
the whole page rather than one per role."""
|
||||
sql, params = self._roles_from(
|
||||
company=company, place=place, open_only=open_only, q=q, function=function,
|
||||
remote=remote, days=days, hide_muted=hide_muted, include_read=include_read,
|
||||
remote=remote, days=days, include_read=include_read,
|
||||
tags=tags, tag_mode=tag_mode, agent=agent, by_score=by_score, gated=gated,
|
||||
fetch_gate=fetch_gate,
|
||||
judged=judged, pay=pay, company_keys=company_keys, places=places,
|
||||
@@ -1253,7 +1254,7 @@ class Store:
|
||||
place: str | None = None, open_only: bool = True,
|
||||
q: str | None = None, function: str | None = None,
|
||||
remote: str | None = None, days: int | None = None,
|
||||
hide_muted: bool = False, include_read: bool = True,
|
||||
include_read: bool = True,
|
||||
tags: Sequence[str] = (), tag_mode: str = "any",
|
||||
agent: int | None = None, by_score: bool = True, gated: bool = False,
|
||||
fetch_gate: bool = False, judged: str | None = None, pay: str | None = None,
|
||||
@@ -1277,7 +1278,7 @@ class Store:
|
||||
column itself never crosses out of SQLite for a list."""
|
||||
sql, params = self._roles_from(
|
||||
company=company, place=place, open_only=open_only, q=q, function=function,
|
||||
remote=remote, days=days, hide_muted=hide_muted, include_read=include_read,
|
||||
remote=remote, days=days, include_read=include_read,
|
||||
tags=tags, tag_mode=tag_mode, agent=agent, by_score=by_score, gated=gated,
|
||||
fetch_gate=fetch_gate,
|
||||
judged=judged, pay=pay, company_keys=company_keys, places=places,
|
||||
@@ -1333,8 +1334,7 @@ class Store:
|
||||
def count_roles(self, company: str | None = None, place: str | None = None,
|
||||
open_only: bool = True, q: str | None = None,
|
||||
function: str | None = None, remote: str | None = None,
|
||||
days: int | None = None, hide_muted: bool = False,
|
||||
include_read: bool = True, tags: Sequence[str] = (),
|
||||
days: int | None = None, include_read: bool = True, tags: Sequence[str] = (),
|
||||
tag_mode: str = "any", agent: int | None = None, by_score: bool = True,
|
||||
gated: bool = False, fetch_gate: bool = False,
|
||||
judged: str | None = None,
|
||||
@@ -1345,7 +1345,7 @@ class Store:
|
||||
"""How many roles `roles` would list with the same filters and no limit."""
|
||||
sql, params = self._roles_from(
|
||||
company=company, place=place, open_only=open_only, q=q, function=function,
|
||||
remote=remote, days=days, hide_muted=hide_muted, include_read=include_read,
|
||||
remote=remote, days=days, include_read=include_read,
|
||||
tags=tags, tag_mode=tag_mode, agent=agent, by_score=by_score, gated=gated,
|
||||
fetch_gate=fetch_gate,
|
||||
judged=judged, pay=pay, company_keys=company_keys, places=places,
|
||||
@@ -1357,8 +1357,7 @@ class Store:
|
||||
def role_facets(self, company: str | None = None, place: str | None = None,
|
||||
open_only: bool = True, q: str | None = None,
|
||||
function: str | None = None, remote: str | None = None,
|
||||
days: int | None = None, hide_muted: bool = False,
|
||||
include_read: bool = True, tags: Sequence[str] = (),
|
||||
days: int | None = None, include_read: bool = True, tags: Sequence[str] = (),
|
||||
tag_mode: str = "any", agent: int | None = None, by_score: bool = True,
|
||||
gated: bool = False, fetch_gate: bool = False,
|
||||
judged: str | None = None,
|
||||
@@ -1375,7 +1374,7 @@ class Store:
|
||||
and then `""`, no pay stated. A value no role has counts 0."""
|
||||
shared: dict[str, Any] = {
|
||||
"company": company, "place": place, "open_only": open_only, "q": q,
|
||||
"function": function, "remote": remote, "days": days, "hide_muted": hide_muted,
|
||||
"function": function, "remote": remote, "days": days,
|
||||
"include_read": include_read, "tags": tags, "tag_mode": tag_mode, "agent": agent,
|
||||
"by_score": by_score, "gated": gated, "fetch_gate": fetch_gate, "judged": judged,
|
||||
"company_keys": company_keys, "places": places, "closing": closing}
|
||||
@@ -1394,7 +1393,7 @@ class Store:
|
||||
|
||||
def _roles_from(self, *, company: str | None, place: str | None, open_only: bool,
|
||||
q: str | None, function: str | None, remote: str | None,
|
||||
days: int | None, hide_muted: bool, include_read: bool,
|
||||
days: int | None, include_read: bool,
|
||||
tags: Sequence[str], tag_mode: str, agent: int | None,
|
||||
by_score: bool, gated: bool, judged: str | None,
|
||||
fetch_gate: bool = False,
|
||||
@@ -1408,7 +1407,7 @@ class Store:
|
||||
(see `_WITH_VOTES`) and its judgements as `j` (`_WITH_JUDGEMENTS`);
|
||||
its scores as `s` when ordering by them or with `fetch_gate`, and
|
||||
then a role the agent's fetch gate rejects is left out unless
|
||||
`gated`. A copy of another role
|
||||
`gated`. A company the agent hid is always left out. A copy of another role
|
||||
(`rebuild_dupes`) is never listed: its kept role stands for it and
|
||||
counts its copies. `closing` keeps the roles whose deadline is
|
||||
today or within `CLOSING_DAYS` after it."""
|
||||
@@ -1451,7 +1450,7 @@ class Store:
|
||||
params += list(seniority)
|
||||
if open_only:
|
||||
where.append("closed_at IS NULL")
|
||||
if hide_muted and agent is not None:
|
||||
if agent is not None:
|
||||
where.append("company_key NOT IN (SELECT company_key FROM agent_companies "
|
||||
"WHERE agent_id = ? AND affinity = -1)")
|
||||
params.append(agent)
|
||||
@@ -1498,15 +1497,14 @@ class Store:
|
||||
return [g for g in found.gates if g.field == "country" and g.mode == "require"] \
|
||||
if found is not None else []
|
||||
|
||||
def tag_counts(self, agent_id: int | None = None,
|
||||
show_muted: bool = False) -> list[tuple[str, int, int]]:
|
||||
def tag_counts(self, agent_id: int | None = None) -> list[tuple[str, int, int]]:
|
||||
"""`(tag, open_count, unread_count)` over open roles, most-used tag
|
||||
first and then alphabetically. What `/api/filters` serves; the
|
||||
companies `agent_id` hid are left out unless `show_muted`, the same
|
||||
default as `roles`, and with no agent nothing is hidden."""
|
||||
companies `agent_id` hid are left out, as in `roles`, and with no
|
||||
agent nothing is hidden."""
|
||||
where = "r.closed_at IS NULL AND r.dup_of IS NULL"
|
||||
params: list[Any] = []
|
||||
if not show_muted and agent_id is not None:
|
||||
if agent_id is not None:
|
||||
where += (" AND r.company_key NOT IN (SELECT company_key FROM agent_companies "
|
||||
"WHERE agent_id = ? AND affinity = -1)")
|
||||
params.append(agent_id)
|
||||
@@ -1664,29 +1662,43 @@ class Store:
|
||||
# -------------------------------------------------------------- extract
|
||||
|
||||
def _summarise_top(self) -> tuple[str, list[Any]]:
|
||||
"""The `WHERE` fragment for a role among the best `summarise_top`
|
||||
final scores of an enabled agent with a prompt, open, no copy and
|
||||
passing that agent's fetch gate: the top of its feed. The rank is
|
||||
numbered per agent and the agent's limits ride out of the window
|
||||
subquery beside it, so each row is held to the limit of the agent
|
||||
that ranked it; a key the JSON lacks is the `Limits` default. The
|
||||
role is `r`. An agent without a prompt with text counts for nothing
|
||||
here: its scores have no fit, so they say how fresh a role is, not
|
||||
whether it is wanted."""
|
||||
return ("""r.uid IN (SELECT uid FROM (
|
||||
SELECT s.uid, a.limits, ROW_NUMBER() OVER (
|
||||
PARTITION BY s.agent_id
|
||||
ORDER BY s.score DESC, top.posted_at DESC, s.uid) AS n
|
||||
FROM scores s
|
||||
JOIN agents a ON a.id = s.agent_id AND a.enabled = 1
|
||||
AND EXISTS (SELECT 1 FROM agent_prompts p
|
||||
WHERE p.agent_id = a.id
|
||||
AND TRIM(p.text, ' ' || char(9, 10, 13)) <> '')
|
||||
JOIN roles top ON top.uid = s.uid AND top.closed_at IS NULL
|
||||
AND top.dup_of IS NULL
|
||||
WHERE s.gated_reason = '')
|
||||
WHERE n <= COALESCE(json_extract(limits, '$.summarise_top'), ?))""",
|
||||
[Limits().summarise_top])
|
||||
"""The `WHERE` fragment for a role in the top of an enabled agent's
|
||||
feed in either order, open, no copy, passing that agent's fetch gate
|
||||
and not of a company it hid: the best `summarise_top` (its `limits`)
|
||||
by the want feed score, the score order of `roles` with the vote
|
||||
applied (`_VOTED_SCORE`), and the best `summarise_top` by the match
|
||||
order, `cv_score` under the agent's weights, then `cv_fit`, then
|
||||
score (`_by_cv`). So at most twice `summarise_top` per agent. An
|
||||
agent without a prompt with text gives only its match top (its
|
||||
scores have no fit, so they say how fresh a role is, not whether it
|
||||
is wanted), one without a CV only its want top. The role is `r`; no
|
||||
agent that counts is a fragment that holds for no role."""
|
||||
arms: list[str] = []
|
||||
params: list[Any] = []
|
||||
for agent in self.agents(enabled_only=True):
|
||||
top = agent.limits.summarise_top
|
||||
orders = []
|
||||
if any(p.text.strip() for p in agent.prompts):
|
||||
orders.append(f"{_VOTED_SCORE} DESC")
|
||||
if agent.cv_text.strip():
|
||||
orders.append(_by_cv(_cv_sql(agent.weights)) + f"{_VOTED_SCORE} DESC")
|
||||
for order in orders:
|
||||
arms.append(f"""SELECT uid FROM (
|
||||
SELECT s.uid FROM scores s
|
||||
JOIN roles top ON top.uid = s.uid AND top.closed_at IS NULL
|
||||
AND top.dup_of IS NULL
|
||||
LEFT JOIN role_votes v ON v.uid = s.uid AND v.agent_id = s.agent_id
|
||||
LEFT JOIN role_judgements j ON j.uid = s.uid AND j.agent_id = s.agent_id
|
||||
AND j.judged_at IS NOT NULL
|
||||
WHERE s.agent_id = ? AND s.gated_reason = ''
|
||||
AND top.company_key NOT IN (
|
||||
SELECT company_key FROM agent_companies
|
||||
WHERE agent_id = s.agent_id AND affinity = -1)
|
||||
ORDER BY {order}, top.posted_at DESC, s.uid LIMIT ?)""")
|
||||
params += [agent.id, top]
|
||||
if not arms:
|
||||
return "0", []
|
||||
return f"r.uid IN ({' UNION '.join(arms)})", params
|
||||
|
||||
def _extract_scope(self, uids: Sequence[str] | None) -> tuple[str, list[Any]]:
|
||||
"""The `WHERE` for a role `extract` may read: open, never answered,
|
||||
@@ -1845,9 +1857,9 @@ class Store:
|
||||
some text to summarise. Given `uids`, those of them and nothing else,
|
||||
open or not and given up or not, because somebody asked for them.
|
||||
Otherwise open, not given up, and in the top of an enabled agent's
|
||||
feed (`_summarise_top`) or one the owner cares about whatever its
|
||||
rank: saved (it has an application) or voted up by an enabled
|
||||
agent."""
|
||||
feed in either order (`_summarise_top`) or one the owner cares about
|
||||
whatever its rank: saved (it has an application) or voted up by an
|
||||
enabled agent."""
|
||||
where = ["r.summary = ''",
|
||||
"(TRIM(r.article_text) <> '' OR TRIM(r.description) <> '')"]
|
||||
if uids is not None:
|
||||
@@ -1875,9 +1887,10 @@ class Store:
|
||||
return int(row["n"]) if row else 0
|
||||
|
||||
def summarise_waiting(self, limit: int, uids: Sequence[str] | None = None) -> list[Role]:
|
||||
"""Roles `summarise` has yet to write, newest first: the best
|
||||
`summarise_top` final scores of every enabled agent, so the backlog
|
||||
is bounded by the agents rather than by the number of open roles,
|
||||
"""Roles `summarise` has yet to write, newest first: the top
|
||||
`summarise_top` of every enabled agent's want order and of its match
|
||||
order (`_summarise_top`), so the backlog is bounded by the agents
|
||||
rather than by the number of open roles,
|
||||
and every open role that is saved or voted up by an enabled agent,
|
||||
whatever its rank; given `uids`, those still without a summary,
|
||||
whatever their rank. A batch asks again when it runs."""
|
||||
@@ -2288,7 +2301,7 @@ class Store:
|
||||
def score_candidates(self, agent_id: int, gates: Sequence[Gate]) -> list[Candidate]:
|
||||
"""Every open role of a company this agent has not hidden, copies
|
||||
(`rebuild_dupes`) aside, with the agent's affinity for the company,
|
||||
the company's All countries and All roles, and how the role meets
|
||||
the company's All locations and All roles, and how the role meets
|
||||
each gate: 1 match, 0 no match, -1 the column is empty. The gates are
|
||||
evaluated here, in SQL, so a `require` gate is the `WHERE` it reads
|
||||
as, written as a column so a gated role keeps its row and reason."""
|
||||
@@ -2467,7 +2480,7 @@ class Store:
|
||||
return self._company(key)
|
||||
|
||||
def set_all_countries(self, key: str, on: bool) -> Company:
|
||||
"""Switch a company's All countries override: its big boards are read
|
||||
"""Switch a company's All locations override: its big boards are read
|
||||
with the agents' wide reach, Europe today, rather than their places,
|
||||
from the next pull (`app/jobs/reach.py`). Global, not per agent.
|
||||
Raises KeyError for an unknown company."""
|
||||
@@ -2536,7 +2549,7 @@ class Store:
|
||||
def merge_companies(self, keep: str, other: str) -> Company:
|
||||
"""Fold company `other` into `keep`, in one transaction: its roles and
|
||||
subscriptions move to `keep`, each agent's stance moves unless the
|
||||
agent has one on `keep` already, the All countries and All roles
|
||||
agent has one on `keep` already, the All locations and All roles
|
||||
overrides carry over, its aliases and its name become aliases of
|
||||
`keep`, and its row goes. Copies are not recomputed (`rebuild_dupes`).
|
||||
Raises KeyError for an unknown company and ValueError for merging one
|
||||
|
||||
+20
-18
@@ -70,7 +70,6 @@ def _feed_filters(
|
||||
function: str = "",
|
||||
remote: str = "",
|
||||
days: int | None = None,
|
||||
show_muted: bool = False,
|
||||
include_read: bool = True,
|
||||
tags: list[str] = Query(default=[]),
|
||||
tag_mode: Literal["any", "all"] = "any",
|
||||
@@ -96,7 +95,8 @@ def _feed_filters(
|
||||
them (`levels_between`), which is what the store filters on. `order=cv`
|
||||
is the score order with the agent's judged roles first by `cv_score`
|
||||
(`by_cv`). A request that names an agent keeps to its fetch gate in
|
||||
every order, newest included (`fetch_gate`), unless `gated`."""
|
||||
every order, newest included (`fetch_gate`), unless `gated`, and never
|
||||
shows a company the agent hid."""
|
||||
for token in tokens:
|
||||
if not places.known(token):
|
||||
raise HTTPException(422, f"No place is known as {token!r}.")
|
||||
@@ -115,7 +115,7 @@ def _feed_filters(
|
||||
return {
|
||||
"q": q or None, "company": company or None, "place": place or None,
|
||||
"function": function or None, "remote": remote or None, "days": days,
|
||||
"hide_muted": not show_muted, "include_read": include_read, "tags": tags,
|
||||
"include_read": include_read, "tags": tags,
|
||||
"tag_mode": tag_mode, "agent": _agent_id(store, agent),
|
||||
"by_score": agent is not None and order in ("score", "cv"),
|
||||
"by_cv": agent is not None and order == "cv", "gated": gated,
|
||||
@@ -155,7 +155,8 @@ def role_facets(store: StoreDep, filters: FeedFilters) -> Facets:
|
||||
def get_role(uid: str, store: StoreDep, agent: int | None = None) -> ScoredRole:
|
||||
"""One role, open or closed, for the read page, with `agent`'s vote and
|
||||
score, the prompt that gave its fit, its `judgement` against the agent's
|
||||
CV and the language flag (the default agent's when absent;
|
||||
CV (`skills`, `experience` and `career` 0 to 10, `cv_score` 0 to 100)
|
||||
and the language flag (the default agent's when absent;
|
||||
None when there is no agent). `copies` lists the open copies of a kept
|
||||
role (`RoleCopy`, for "Also posted"); a copy itself opens too, with
|
||||
`dup_of` naming its kept role."""
|
||||
@@ -235,9 +236,9 @@ def list_roles(
|
||||
`Store.roles` for what each filter does.
|
||||
|
||||
`agent` says whose votes, hidden companies and scores are meant. Each
|
||||
role carries that agent's `vote`; a company it hid is left out unless
|
||||
`show_muted` is set; `judged` keeps the liked, the unjudged or the
|
||||
passed. Every order keeps to the roles that agent's fetch gate passes,
|
||||
role carries that agent's `vote`; a company it hid is always left out,
|
||||
in every order, the total and the facets; `judged` keeps the liked, the
|
||||
unjudged or the passed. Every order keeps to the roles that agent's fetch gate passes,
|
||||
a gated one only with `gated=1`: with `order=score` (the default) best
|
||||
first by final score, carrying `score` and `gated_reason`; with
|
||||
`order=newest` newest first, carrying `gated_reason` and no score; with
|
||||
@@ -255,8 +256,8 @@ def list_roles(
|
||||
as well. `closing=1` keeps the roles whose `deadline` is today or in
|
||||
the next four days (Closing soon).
|
||||
|
||||
Each row carries `deadline`, the agent's `cv_score` (None when not
|
||||
judged), and `lang_flag` and `lang_note`, the posting's languages
|
||||
Each row carries `deadline`, the agent's `cv_score` (0 to 100, None
|
||||
when not judged), and `lang_flag` and `lang_note`, the posting's languages
|
||||
against the agent's (`app.models.language_flag`).
|
||||
|
||||
`company` and `place` are substrings, kept for links from other pages.
|
||||
@@ -290,14 +291,13 @@ class FiltersOut(BaseModel):
|
||||
|
||||
|
||||
@router.get("/filters")
|
||||
def list_filters(store: StoreDep, show_muted: bool = False,
|
||||
agent: int | None = None) -> FiltersOut:
|
||||
def list_filters(store: StoreDep, agent: int | None = None) -> FiltersOut:
|
||||
"""The tag vocabulary for the feed's filter row, most-used first. The
|
||||
companies `agent` hid (the default agent's without one) are left out
|
||||
unless `show_muted`, matching `/api/roles`."""
|
||||
companies `agent` hid (the default agent's without one) are left out,
|
||||
matching `/api/roles`."""
|
||||
hidden_for = _agent_id(store, agent)
|
||||
return FiltersOut(tags=[TagCount(tag=tag, count=count, unread=unread)
|
||||
for tag, count, unread in store.tag_counts(hidden_for, show_muted)])
|
||||
for tag, count, unread in store.tag_counts(hidden_for)])
|
||||
|
||||
|
||||
# ------------------------------------------------------------ suggestions
|
||||
@@ -506,9 +506,10 @@ class CompanyOut(BaseModel):
|
||||
`careers_opened_at` are the Watchlist's (`Company`'s), the latter also
|
||||
when a person last looked at the careers page. `by_hand` marks a company
|
||||
with no board shown that is not `from_search`, and `hand_reason` says why
|
||||
it is read by hand (`app.models.HAND_REASONS`). `all_countries` and
|
||||
`all_roles` are the company's two fetch overrides: its big boards read
|
||||
with the agents' wide reach, and with no role-type narrowing. `target` is
|
||||
it is read by hand (`app.models.HAND_REASONS`). `all_countries` (All
|
||||
locations) and `all_roles` (All roles) are the company's two fetch
|
||||
overrides: its big boards read with the agents' wide reach, and with no
|
||||
role-type narrowing. `target` is
|
||||
the attached board in full, `host:slug`, where `board` is its host alone;
|
||||
the page compares it with the board typed to know whether a replacement
|
||||
closes anything. `ats_slug` cannot stand in for it, since the careers site
|
||||
@@ -826,7 +827,8 @@ def _override(store: Store, queue: Any, key: str, on: bool, setter: str) -> Comp
|
||||
@router.post("/companies/{key}/all-countries")
|
||||
def set_all_countries(key: str, body: OverrideBody, store: StoreDep,
|
||||
queue: QueueDep) -> Company:
|
||||
"""All countries on or off: global, apart from affinity. On, the
|
||||
"""All locations on or off (the field and the path keep the name
|
||||
`all_countries`): global, apart from affinity. On, the
|
||||
company's roles skip the place part of every agent's fetch gate (the
|
||||
`any` gates, `jobs.score.failed_gates`), and its big boards are read
|
||||
with the agents' wide reach, Europe today, rather than their places
|
||||
|
||||
+14
-13
@@ -67,9 +67,10 @@ extract:
|
||||
|
||||
# About 60 words on a role: what it is, the stack, where, the pay if stated
|
||||
# (app/jobs/summarise.py). Off by default. On, each pull summarises the top
|
||||
# of every enabled agent's feed that has none yet, the best summarise_top by
|
||||
# final score (its limits), and every role liked or saved, so the cost stays
|
||||
# bounded however many roles are open. The Summarise button on
|
||||
# of every enabled agent's feed that has none yet, the best summarise_top (its
|
||||
# limits) by the want feed score and the best summarise_top by the match
|
||||
# order (CV match, then CV closeness), and every role liked or saved, so the
|
||||
# cost stays bounded however many roles are open. The Summarise button on
|
||||
# a role's page asks for that one role either way. `enabled` is only the
|
||||
# default for a fresh database: the switch under Settings, Sources, Runs (or
|
||||
# `app stages summarise on|off`) overrides it and needs no restart.
|
||||
@@ -83,8 +84,8 @@ summarise:
|
||||
# Only extract reads it.
|
||||
|
||||
# Each search agent's cut read against its CV: skills, experience and career 0
|
||||
# to 100, a total, and 1 to 3 strengths and gaps (app/jobs/judge.py), for the
|
||||
# CV match order on Roles. Off by default. On, each pull judges the cut of
|
||||
# to 10, a total 0 to 100, and 1 to 3 strengths and gaps (app/jobs/judge.py),
|
||||
# for the CV match order on Roles. Off by default. On, each pull judges the cut of
|
||||
# every enabled agent with a CV and a prompt, and only the roles not judged
|
||||
# yet or judged from another CV, prompt, like, avoid or must text, or role
|
||||
# text. The CV rides in every call, so batches are
|
||||
@@ -146,7 +147,7 @@ sources: {}
|
||||
# one of ("in Denmark, or remote"), the place part, and an exclude gate leaves
|
||||
# out the roles that match one of its values (title: the titles to leave
|
||||
# out). A gate rejects only a role whose column is filled, since extract fills
|
||||
# the rest for the roles in the cut. A company set to All countries skips the
|
||||
# the rest for the roles in the cut. A company set to All locations skips the
|
||||
# any group, one set to All roles the exclude gates on title. Fields are
|
||||
# place, country, remote, remote_from, seniority, function, salary_min,
|
||||
# currency, permit, languages, company and title. weights are the final
|
||||
@@ -159,12 +160,12 @@ sources: {}
|
||||
# best cut_cv_top by CV closeness at cut_cv_min or more that the first list
|
||||
# leaves out, then every role liked or saved. Both levels are calibrated, so
|
||||
# a minimum means the same in every run, and a liked company's roles sit
|
||||
# about 0.05 higher, a favourite's about 0.1. summarise_top is how many of
|
||||
# the best final scores summarise reads. The defaults are {cut_fit_top: 500,
|
||||
# cut_fit_min: 0.6, cut_cv_top: 150, cut_cv_min: 0.6, summarise_top: 50}. For
|
||||
# a broad agent the count stops a list, for a narrow one the minimum. An
|
||||
# agent without a prompt that has text has no fit, so nothing of it is in
|
||||
# the cut by fit.
|
||||
# about 0.05 higher, a favourite's about 0.1. summarise_top is how deep into
|
||||
# each order, want and match, summarise reads. The defaults are
|
||||
# {cut_fit_top: 500, cut_fit_min: 0.6, cut_cv_top: 150, cut_cv_min: 0.6,
|
||||
# summarise_top: 30}. For a broad agent the count stops a list, for a narrow
|
||||
# one the minimum. An agent without a prompt that has text has no fit, so
|
||||
# nothing of it is in the cut by fit.
|
||||
# prompts is a list of {name, text}, each what the agent looks for; a role's
|
||||
# fit is its best prompt's, so one agent can hunt several kinds of role
|
||||
# without blending them into one paragraph. Votes, gates and limits stay the
|
||||
@@ -191,7 +192,7 @@ agents: []
|
||||
# LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, SE, IS, LI, NO,
|
||||
# GB, CH, EU], mode: require}
|
||||
# limits: {cut_fit_top: 1000, cut_fit_min: 0.5, cut_cv_top: 150, cut_cv_min: 0.6,
|
||||
# summarise_top: 50}
|
||||
# summarise_top: 30}
|
||||
# - name: Europe hybrid
|
||||
# intent: >-
|
||||
# Senior backend or platform engineer in a European tech hub, hybrid or
|
||||
|
||||
@@ -397,7 +397,7 @@ def ask_for(module: ModuleType, subscription_params: Mapping[str, Any] | None =
|
||||
its reach (see `app/jobs/reach.py`), and a board whose params name a query
|
||||
of their own takes none. Terms times the reach's series (`_cost`) may cost
|
||||
at most `MAX_SERIES`. Over it, a wide read (`reach["wide"]`, a company set
|
||||
to All countries, or a reach this rule just dropped as too many
|
||||
to All locations, or a reach this rule just dropped as too many
|
||||
countries) drops the place part, whole, since remote without its
|
||||
countries would read only the remote roles, and keeps the terms. A narrow
|
||||
read keeps the places, which the agent's fetch gate needs, and drops the
|
||||
|
||||
@@ -148,7 +148,7 @@ def test_migration_20_seeds_an_old_file_and_leaves_collisions(tmp_path: Path) ->
|
||||
"VALUES (?, ?, '', '')", (key, name))
|
||||
conn.execute("PRAGMA user_version = 19")
|
||||
reopened = Store(path)
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert reopened.duplicate_companies() == [("orsted", ["orsted", "ørsted"])]
|
||||
assert len(reopened.companies()) == 3
|
||||
|
||||
@@ -186,7 +186,7 @@ def test_migration_21_tags_the_favourites_and_the_boards_that_read_all_roles(tmp
|
||||
conn.execute("ALTER TABLE companies DROP COLUMN all_countries")
|
||||
conn.execute("PRAGMA user_version = 20")
|
||||
reopened = Store(path)
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
# The tag of 21 is All countries and All roles since 24.
|
||||
tagged = {"mistral-ai": 1, "acme": 0, "black-forest-labs": 1, "liked": 0}
|
||||
assert {c.key: c.all_roles for c in reopened.companies()} == tagged
|
||||
|
||||
+17
-17
@@ -65,8 +65,8 @@ def setup(store: Store) -> tuple[Any, dict[str, str]]:
|
||||
uid[sid] = posting(sid).uid
|
||||
store.replace_scores(owner.id, [(uid["a"], 0.9, ""), (uid["b"], 0.8, ""),
|
||||
(uid["c"], 0.7, ""), (uid["d"], 0.6, "gated")])
|
||||
store.set_judgement(owner.id, uid["c"], "k", 90, 90, 90, ["Leads data."], ["Small team."])
|
||||
store.set_judgement(owner.id, uid["b"], "k", 60, 60, 60, ["Data."], ["Junior."])
|
||||
store.set_judgement(owner.id, uid["c"], "k", 9, 9, 9, ["Leads data."], ["Small team."])
|
||||
store.set_judgement(owner.id, uid["b"], "k", 6, 6, 6, ["Data."], ["Junior."])
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET languages_required = ? WHERE uid = ?", (json.dumps(
|
||||
[{"language": "sv", "level": "fluent", "kind": "required"}]), uid["a"]))
|
||||
@@ -94,22 +94,22 @@ def test_best_cv_match_puts_the_judged_first_by_cv_score(
|
||||
def test_a_broken_must_have_caps_career_in_the_order_and_the_reader(
|
||||
client: TestClient, store: Store) -> None:
|
||||
owner, uid = setup(store)
|
||||
# c: 90 on all three, but one must-have broken: career counts as 39.
|
||||
# c: 9 on all three, but one must-have broken: career counts as 4.
|
||||
musts = [{"id": "M1", "text": "Permanent", "verdict": "met"},
|
||||
{"id": "M2", "text": "Remote", "verdict": "broken"}]
|
||||
store.set_judgement(owner.id, uid["c"], "k", 90, 90, 90, [], [], musts)
|
||||
capped = round((30 * 90 + 25 * 90 + 30 * 39) / 85, 1)
|
||||
store.set_judgement(owner.id, uid["c"], "k", 9, 9, 9, [], [], musts)
|
||||
capped = round(10 * (30 * 9 + 25 * 9 + 30 * 4) / 85, 1)
|
||||
rows = client.get("/api/roles", params={"agent": owner.id, "order": "cv"}).json()["items"]
|
||||
assert [(r["uid"], r["cv_score"]) for r in rows[:2]] == [(uid["c"], capped), (uid["b"], 60.0)]
|
||||
# With career weighted up the capped value drops under b's 60.
|
||||
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id, cv_text=owner.cv_text,
|
||||
weights=Weights(cv_skills=0, cv_experience=0, cv_career=1))
|
||||
rows = client.get("/api/roles", params={"agent": owner.id, "order": "cv"}).json()["items"]
|
||||
assert [(r["uid"], r["cv_score"]) for r in rows[:2]] == [(uid["b"], 60.0), (uid["c"], 39.0)]
|
||||
assert [(r["uid"], r["cv_score"]) for r in rows[:2]] == [(uid["b"], 60.0), (uid["c"], 40.0)]
|
||||
one = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()
|
||||
j = one["judgement"]
|
||||
assert (j["career"], j["career_capped"], j["broken"]) == (90, 39, 1)
|
||||
assert j["musts"] == musts and one["cv_score"] == j["cv_score"] == 39.0
|
||||
assert (j["career"], j["career_capped"], j["broken"]) == (9, 4, 1)
|
||||
assert j["musts"] == musts and one["cv_score"] == j["cv_score"] == 40.0
|
||||
|
||||
|
||||
def test_a_met_or_unclear_must_have_leaves_career_as_the_model_gave_it(
|
||||
@@ -117,16 +117,16 @@ def test_a_met_or_unclear_must_have_leaves_career_as_the_model_gave_it(
|
||||
owner, uid = setup(store)
|
||||
musts = [{"id": "M1", "text": "Permanent", "verdict": "met"},
|
||||
{"id": "M2", "text": "Remote", "verdict": "unclear"}]
|
||||
store.set_judgement(owner.id, uid["c"], "k", 90, 90, 90, [], [], musts)
|
||||
store.set_judgement(owner.id, uid["c"], "k", 9, 9, 9, [], [], musts)
|
||||
j = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()["judgement"]
|
||||
assert (j["career"], j["career_capped"], j["broken"], j["cv_score"]) == (90, 90, 0, 90.0)
|
||||
assert (j["career"], j["career_capped"], j["broken"], j["cv_score"]) == (9, 9, 0, 90.0)
|
||||
|
||||
|
||||
def test_the_agents_weights_make_the_cv_score_at_read_time(
|
||||
client: TestClient, store: Store) -> None:
|
||||
owner, uid = setup(store)
|
||||
# c: skills 100, experience 0, career 0; b: 60 on all three.
|
||||
store.set_judgement(owner.id, uid["c"], "k", 100, 0, 0, ["Leads data."], ["Small team."])
|
||||
# c: skills 10, experience 0, career 0; b: 6 on all three.
|
||||
store.set_judgement(owner.id, uid["c"], "k", 10, 0, 0, ["Leads data."], ["Small team."])
|
||||
key_before = input_key(owner, "text")
|
||||
|
||||
def asked() -> tuple[list[tuple[str, float | None]], float | None]:
|
||||
@@ -150,7 +150,7 @@ def test_the_agents_weights_make_the_cv_score_at_read_time(
|
||||
assert [c for _, c in rows] == [None, None, None] and one is None
|
||||
assert [u for u, _ in rows] == [uid["a"], uid["b"], uid["c"]], "by score, as none is judged"
|
||||
assert client.get(f"/api/roles/{uid['c']}",
|
||||
params={"agent": owner.id}).json()["judgement"]["skills"] == 100
|
||||
params={"agent": owner.id}).json()["judgement"]["skills"] == 10
|
||||
refreshed = store.agent(owner.id)
|
||||
assert refreshed is not None and input_key(refreshed, "text") == key_before, \
|
||||
"the weights are no part of what the judge read"
|
||||
@@ -160,9 +160,9 @@ def test_the_weights_are_per_agent_json_with_the_old_values_as_default(store: St
|
||||
owner = store.save_agent("Data", prompts=[Prompt(name="Lead", text="Head of data")])
|
||||
assert (owner.weights.cv_skills, owner.weights.cv_experience,
|
||||
owner.weights.cv_career) == (30, 25, 30)
|
||||
assert cv_score(80, 60, 40, owner.weights) == round((2400 + 1500 + 1200) / 85, 1)
|
||||
assert cv_score(80, 60, 40, Weights(cv_skills=0, cv_experience=1, cv_career=1)) == 50.0
|
||||
assert cv_score(80, 60, 40, Weights(cv_skills=0, cv_experience=0, cv_career=0)) is None
|
||||
assert cv_score(8, 6, 4, owner.weights) == round(10 * (240 + 150 + 120) / 85, 1)
|
||||
assert cv_score(8, 6, 4, Weights(cv_skills=0, cv_experience=1, cv_career=1)) == 50.0
|
||||
assert cv_score(8, 6, 4, Weights(cv_skills=0, cv_experience=0, cv_career=0)) is None
|
||||
|
||||
|
||||
def test_a_row_carries_the_deadline_and_the_language_flag(
|
||||
@@ -199,7 +199,7 @@ def test_the_role_carries_its_judgement_and_languages(
|
||||
owner, uid = setup(store)
|
||||
role = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()
|
||||
judgement = role["judgement"]
|
||||
assert (judgement["skills"], judgement["cv_score"]) == (90, 90.0)
|
||||
assert (judgement["skills"], judgement["cv_score"]) == (9, 90.0)
|
||||
assert judgement["strengths"] == ["Leads data."] and judgement["gaps"] == ["Small team."]
|
||||
assert judgement["judged_at"]
|
||||
assert role["cv_score"] == 90.0 and role["lang_flag"] == "plus"
|
||||
|
||||
+51
-9
@@ -75,7 +75,7 @@ def test_new_agents_have_the_cut_by_default(store: Store) -> None:
|
||||
made = store.save_agent("Data")
|
||||
assert made.limits.model_dump() == {"cut_fit_top": 500, "cut_fit_min": 0.6,
|
||||
"cut_cv_top": 150, "cut_cv_min": 0.6,
|
||||
"summarise_top": 50}
|
||||
"summarise_top": 30}
|
||||
|
||||
|
||||
# --------------------------------------------------------------- migration
|
||||
@@ -98,7 +98,7 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [28, 29, 30, 31, 32, 33]
|
||||
rows = {r["source_id"]: r for r in migrated._rows(
|
||||
"SELECT source_id, languages_required, deadline_host, deadline FROM roles")}
|
||||
assert (rows["a"]["deadline_host"], rows["a"]["deadline"]) == ("2026-10-18", None)
|
||||
@@ -110,7 +110,7 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
|
||||
assert migrated.role(posting("a").uid).deadline == "2026-10-18"
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 27")
|
||||
assert Store(path).migrations_applied == [28, 29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [28, 29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- deadline
|
||||
@@ -229,8 +229,9 @@ def test_the_language_flag() -> None:
|
||||
|
||||
|
||||
def test_the_cv_score_weighs_skills_and_career_above_experience() -> None:
|
||||
assert cv_score(100, 100, 100) == 100.0
|
||||
assert cv_score(80, 60, 40) == round((2400 + 1500 + 1200) / 85, 1)
|
||||
assert cv_score(10, 10, 10) == 100.0
|
||||
assert cv_score(8, 6, 4) == round(10 * (240 + 150 + 120) / 85, 1)
|
||||
assert cv_score(8, 6, 9, broken=1) == cv_score(8, 6, 4)
|
||||
|
||||
|
||||
def test_a_stored_language_list_survives_a_bad_entry(store: Store) -> None:
|
||||
@@ -251,12 +252,12 @@ def test_v29_adds_the_musts_and_broken_columns_and_runs_twice(tmp_path: Path) ->
|
||||
conn.execute(f"ALTER TABLE role_judgements DROP COLUMN {column}")
|
||||
conn.execute("PRAGMA user_version = 28")
|
||||
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32, 33]
|
||||
with sqlite3.connect(path) as conn:
|
||||
columns = {r[1] for r in conn.execute("PRAGMA table_info(role_judgements)")}
|
||||
assert {"musts", "broken"} <= columns
|
||||
conn.execute("PRAGMA user_version = 28")
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
|
||||
@@ -268,12 +269,53 @@ def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [30, 31, 32]
|
||||
assert migrated.migrations_applied == [30, 31, 32, 33]
|
||||
[data] = migrated.agents()
|
||||
assert (data.like_text, data.avoid_text) == ("", "Reporting.")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 29")
|
||||
assert Store(path).migrations_applied == [30, 31, 32]
|
||||
assert Store(path).migrations_applied == [30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
|
||||
tmp_path: Path) -> None:
|
||||
"""A judgement on the 0 to 100 scale is never shown on the 0 to 10 one:
|
||||
migration 33 clears every row and gives the tries back, and the judge
|
||||
reads the pair again. `summarise_top` 50, migration 32's default, is 30;
|
||||
any other value, and a limits object without the key, stay."""
|
||||
path = tmp_path / "v32.db"
|
||||
store = Store(path)
|
||||
item = posting("1")
|
||||
upsert(store, item)
|
||||
old = store.save_agent("Old", "data leadership", cv_text="CV.")
|
||||
own = store.save_agent("Own", "data leadership")
|
||||
bare = store.save_agent("Bare", "data leadership")
|
||||
musts = [{"id": "M1", "text": "Remote", "verdict": "broken"}]
|
||||
assert store.set_judgement(old.id, item.uid, "key", 80, 70, 90, ["Good."], ["Bad."], musts)
|
||||
store.judge_missed([(own.id, item.uid)])
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("UPDATE agents SET limits = json_set(limits, '$.summarise_top', 50) "
|
||||
"WHERE id = ?", (old.id,))
|
||||
conn.execute("UPDATE agents SET limits = json_set(limits, '$.summarise_top', 12) "
|
||||
"WHERE id = ?", (own.id,))
|
||||
conn.execute("UPDATE agents SET limits = '{}' WHERE id = ?", (bare.id,))
|
||||
conn.execute("PRAGMA user_version = 32")
|
||||
|
||||
for _ in range(2): # runs twice without harm
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [33]
|
||||
assert migrated.judgement(old.id, item.uid) is None
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT skills, experience, career, cv_score, strengths, gaps, musts, broken, "
|
||||
"input_key, tries, judged_at FROM role_judgements").fetchall()
|
||||
assert rows == [(None, None, None, None, "[]", "[]", "[]", 0, "", 0, None)] * 2
|
||||
conn.execute("PRAGMA user_version = 32")
|
||||
assert {a.name: a.limits.summarise_top for a in migrated.agents()} == {
|
||||
"Old": 30, "Own": 12, "Bare": 30}
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert conn.execute("SELECT limits FROM agents WHERE id = ?",
|
||||
(bare.id,)).fetchone() == ("{}",)
|
||||
|
||||
|
||||
def test_the_musts_text_is_one_must_have_per_line() -> None:
|
||||
|
||||
@@ -282,7 +282,7 @@ def test_migration_31_adds_the_column_and_the_table_and_runs_twice(tmp_path: Pat
|
||||
conn.execute("DROP TABLE agent_cv_vectors")
|
||||
conn.execute("ALTER TABLE scores DROP COLUMN cv_fit")
|
||||
conn.execute("PRAGMA user_version = 30")
|
||||
assert Store(path).migrations_applied == [31, 32]
|
||||
assert Store(path).migrations_applied == [31, 32, 33]
|
||||
step = {v: s for v, _, s in MIGRATIONS}[31]
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert callable(step)
|
||||
|
||||
@@ -279,7 +279,7 @@ def test_a_v17_file_gains_dup_of_with_its_first_rebuild(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert dup_of(migrated) == {first.uid: None, second.uid: first.uid}
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert conn.execute("SELECT 1 FROM sqlite_master WHERE name = 'idx_roles_dup_of'"
|
||||
|
||||
@@ -300,7 +300,7 @@ def test_the_reach_line_counts_the_terms(store: Store) -> None:
|
||||
plan = reach.plan(store)
|
||||
philips = _sub(store, "phenom:www.careers.philips.com/global/en")
|
||||
assert reach.line(plan, philips) == \
|
||||
"all countries (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, head of"
|
||||
"all locations (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, head of"
|
||||
assert reach.line(plan, _sub(store, "smartrecruiters:BoschGroup")) == \
|
||||
"all places, too many countries to ask · follows agents' terms: data, engineer, head of"
|
||||
|
||||
@@ -520,7 +520,7 @@ def test_migration_23_gives_every_agent_no_terms(tmp_path: Path) -> None:
|
||||
conn.execute("ALTER TABLE agents DROP COLUMN fetch_terms")
|
||||
conn.execute("PRAGMA user_version = 22")
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert migrated.agents()[0].fetch_terms == []
|
||||
|
||||
|
||||
|
||||
+21
-12
@@ -51,7 +51,7 @@ class Model:
|
||||
|
||||
|
||||
def judged(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
return [{"key": i["key"], "skills": 80, "experience": 70, "career": 90,
|
||||
return [{"key": i["key"], "skills": 8, "experience": 7, "career": 9,
|
||||
"strengths": ["Leads a data science team.", "", "Python.", "ML.", "Fourth."],
|
||||
"gaps": ["No people budget stated."]} for i in items]
|
||||
|
||||
@@ -100,8 +100,8 @@ def test_a_run_writes_the_judgement_and_its_total(
|
||||
|
||||
found = store.judgement(owner.id, uid)
|
||||
assert found is not None
|
||||
assert (found.skills, found.experience, found.career) == (80, 70, 90)
|
||||
assert found.cv_score == round((30 * 80 + 25 * 70 + 30 * 90) / 85, 1)
|
||||
assert (found.skills, found.experience, found.career) == (8, 7, 9)
|
||||
assert found.cv_score == round(10 * (30 * 8 + 25 * 7 + 30 * 9) / 85, 1)
|
||||
assert found.strengths == ["Leads a data science team.", "Python.", "ML."]
|
||||
assert found.gaps == ["No people budget stated."]
|
||||
assert result["judged"] == 1 and result["pending"] == 0
|
||||
@@ -125,7 +125,7 @@ def test_the_musts_are_numbered_in_the_profile_and_stored_with_their_text(
|
||||
[uid] = ranked(store, owner, "1")
|
||||
|
||||
def reply(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
return [{**one, "career": 80, "musts": [
|
||||
return [{**one, "career": 8, "musts": [
|
||||
{"id": "M1", "verdict": "met"}, {"id": "M2", "verdict": "broken"},
|
||||
{"id": "M9", "verdict": "broken"}, {"id": "M3", "verdict": "maybe"}]}
|
||||
for one in judged(items)]
|
||||
@@ -140,8 +140,8 @@ def test_the_musts_are_numbered_in_the_profile_and_stored_with_their_text(
|
||||
assert [(m.id, m.text, m.verdict) for m in found.musts] == [
|
||||
("M1", "Permanent contract", "met"), ("M2", "Remote two days", "broken"),
|
||||
("M3", "Danish team", "unclear")]
|
||||
assert (found.career, found.career_capped, found.broken) == (80, 39, 1)
|
||||
assert found.cv_score == round((30 * 80 + 25 * 70 + 30 * 39) / 85, 1)
|
||||
assert (found.career, found.career_capped, found.broken) == (8, 4, 1)
|
||||
assert found.cv_score == round(10 * (30 * 8 + 25 * 7 + 30 * 4) / 85, 1)
|
||||
|
||||
|
||||
def test_a_must_the_model_left_out_is_unclear_and_nothing_is_broken_by_silence(
|
||||
@@ -153,7 +153,7 @@ def test_a_must_the_model_left_out_is_unclear_and_nothing_is_broken_by_silence(
|
||||
found = store.judgement(owner.id, uid)
|
||||
assert found is not None
|
||||
assert [(m.id, m.verdict) for m in found.musts] == [("M1", "unclear")]
|
||||
assert (found.career, found.career_capped, found.broken) == (90, 90, 0)
|
||||
assert (found.career, found.career_capped, found.broken) == (9, 9, 0)
|
||||
|
||||
|
||||
def test_the_schema_requires_the_verdicts_and_the_prompt_leaves_the_cap_to_code() -> None:
|
||||
@@ -161,7 +161,8 @@ def test_the_schema_requires_the_verdicts_and_the_prompt_leaves_the_cap_to_code(
|
||||
assert "musts" in item["required"]
|
||||
verdict = item["properties"]["musts"]["items"]["properties"]["verdict"]
|
||||
assert verdict["enum"] == ["met", "broken", "unclear"]
|
||||
assert "career 0-39" not in judge.SYSTEM and "clearly contradicts" in judge.SYSTEM
|
||||
assert "career 0-3" not in judge.SYSTEM and "clearly contradicts" in judge.SYSTEM
|
||||
assert "0 to 10" in judge.SYSTEM and "80-100" not in judge.SYSTEM
|
||||
|
||||
|
||||
def test_judgements_made_before_the_format_are_made_again(store: Store) -> None:
|
||||
@@ -169,6 +170,14 @@ def test_judgements_made_before_the_format_are_made_again(store: Store) -> None:
|
||||
assert judge.input_key(owner, "text") != hashlib_old_key(owner, "text")
|
||||
|
||||
|
||||
def test_a_judgement_on_the_0_to_100_scale_is_made_again(
|
||||
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
owner = hunter(store)
|
||||
now = judge.input_key(owner, "text")
|
||||
monkeypatch.setattr(judge, "FORMAT", 3)
|
||||
assert judge.input_key(owner, "text") != now
|
||||
|
||||
|
||||
def test_what_the_person_likes_is_part_of_what_a_judgement_read(store: Store) -> None:
|
||||
owner = hunter(store)
|
||||
liked = store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id,
|
||||
@@ -265,16 +274,16 @@ def test_an_answer_without_its_three_numbers_is_rejected(
|
||||
owner = hunter(store)
|
||||
[uid] = ranked(store, owner, "1")
|
||||
stub(monkeypatch, lambda items: [{"key": items[0]["key"], "skills": None,
|
||||
"experience": 50, "career": 250,
|
||||
"experience": 5, "career": 25,
|
||||
"strengths": [], "gaps": []}])
|
||||
modeltask.run(judge.TASK, config, store)
|
||||
assert store.judgement(owner.id, uid) is None
|
||||
stub(monkeypatch, lambda items: [{"key": items[0]["key"], "skills": 40.4,
|
||||
"experience": 50, "career": 250,
|
||||
stub(monkeypatch, lambda items: [{"key": items[0]["key"], "skills": 4.4,
|
||||
"experience": 5, "career": 25,
|
||||
"strengths": [], "gaps": []}])
|
||||
modeltask.run(judge.TASK, config, store)
|
||||
found = store.judgement(owner.id, uid)
|
||||
assert found is not None and (found.skills, found.career) == (40, 100)
|
||||
assert found is not None and (found.skills, found.career) == (4, 10)
|
||||
|
||||
|
||||
def test_a_batch_holds_one_agents_pairs_with_that_agents_profile(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""A company's two fetch overrides (see "The agents set the reach of a pull"
|
||||
and "Fetch terms" in `docs/decisions.md`): All countries reads its big boards
|
||||
and "Fetch terms" in `docs/decisions.md`): All locations reads its big boards
|
||||
with the agents' wide reach, All roles with no fetch terms. The four
|
||||
combinations, the reach line, migration 24 and a merge. No network."""
|
||||
|
||||
@@ -53,9 +53,9 @@ def _read(store: Store, target: str) -> tuple[Ask, str]:
|
||||
@pytest.mark.parametrize("countries, roles, line", [
|
||||
(False, False, "follows agents: DK, SE · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(False, True, "follows agents: DK, SE · remote not asked on Phenom · all roles"),
|
||||
(True, False, "all countries (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(True, True, "all countries (Europe) · remote not asked on Phenom · all roles"),
|
||||
], ids=["neither", "all roles alone", "all countries alone", "both"])
|
||||
(True, False, "all locations (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(True, True, "all locations (Europe) · remote not asked on Phenom · all roles"),
|
||||
], ids=["neither", "all roles alone", "all locations alone", "both"])
|
||||
def test_the_four_combinations(store: Store, countries: bool, roles: bool, line: str) -> None:
|
||||
_board(store, PHILIPS, "Philips")
|
||||
store.set_all_countries("philips", countries)
|
||||
@@ -122,7 +122,7 @@ def test_migration_24_splits_the_tag_and_moves_terms_off(tmp_path: Path) -> None
|
||||
conn.execute("UPDATE companies SET all_roles=1 WHERE key='mistral-ai'")
|
||||
conn.execute("PRAGMA user_version = 23")
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
flags = {c.key: (c.all_countries, c.all_roles) for c in migrated.companies()}
|
||||
assert flags == {"mistral-ai": (1, 1), "acme": (0, 1), "plain": (0, 0)}
|
||||
params = {s.target: s.params for s in migrated.subscriptions(source="ats")}
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ def test_migration_22_fills_the_host_words_from_raw(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
one = row(migrated, "1")
|
||||
assert (one["seniority_host"], one["employment_host"], one["remote_host"],
|
||||
one["country_host"]) == ("senior", "full_time", "true", "DK")
|
||||
|
||||
+3
-3
@@ -117,7 +117,7 @@ def test_a_company_tagged_all_roles_is_read_across_the_require_reach(store: Stor
|
||||
# Europe, and the base's remote, which a tag never reads less than.
|
||||
assert why == "countries" and {"DE", "FR", "DK"} <= wide.countries and wide.remote
|
||||
# The gate lists Europe's countries one by one; the line names the continent.
|
||||
assert reach.line(plan, subs["workday:mistral"]) == "all countries (Europe) · all roles"
|
||||
assert reach.line(plan, subs["workday:mistral"]) == "all locations (Europe) · all roles"
|
||||
assert plan.why(subs["workday:acme"]) == (plan.base, "agents")
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ def test_a_tag_asks_phenom_for_europe_in_one_request(store: Store) -> None:
|
||||
store.set_all_countries("mistral-ai", True)
|
||||
[sub] = store.subscriptions(source="ats")
|
||||
found = reach.plan(store)
|
||||
assert reach.line(found, sub) == "all countries (Europe) · remote not asked on Phenom · all roles"
|
||||
assert reach.line(found, sub) == "all locations (Europe) · remote not asked on Phenom · all roles"
|
||||
|
||||
|
||||
def test_an_agent_without_a_required_place_makes_the_tag_everywhere(store: Store) -> None:
|
||||
@@ -157,7 +157,7 @@ def test_an_agent_without_a_required_place_makes_the_tag_everywhere(store: Store
|
||||
[sub] = store.subscriptions(source="ats")
|
||||
assert plan.why(sub) == (reach.EVERYWHERE, "countries")
|
||||
assert plan.for_subscription(sub) is None
|
||||
assert reach.line(plan, sub) == "all countries (everywhere): read whole"
|
||||
assert reach.line(plan, sub) == "all locations (everywhere): read whole"
|
||||
|
||||
|
||||
def test_a_boards_own_reach_wins_over_the_tag(store: Store) -> None:
|
||||
|
||||
@@ -530,7 +530,7 @@ def test_migration_27_keeps_an_older_readers_remote_as_the_hosts_word(tmp_path:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30, 31, 32, 33]
|
||||
assert migrated.gazetteer().anywhere is not None
|
||||
row = migrated._row("SELECT remote_host, remote_model, remote_where_model FROM roles "
|
||||
"WHERE uid = ?", (board,))
|
||||
@@ -540,7 +540,7 @@ def test_migration_27_keeps_an_older_readers_remote_as_the_hosts_word(tmp_path:
|
||||
assert area(migrated, search.uid) == ("", "")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 26")
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_a_role_waits_for_extract_until_it_was_asked_where(store: Store) -> None:
|
||||
|
||||
+2
-2
@@ -443,7 +443,7 @@ def test_a_favourite_is_gated_by_a_require_gate_it_fails(
|
||||
def test_all_countries_passes_the_any_group_a_favourite_does_not(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
""""Denmark or remote" gates the onsite German role of a neutral company
|
||||
and of a favourite, and lets the same role of an All countries company
|
||||
and of a favourite, and lets the same role of an All locations company
|
||||
through."""
|
||||
for name in ("Fave", "Wide", "Other"):
|
||||
store.add_company(name)
|
||||
@@ -465,7 +465,7 @@ def test_all_countries_passes_the_any_group_a_favourite_does_not(
|
||||
|
||||
|
||||
def test_all_countries_skips_the_place_part_and_all_roles_the_titles() -> None:
|
||||
"""The region applies to every company; All countries lifts the `any`
|
||||
"""The region applies to every company; All locations lifts the `any`
|
||||
group, All roles the exclude gates on title and no other exclude gate."""
|
||||
gates = [Gate(field="country", values=["DK", "SE", "EU"]),
|
||||
Gate(field="country", values=["DK"], mode="any"),
|
||||
|
||||
+56
-28
@@ -71,7 +71,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
|
||||
"application_events", "agents", "scores", "state"} <= tables
|
||||
assert "idx_roles_cluster" in indexes
|
||||
assert store.migrations_applied == []
|
||||
assert LATEST == 32
|
||||
assert LATEST == 33
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -191,7 +191,7 @@ def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
|
||||
@@ -396,7 +396,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
|
||||
Prompt(name="Backend", text="python backend")]
|
||||
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
|
||||
@@ -420,7 +420,7 @@ def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
|
||||
@@ -449,7 +449,7 @@ def test_v17_folds_every_place_and_levels_the_titles_extract_has_not_read(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
|
||||
"SELECT uid, place_fold, seniority FROM roles")}
|
||||
@@ -691,7 +691,7 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert [p.name for p in migrated.role_places(joined.uid)] == ["Copenhagen", "Malmö"]
|
||||
assert [p.name for p in migrated.role_places(detailed.uid)] == ["Aarhus"]
|
||||
assert migrated.role_places(stated.uid) == []
|
||||
@@ -733,7 +733,7 @@ def test_v25_clears_the_model_levels_the_ladder_splits_and_sets_the_level(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
with sqlite3.connect(path) as conn:
|
||||
found = {sid: rest for sid, *rest in conn.execute(
|
||||
"SELECT source_id, seniority_model, seniority_stated, seniority_title, seniority "
|
||||
@@ -751,12 +751,12 @@ def test_v26_adds_posting_url_empty_and_runs_twice_without_harm(tmp_path: Path)
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33]
|
||||
role = migrated.role(posting("a").uid)
|
||||
assert role is not None and role.posting_url == ""
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 25") # the column is there already
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
|
||||
@@ -1005,7 +1005,7 @@ def test_the_newest_feed_query_uses_the_partial_posted_at_index(
|
||||
upsert(store, posting("1"))
|
||||
sql, _ = store._roles_from(
|
||||
company=None, place=None, open_only=True, q=None, function=None, remote=None,
|
||||
days=None, hide_muted=False, include_read=True, tags=(), tag_mode="any",
|
||||
days=None, include_read=True, tags=(), tag_mode="any",
|
||||
agent=None, by_score=True, gated=False, judged=None)
|
||||
assert "INDEXED BY" not in sql # the hint belongs to roles(), not the shared builder
|
||||
|
||||
@@ -1171,7 +1171,7 @@ def test_open_companies_and_places_are_what_the_rail_suggests_from(store: Store)
|
||||
assert sorted(store.open_places()) == [("Gentofte", "DK", 2), ("Malmö", "SE", 2)]
|
||||
|
||||
|
||||
def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock) -> None:
|
||||
def test_roles_leave_out_a_hidden_company_before_the_limit(store: Store, clock: Clock) -> None:
|
||||
agent = store.save_agent("A")
|
||||
store.add_company("Acme", key="acme")
|
||||
store.set_affinity(agent.id, "acme", -1)
|
||||
@@ -1180,18 +1180,18 @@ def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock)
|
||||
for i in range(3):
|
||||
upsert(store, posting(f"a{i}", company="Acme"))
|
||||
clock.tick()
|
||||
# Acme's roles are the three newest, so a plain limit=1 shows only Acme;
|
||||
# hide_muted has to reach past all three to find "other" rather than
|
||||
# just dropping Acme's rows out of an already-limited page.
|
||||
# Acme's roles are the three newest, so a plain limit=1 would show only
|
||||
# Acme; leaving it out has to reach past all three to find "other"
|
||||
# rather than just dropping Acme's rows out of an already-limited page.
|
||||
listing = {"agent": agent.id, "by_score": False}
|
||||
assert [r.source_id for r in store.roles(limit=1, **listing)] == ["a2"]
|
||||
assert [r.source_id for r in store.roles(limit=1, hide_muted=True, **listing)] == ["other"]
|
||||
assert {r.source_id for r in store.roles(hide_muted=True, **listing)} == {"other"}
|
||||
assert {r.source_id for r in store.roles(**listing)} == {"a0", "a1", "a2", "other"}
|
||||
assert [r.source_id for r in store.roles(limit=1, **listing)] == ["other"]
|
||||
assert {r.source_id for r in store.roles(**listing)} == {"other"}
|
||||
assert store.count_roles(**listing) == 1
|
||||
assert sum(n for _, n in store.role_facets(**listing)["seniority"]) == 1
|
||||
# Hidden is per agent: another agent, or no agent, hides nothing.
|
||||
other = store.save_agent("B")
|
||||
assert store.count_roles(hide_muted=True, agent=other.id, by_score=False) == 4
|
||||
assert store.count_roles(hide_muted=True) == 4
|
||||
assert store.count_roles(agent=other.id, by_score=False) == 4
|
||||
assert store.count_roles() == 4
|
||||
|
||||
|
||||
def test_roles_page_by_offset_and_count_the_same_filter(
|
||||
@@ -1206,7 +1206,7 @@ def test_roles_page_by_offset_and_count_the_same_filter(
|
||||
agent = store.save_agent("A")
|
||||
store.add_company("Other", key="other")
|
||||
store.set_affinity(agent.id, "other", -1)
|
||||
assert store.count_roles(hide_muted=True, agent=agent.id, by_score=False) == 3
|
||||
assert store.count_roles(agent=agent.id, by_score=False) == 3
|
||||
|
||||
|
||||
def test_a_vote_is_stamped_cleared_and_filtered(store: Store, clock: Clock) -> None:
|
||||
@@ -1383,21 +1383,20 @@ def test_roles_filters_by_tags_any_and_all(store: Store) -> None:
|
||||
store.roles(tags=["python"], tag_mode="maybe")
|
||||
|
||||
|
||||
def test_tag_counts_orders_by_count_then_tag_and_respects_muted(store: Store) -> None:
|
||||
def test_tag_counts_orders_by_count_then_tag_and_leaves_out_hidden(store: Store) -> None:
|
||||
store.add_company("Hidden", key="hidden")
|
||||
agent = store.save_agent("A")
|
||||
store.set_affinity(agent.id, "hidden", -1)
|
||||
upsert(store, posting("1", company="Acme"))
|
||||
upsert(store, posting("2", company="Acme"))
|
||||
upsert(store, posting("3", company="Hidden"))
|
||||
uid = {r.source_id: r.uid for r in store.roles(hide_muted=False)}
|
||||
uid = {r.source_id: r.uid for r in store.roles()}
|
||||
store.set_tags(uid["1"], ["python", "backend"])
|
||||
store.set_tags(uid["2"], ["python"])
|
||||
store.set_tags(uid["3"], ["python", "backend"])
|
||||
store.set_read(uid["1"])
|
||||
|
||||
assert store.tag_counts(agent.id) == [("python", 2, 1), ("backend", 1, 0)]
|
||||
assert store.tag_counts(agent.id, show_muted=True) == [("python", 3, 2), ("backend", 2, 1)]
|
||||
assert store.tag_counts() == [("python", 3, 2), ("backend", 2, 1)] # no agent, nothing hidden
|
||||
|
||||
|
||||
@@ -1774,11 +1773,40 @@ def test_summarise_waits_on_the_top_of_each_enabled_agent_by_its_own_limits(
|
||||
assert [r.uid for r in store.summarise_waiting(10, uids=[d])] == [d]
|
||||
store.save_agent("Two", "python backend", agent_id=two.id, limits=Limits(summarise_top=0))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a}
|
||||
# '{}' is the defaults, 50 deep.
|
||||
# '{}' is the defaults, 30 deep.
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE agents SET limits = '{}'")
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b, c}
|
||||
assert store.agents()[0].limits == Limits()
|
||||
assert Limits().summarise_top == 30
|
||||
|
||||
|
||||
def test_summarise_waits_on_the_top_of_the_want_and_the_match_order(store: Store) -> None:
|
||||
"""An agent with a CV adds the top of its match order to the top of its
|
||||
want order: the judged roles by `cv_score`, then the rest by `cv_fit`,
|
||||
as `order=cv` lists them. Without a prompt only the match top counts,
|
||||
without a CV only the want top, which the vote moves as in the feed."""
|
||||
for sid in "abcd":
|
||||
upsert(store, posting(sid))
|
||||
a, b, c, d = (posting(s).uid for s in "abcd")
|
||||
both = store.save_agent("Both", "python backend", cv_text="Python engineer.",
|
||||
limits=Limits(summarise_top=1))
|
||||
store.replace_scores(both.id, [(a, 0.9, "", "", 0.1), (b, 0.5, "", "", 0.95),
|
||||
(c, 0.4, "", "", 0.2), (d, 0.3, "remote", "", 0.99)])
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b}
|
||||
# A judged role leads the match order whatever its closeness.
|
||||
assert store.set_judgement(both.id, c, "key", 6, 6, 6, [], [])
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, c}
|
||||
|
||||
store.save_agent("Both", agent_id=both.id, prompts=[], cv_text="Python engineer.",
|
||||
limits=Limits(summarise_top=1))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {c}
|
||||
|
||||
store.save_agent("Both", "python backend", agent_id=both.id, cv_text="",
|
||||
limits=Limits(summarise_top=1))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a}
|
||||
store.set_vote(both.id, a, -1) # 0.9 halved falls below b's 0.5
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {b}
|
||||
|
||||
|
||||
# ------------------------------------------------------------- migration 32
|
||||
@@ -1827,7 +1855,7 @@ def test_v32_resets_the_limits_drops_prefer_gates_and_renames_enrich(tmp_path: P
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [32]
|
||||
assert migrated.migrations_applied == [32, 33]
|
||||
by_name = {a.name: a for a in migrated.agents()}
|
||||
assert by_name["Wolf"].limits == Limits() == by_name["Bare"].limits
|
||||
assert [(g.field, g.mode) for g in by_name["Wolf"].gates] == [
|
||||
@@ -1852,14 +1880,14 @@ def test_v32_runs_twice_and_keeps_limits_set_since(tmp_path: Path) -> None:
|
||||
store = Store(path)
|
||||
agent = store.save_agent("Wolf", limits=Limits(cut_fit_top=900))
|
||||
_v31(path)
|
||||
assert Store(path).migrations_applied == [32]
|
||||
assert Store(path).migrations_applied == [32, 33]
|
||||
assert Store(path).agent(agent.id).limits == Limits() # type: ignore[union-attr]
|
||||
narrow = Limits(cut_fit_top=900, summarise_top=10)
|
||||
store.save_agent("Wolf", agent_id=agent.id, limits=narrow)
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 31") # the columns are there already
|
||||
again = Store(path)
|
||||
assert again.migrations_applied == [32]
|
||||
assert again.migrations_applied == [32, 33]
|
||||
assert again.agent(agent.id).limits == narrow # type: ignore[union-attr]
|
||||
|
||||
|
||||
|
||||
+10
-7
@@ -279,7 +279,7 @@ def test_list_roles_limit_is_bounded(client: TestClient, store: Store) -> None:
|
||||
assert client.get("/api/roles", params={"limit": 1001}).status_code == 422
|
||||
|
||||
|
||||
def test_muted_roles_are_hidden_unless_show_muted(client: TestClient, store: Store) -> None:
|
||||
def test_a_hidden_companys_roles_are_never_shown(client: TestClient, store: Store) -> None:
|
||||
store.add_company("Acme", key="acme")
|
||||
upsert(store, posting("1", company="Acme"))
|
||||
upsert(store, posting("2", company="Other"))
|
||||
@@ -296,7 +296,10 @@ def test_muted_roles_are_hidden_unless_show_muted(client: TestClient, store: Sto
|
||||
# without `agent` hides for.
|
||||
assert client.post("/api/companies/acme/affinity", json={"affinity": -1}).status_code == 200
|
||||
assert shown() == {uid["2"]}
|
||||
assert shown(show_muted="true") == {uid["1"], uid["2"]}
|
||||
# `show_muted` is gone: the parameter is ignored and lifts nothing.
|
||||
assert shown(show_muted="true") == {uid["2"]}
|
||||
assert shown(agent=agent.id) == {uid["2"]}
|
||||
assert client.get("/api/roles", params={"agent": agent.id}).json()["total"] == 1
|
||||
assert shown(agent=agent.id, order="newest") == {uid["2"]}
|
||||
# Hidden is per agent: the other agent still sees Acme.
|
||||
assert shown(agent=other.id, order="newest") == {uid["1"], uid["2"]}
|
||||
@@ -528,14 +531,14 @@ def test_list_roles_filters_by_tags_any_and_all(client: TestClient, store: Store
|
||||
assert item["tags"] == ["backend", "python"]
|
||||
|
||||
|
||||
def test_filters_lists_tag_counts_and_respects_show_muted(
|
||||
def test_filters_lists_tag_counts_without_a_hidden_company(
|
||||
client: TestClient, store: Store) -> None:
|
||||
store.add_company("Hidden", key="hidden")
|
||||
agent = store.save_agent("A") # the default agent, whose hidden companies count
|
||||
store.set_affinity(agent.id, "hidden", -1)
|
||||
upsert(store, posting("1", company="Acme"))
|
||||
upsert(store, posting("2", company="Hidden"))
|
||||
uid = {r.source_id: r.uid for r in store.roles(hide_muted=False)}
|
||||
uid = {r.source_id: r.uid for r in store.roles()}
|
||||
store.set_tags(uid["1"], ["python"])
|
||||
store.set_tags(uid["2"], ["python"])
|
||||
|
||||
@@ -544,7 +547,7 @@ def test_filters_lists_tag_counts_and_respects_show_muted(
|
||||
assert res.json() == {"tags": [{"tag": "python", "count": 1, "unread": 1}]}
|
||||
|
||||
muted = client.get("/api/filters", params={"show_muted": "true"})
|
||||
assert muted.json() == {"tags": [{"tag": "python", "count": 2, "unread": 2}]}
|
||||
assert muted.json() == {"tags": [{"tag": "python", "count": 1, "unread": 1}]}
|
||||
|
||||
|
||||
def test_one_role_and_its_read_page(client: TestClient, store: Store) -> None:
|
||||
@@ -1204,7 +1207,7 @@ def test_an_agents_limits_are_saved_listed_and_checked(client: TestClient) -> No
|
||||
outside 0..1 and a key from before the cut are refused."""
|
||||
default = client.post("/api/agents", json={"name": "Wide"}).json()
|
||||
assert default["limits"] == {"cut_fit_top": 500, "cut_fit_min": 0.6,
|
||||
"cut_cv_top": 150, "cut_cv_min": 0.6, "summarise_top": 50}
|
||||
"cut_cv_top": 150, "cut_cv_min": 0.6, "summarise_top": 30}
|
||||
narrow = {"cut_fit_top": 50, "cut_fit_min": 0.7, "cut_cv_top": 10, "cut_cv_min": 0.75,
|
||||
"summarise_top": 5}
|
||||
saved = client.post("/api/agents", json={"name": "Narrow", "limits": narrow})
|
||||
@@ -1916,7 +1919,7 @@ def test_saved_filters_are_listed_saved_and_deleted_per_agent(
|
||||
|
||||
def test_an_override_queues_a_rescore_and_fetch_text_either_way(
|
||||
client: TestClient, store: Store, queue: Any) -> None:
|
||||
"""All countries and All roles change the agents' fetch gates for the
|
||||
"""All locations and All roles change the agents' fetch gates for the
|
||||
roles already stored, so either switch, on or off, rescores."""
|
||||
states = ("queued", "running", "done", "failed", "cancelled")
|
||||
store.add_company("Acme")
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_all_countries_reads_the_wide_reach_and_on_queues_a_pull(
|
||||
row = _row(client)
|
||||
# Wolf requires no place, so the wide reach is everywhere.
|
||||
assert (row["all_countries"], row["all_roles"], row["reach"]) == (
|
||||
True, False, "all countries (everywhere): read whole")
|
||||
True, False, "all locations (everywhere): read whole")
|
||||
# A board's own countries win over it.
|
||||
client.post(f"/api/sources/{bosch}/reach", json={"mode": "own", "countries": ["DE"]})
|
||||
assert _row(client)["reach"] == "set here: DE · all roles"
|
||||
|
||||
Reference in new issue
Block a user