Let the model report a verdict per must-have and cap career at 39 in code when one is broken
The judge numbers an agent's must-haves (one per line) and answers met, broken or unclear for each; career is stored as the model gave it and counts as at most BROKEN_CAP when a role is served, in cv_score, Store.judgement and the SQL of Best CV match. Migration 29 adds role_judgements.musts and broken; the judge's input_key carries a format version so earlier judgements are made again. The reader lists the must-haves with their verdicts and the cap. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
64fecf57ad
commit
001fc9002b
19 files changed
+336
-61
No files matched your search
+53
-7
@@ -1007,30 +1007,76 @@ 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
|
||||
#: 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
|
||||
|
||||
#: A must-have's verdict, as the judge answers it.
|
||||
MUST_VERDICTS = ("met", "broken", "unclear")
|
||||
|
||||
_BULLET = re.compile(r"^\s*(?:[-*\u2022]+|\(?\d+[.)])\s+")
|
||||
|
||||
|
||||
def must_lines(text: str) -> list[str]:
|
||||
"""The agent's must-haves text read as one must-have per line: a leading
|
||||
bullet (`-`, `*`, `•`) or number (`1.`, `2)`) is dropped, so are empty
|
||||
lines."""
|
||||
found = []
|
||||
for line in text.splitlines():
|
||||
line = " ".join(_BULLET.sub("", line, count=1).split())
|
||||
if line:
|
||||
found.append(line)
|
||||
return found
|
||||
|
||||
|
||||
def capped_career(career: int, broken: int = 0) -> int:
|
||||
"""`career` as it counts: at most `BROKEN_CAP` when any must-have is
|
||||
broken."""
|
||||
return min(career, BROKEN_CAP) if broken else career
|
||||
|
||||
|
||||
def cv_score(skills: int, experience: int, career: int,
|
||||
weights: "Weights | None" = None) -> float | None:
|
||||
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). None when all three
|
||||
weights are 0."""
|
||||
`cv_career` weights (30, 25 and 30 by default), career as
|
||||
`capped_career` has it. 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)
|
||||
|
||||
|
||||
class Must(Model):
|
||||
"""One must-have of an agent as the judge read it against a role: its
|
||||
`id` (`M1`, by line), the line's `text` and the `verdict`."""
|
||||
|
||||
id: str
|
||||
text: str = ""
|
||||
verdict: Literal["met", "broken", "unclear"] = "unclear"
|
||||
|
||||
|
||||
class Judgement(Model):
|
||||
"""What `judge` read of one role for one agent (`role_judgements`): the
|
||||
three dimensions 0 to 100, `cv_score` (`cv_score`) and 1 to 3 strengths
|
||||
and gaps grounded in the posting. `cv_score` is not read from the table:
|
||||
`Store.judgement` sets it from the agent's weights; None when all three
|
||||
are 0."""
|
||||
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.
|
||||
`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
|
||||
table: `Store.judgement` sets them from the agent's weights; `cv_score`
|
||||
is None when all three are 0."""
|
||||
|
||||
skills: int
|
||||
experience: int
|
||||
career: int
|
||||
career_capped: int | None = None
|
||||
broken: int = 0
|
||||
musts: Annotated[list[Must], BeforeValidator(lambda v: _json(v, "[]"))] = []
|
||||
cv_score: float | None = None
|
||||
strengths: JsonStrings = []
|
||||
gaps: JsonStrings = []
|
||||
|
||||
Reference in new issue
Block a user