Remove the must-haves the form dropped on 2026-10-03: the agent's must text, the judge's verdicts and the career cap they set, with migration 34 dropping their columns and the judge's format at 6 so every role is judged again
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
38c31c830b
commit
2159c7925f
19 files changed
+157
-365
No files matched your search
+20
-35
@@ -11,7 +11,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import sqlite3
|
||||
from collections import Counter
|
||||
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence
|
||||
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
|
||||
from contextlib import closing, contextmanager
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
@@ -26,7 +26,7 @@ from app.models import (
|
||||
AFFINITY, HAND_REASONS, LEVELS, STATUSES, Agent, Application,
|
||||
ApplicationEvent, Candidate, Company, CvLanguage, Gate, Judgement, Limits, Prompt, Role,
|
||||
RoleCopy, RolePlace, RoleRow, SavedFilter, ScoredRole, cv_languages as normal_languages, cv_score,
|
||||
BROKEN_CAP, capped_career, language_flag, role_languages,
|
||||
language_flag, role_languages,
|
||||
Subscription, Weights, check_prompts, company_fold, company_key, country_of, excerpt, place_key,
|
||||
fetch_terms as normal_terms, host_word, iso_day, posted_at, posted_host, remote_of, title_key,
|
||||
)
|
||||
@@ -140,7 +140,7 @@ _VOTED_SCORE = ("MIN(1.0, s.score * CASE v.vote WHEN -1 THEN 0.5 "
|
||||
_WITH_VOTES = "LEFT JOIN role_votes v ON v.uid = roles.uid AND v.agent_id = ?"
|
||||
|
||||
#: The agent's `judge` readings beside every role, the same way: `j.skills`,
|
||||
#: `j.experience`, `j.career` and `j.broken` are NULL for a role not judged and with no
|
||||
#: `j.experience` and `j.career` are NULL for a role not judged and with no
|
||||
#: agent.
|
||||
_WITH_JUDGEMENTS = ("LEFT JOIN role_judgements j ON j.uid = roles.uid AND j.agent_id = ? "
|
||||
"AND j.judged_at IS NOT NULL")
|
||||
@@ -150,19 +150,15 @@ _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, 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
|
||||
rather than bound, the select's placeholders being then no concern."""
|
||||
for a role not judged, and for all three weights 0. The weights are
|
||||
validated, finite floats, so they are written in rather than bound, the
|
||||
select's placeholders being then no concern."""
|
||||
w = weights or Weights()
|
||||
total = w.cv_skills + w.cv_experience + w.cv_career
|
||||
if not total:
|
||||
return "NULL"
|
||||
career = (f"(CASE WHEN j.broken > 0 AND j.career > {BROKEN_CAP} THEN {BROKEN_CAP} "
|
||||
"ELSE j.career END)")
|
||||
return (f"(10.0 * ({w.cv_skills!r} * j.skills + {w.cv_experience!r} * j.experience "
|
||||
f"+ {w.cv_career!r} * {career}) / {total!r})")
|
||||
f"+ {w.cv_career!r} * j.career) / {total!r})")
|
||||
|
||||
|
||||
def _by_cv(expression: str) -> str:
|
||||
@@ -2021,33 +2017,28 @@ class Store:
|
||||
|
||||
def set_judgement(self, agent_id: int, uid: str, input_key: str, skills: int,
|
||||
experience: int, career: int, strengths: Sequence[str],
|
||||
gaps: Sequence[str], musts: Sequence[Mapping[str, str]] = ()) -> bool:
|
||||
gaps: Sequence[str]) -> bool:
|
||||
"""Store `judge`'s reading of one role for one agent, replacing the
|
||||
one before: the three numbers as the model gave them, the verdict on
|
||||
each of the agent's must-haves (`musts`, `{id, text, verdict}`) and how
|
||||
many are broken, `cv_score` (`app.models.cv_score`, at the default
|
||||
weights and with the cap: the table's column is not read, see
|
||||
`judgement`) and its tries back at 0. False for an unknown role or
|
||||
agent."""
|
||||
broken = sum(1 for m in musts if m.get("verdict") == "broken")
|
||||
one before: the three numbers as the model gave them, `cv_score`
|
||||
(`app.models.cv_score`, at the default weights: the table's column is
|
||||
not read, see `judgement`) and its tries back at 0. False for an
|
||||
unknown role or agent."""
|
||||
try:
|
||||
with self.transaction() as conn:
|
||||
conn.execute(
|
||||
"""INSERT INTO role_judgements (uid, agent_id, skills, experience, career,
|
||||
cv_score, strengths, gaps, musts, broken,
|
||||
cv_score, strengths, gaps,
|
||||
input_key, tries, judged_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,0,?)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,0,?)
|
||||
ON CONFLICT(uid, agent_id) DO UPDATE SET
|
||||
skills=excluded.skills, experience=excluded.experience,
|
||||
career=excluded.career, cv_score=excluded.cv_score,
|
||||
strengths=excluded.strengths, gaps=excluded.gaps,
|
||||
musts=excluded.musts, broken=excluded.broken,
|
||||
input_key=excluded.input_key, tries=0, judged_at=excluded.judged_at""",
|
||||
(uid, agent_id, skills, experience, career,
|
||||
cv_score(skills, experience, career, broken=broken),
|
||||
cv_score(skills, experience, career),
|
||||
json.dumps(list(strengths), ensure_ascii=False),
|
||||
json.dumps(list(gaps), ensure_ascii=False),
|
||||
json.dumps([dict(m) for m in musts], ensure_ascii=False), broken,
|
||||
input_key, self.now()))
|
||||
except sqlite3.IntegrityError:
|
||||
return False
|
||||
@@ -2075,8 +2066,7 @@ class Store:
|
||||
def judgement(self, agent_id: int | None, uid: str) -> Judgement | None:
|
||||
"""The agent's judgement of one role, None when it has none, its
|
||||
`cv_score` the three numbers under the agent's weights as they are
|
||||
now, not as stored, and `career_capped` the model's career as the
|
||||
broken must-haves leave it (`BROKEN_CAP`)."""
|
||||
now, not as stored."""
|
||||
if agent_id is None:
|
||||
return None
|
||||
row = self._row("SELECT * FROM role_judgements WHERE agent_id = ? AND uid = ? "
|
||||
@@ -2085,9 +2075,8 @@ class Store:
|
||||
return None
|
||||
found = Judgement.from_row(row)
|
||||
agent = self.agent(agent_id)
|
||||
found.career_capped = capped_career(found.career, found.broken)
|
||||
found.cv_score = cv_score(found.skills, found.experience, found.career,
|
||||
agent.weights if agent else None, found.broken)
|
||||
agent.weights if agent else None)
|
||||
return found
|
||||
|
||||
def set_article_text(self, uid: str, text: str) -> Role | None:
|
||||
@@ -2209,14 +2198,13 @@ class Store:
|
||||
cv_text: str | None = None,
|
||||
cv_languages: Sequence[CvLanguage] | None = None,
|
||||
avoid_text: str | None = None,
|
||||
must_text: str | None = None,
|
||||
like_text: str | None = None) -> Agent:
|
||||
"""Create an agent, or with `agent_id` replace that one's fields and
|
||||
prompts. Without `prompts`, a non-empty `intent` is its one prompt,
|
||||
named after the agent. Without `fetch_terms` an update keeps the
|
||||
stored ones and a new agent has none, so a caller that does not know
|
||||
them (the CLI's prompt edit) loses none; `cv_text`, `cv_languages`,
|
||||
`like_text`, `avoid_text` and `must_text` are kept the same way. A prompt whose text is
|
||||
`like_text` and `avoid_text` are kept the same way. A prompt whose text is
|
||||
unchanged keeps its cached vector, whatever its name or place, so an
|
||||
edit re-embeds only the prompts it changed. A save gives every role
|
||||
`judge` gave up on for the agent its tries back, since what it is
|
||||
@@ -2237,7 +2225,6 @@ class Store:
|
||||
(limits or Limits()).model_dump_json(), int(enabled), terms,
|
||||
None if cv_text is None else cv_text.strip(), spoken,
|
||||
None if avoid_text is None else avoid_text.strip(),
|
||||
None if must_text is None else must_text.strip(),
|
||||
None if like_text is None else like_text.strip())
|
||||
try:
|
||||
with self.transaction() as conn:
|
||||
@@ -2245,10 +2232,9 @@ class Store:
|
||||
agent_id = conn.execute(
|
||||
"""INSERT INTO agents (name, gates, weights, limits, enabled,
|
||||
fetch_terms, cv_text, cv_languages, avoid_text,
|
||||
must_text, like_text, created_at)
|
||||
like_text, created_at)
|
||||
VALUES (?,?,?,?,?,COALESCE(?, '[]'),COALESCE(?, ''),
|
||||
COALESCE(?, '[]'),COALESCE(?, ''),COALESCE(?, ''),
|
||||
COALESCE(?, ''),?)""",
|
||||
COALESCE(?, '[]'),COALESCE(?, ''),COALESCE(?, ''),?)""",
|
||||
(*fields, self.now())).lastrowid
|
||||
elif not conn.execute(
|
||||
"""UPDATE agents SET name=?, gates=?, weights=?, limits=?, enabled=?,
|
||||
@@ -2256,7 +2242,6 @@ class Store:
|
||||
cv_text=COALESCE(?, cv_text),
|
||||
cv_languages=COALESCE(?, cv_languages),
|
||||
avoid_text=COALESCE(?, avoid_text),
|
||||
must_text=COALESCE(?, must_text),
|
||||
like_text=COALESCE(?, like_text)
|
||||
WHERE id=?""",
|
||||
(*fields, agent_id)).rowcount:
|
||||
|
||||
Reference in new issue
Block a user