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:
WolfandClaude Fable 5.1 committed 2026-10-06 13:55:59 +02:00
1 parent 38c31c830b
commit 2159c7925f
19 files changed
+157 -365

No files matched your search

+46 -42
View File
@@ -16,7 +16,7 @@ from pydantic import ValidationError
from app import prep
from app.config import Config
from app.jobs import extract
from app.models import CvLanguage, RoleLanguage, cv_score, iso_day, language_flag, must_lines
from app.models import CvLanguage, RoleLanguage, cv_score, iso_day, language_flag
from app.storage import Store
from desk import modeltask
from desk.models import Item
@@ -44,24 +44,21 @@ def test_an_agent_keeps_its_cv_fields_when_a_save_leaves_them_out(store: Store)
cv_languages=[CvLanguage(language="DA", level="native"),
CvLanguage(language="en", level="fluent"),
CvLanguage(language="da", level="basic")],
like_text=" Building teams. ", avoid_text="Pure reporting.",
must_text="Permanent contract.")
like_text=" Building teams. ", avoid_text="Pure reporting.")
assert made.cv_text == "VP Data."
assert [(lang.language, lang.level) for lang in made.cv_languages] == \
[("da", "native"), ("en", "fluent")]
assert (made.like_text, made.avoid_text, made.must_text) == \
("Building teams.", "Pure reporting.", "Permanent contract.")
assert (made.like_text, made.avoid_text) == ("Building teams.", "Pure reporting.")
kept = store.save_agent("Data", "data leadership", agent_id=made.id)
assert (kept.cv_text, kept.like_text, kept.avoid_text, kept.must_text) == \
("VP Data.", "Building teams.", "Pure reporting.", "Permanent contract.")
assert (kept.cv_text, kept.like_text, kept.avoid_text) == \
("VP Data.", "Building teams.", "Pure reporting.")
assert len(kept.cv_languages) == 2
cleared = store.save_agent("Data", "data leadership", agent_id=made.id, cv_text="",
cv_languages=[], like_text="", avoid_text="",
must_text="")
assert (cleared.cv_text, cleared.cv_languages, cleared.like_text, cleared.avoid_text,
cleared.must_text) == ("", [], "", "", "")
cv_languages=[], like_text="", avoid_text="")
assert (cleared.cv_text, cleared.cv_languages, cleared.like_text, cleared.avoid_text) == \
("", [], "", "")
def test_a_cv_language_is_a_code_and_a_level_of_the_ladder() -> None:
@@ -92,25 +89,24 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
conn.execute("DROP TABLE role_judgements")
for column in ("languages_required", "deadline_host", "deadline_model", "deadline"):
conn.execute(f"ALTER TABLE roles DROP COLUMN {column}")
for column in ("cv_text", "cv_languages", "avoid_text", "must_text"):
for column in ("cv_text", "cv_languages", "avoid_text"):
conn.execute(f"ALTER TABLE agents DROP COLUMN {column}")
conn.execute("PRAGMA user_version = 27")
migrated = Store(path)
assert migrated.migrations_applied == [28, 29, 30, 31, 32, 33]
assert migrated.migrations_applied == [28, 29, 30, 31, 32, 33, 34]
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)
assert rows["a"]["languages_required"] is None and rows["b"]["deadline_host"] == ""
[data] = migrated.agents()
assert (data.cv_text, data.cv_languages, data.avoid_text, data.must_text) == \
("", [], "", "")
assert (data.cv_text, data.cv_languages, data.avoid_text) == ("", [], "")
prep.run(migrated, remap=True, dupes=False)
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, 33]
assert Store(path).migrations_applied == [28, 29, 30, 31, 32, 33, 34]
# ---------------------------------------------------------------- deadline
@@ -231,7 +227,6 @@ def test_the_language_flag() -> None:
def test_the_cv_score_weighs_skills_and_career_above_experience() -> None:
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:
@@ -244,20 +239,36 @@ def test_a_stored_language_list_survives_a_bad_entry(store: Store) -> None:
assert [lang.language for lang in store.role(item.uid).languages_required] == ["da"]
def test_v29_adds_the_musts_and_broken_columns_and_runs_twice(tmp_path: Path) -> None:
path = tmp_path / "v28.db"
Store(path)
def test_v34_drops_the_must_haves_and_runs_twice(tmp_path: Path) -> None:
"""A file from before migration 34 holds the agent's must text and the
judge's verdicts on it; the columns go, the rest of the agent and the
judgement stay."""
path = tmp_path / "v33.db"
store = Store(path)
item = posting("1")
upsert(store, item)
agent = store.save_agent("Data", "data leadership", cv_text="CV.", like_text="Teams.")
assert store.set_judgement(agent.id, item.uid, "key", 8, 7, 9, ["Good."], ["Bad."])
with sqlite3.connect(path) as conn:
for column in ("musts", "broken"):
conn.execute(f"ALTER TABLE role_judgements DROP COLUMN {column}")
conn.execute("PRAGMA user_version = 28")
conn.execute("ALTER TABLE agents ADD COLUMN must_text TEXT NOT NULL DEFAULT ''")
conn.execute("ALTER TABLE role_judgements ADD COLUMN musts TEXT NOT NULL DEFAULT '[]'")
conn.execute("ALTER TABLE role_judgements ADD COLUMN broken INTEGER NOT NULL DEFAULT 0")
conn.execute("UPDATE agents SET must_text = 'Remote.'")
conn.execute("UPDATE role_judgements SET musts = ?, broken = 1",
(json.dumps([{"id": "M1", "text": "Remote.", "verdict": "broken"}]),))
conn.execute("PRAGMA user_version = 33")
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, 33]
for _ in range(2): # runs twice without harm
migrated = Store(path)
assert migrated.migrations_applied == [34]
with sqlite3.connect(path) as conn:
assert "must_text" not in {r[1] for r in conn.execute("PRAGMA table_info(agents)")}
assert not {"musts", "broken"} & {
r[1] for r in conn.execute("PRAGMA table_info(role_judgements)")}
conn.execute("PRAGMA user_version = 33")
assert migrated.agent(agent.id).like_text == "Teams." # type: ignore[union-attr]
found = migrated.judgement(agent.id, item.uid)
assert found is not None and (found.career, found.cv_score) == (9, cv_score(8, 7, 9))
def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
@@ -269,12 +280,12 @@ def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
migrated = Store(path)
assert migrated.migrations_applied == [30, 31, 32, 33]
assert migrated.migrations_applied == [30, 31, 32, 33, 34]
[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, 33]
assert Store(path).migrations_applied == [30, 31, 32, 33, 34]
def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
@@ -290,8 +301,7 @@ def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
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)
assert store.set_judgement(old.id, item.uid, "key", 80, 70, 90, ["Good."], ["Bad."])
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) "
@@ -303,22 +313,16 @@ def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
for _ in range(2): # runs twice without harm
migrated = Store(path)
assert migrated.migrations_applied == [33]
assert migrated.migrations_applied == [33, 34]
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, "
"SELECT skills, experience, career, cv_score, strengths, gaps, "
"input_key, tries, judged_at FROM role_judgements").fetchall()
assert rows == [(None, None, None, None, "[]", "[]", "[]", 0, "", 0, None)] * 2
assert rows == [(None, None, None, None, "[]", "[]", "", 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:
assert must_lines("- A\n* B c\n\u2022 D\n1. E\n2) F\n \nG\n-H") == [
"A", "B c", "D", "E", "F", "G", "-H"]
assert must_lines("") == []