Give an agent a soft profile of likes and dislikes and take the must-haves off the form (wp-likes)
Add agents.like_text (migration 30) beside avoid_text, now shown as "What I don't like". The judge reads both under <likes> and <dislikes>, its career rubric judges against the prompts, the likes and the dislikes, and FORMAT 3 makes earlier judgements be made again. The form drops the must-haves box and no longer sends must_text, so a stored one is kept and still caps career in code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
82afa831f2
commit
8c6cbdf002
18 files changed
+144
-75
No files matched your search
@@ -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]
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
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]
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
# 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
|
||||
|
||||
@@ -212,7 +212,7 @@ def test_an_agent_without_languages_flags_nothing(client: TestClient, store: Sto
|
||||
|
||||
|
||||
def test_the_cv_fields_round_trip_and_are_kept_when_left_out(client: TestClient) -> None:
|
||||
body = {"name": "Data", "cv_text": "VP Data.", "avoid_text": "Reporting.",
|
||||
body = {"name": "Data", "cv_text": "VP Data.", "like_text": "Teams.", "avoid_text": "Reporting.",
|
||||
"must_text": "Permanent.",
|
||||
"cv_languages": [{"language": "da", "level": "native"},
|
||||
{"language": "EN", "level": "fluent"}]}
|
||||
@@ -220,8 +220,8 @@ def test_the_cv_fields_round_trip_and_are_kept_when_left_out(client: TestClient)
|
||||
assert made["cv_languages"] == [{"language": "da", "level": "native"},
|
||||
{"language": "en", "level": "fluent"}]
|
||||
kept = client.post("/api/agents", json={"id": made["id"], "name": "Data"}).json()
|
||||
assert (kept["cv_text"], kept["avoid_text"], kept["must_text"]) == \
|
||||
("VP Data.", "Reporting.", "Permanent.")
|
||||
assert (kept["cv_text"], kept["like_text"], kept["avoid_text"], kept["must_text"]) == \
|
||||
("VP Data.", "Teams.", "Reporting.", "Permanent.")
|
||||
assert len(kept["cv_languages"]) == 2
|
||||
nulls = client.post("/api/agents", json={"id": made["id"], "name": "Data",
|
||||
"cv_text": None, "cv_languages": None}).json()
|
||||
|
||||
+31
-11
@@ -44,21 +44,24 @@ 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")],
|
||||
avoid_text="Pure reporting.", must_text="Permanent contract.")
|
||||
like_text=" Building teams. ", avoid_text="Pure reporting.",
|
||||
must_text="Permanent contract.")
|
||||
assert made.cv_text == "VP Data."
|
||||
assert [(lang.language, lang.level) for lang in made.cv_languages] == \
|
||||
[("da", "native"), ("en", "fluent")]
|
||||
assert (made.avoid_text, made.must_text) == ("Pure reporting.", "Permanent contract.")
|
||||
assert (made.like_text, made.avoid_text, made.must_text) == \
|
||||
("Building teams.", "Pure reporting.", "Permanent contract.")
|
||||
|
||||
kept = store.save_agent("Data", "data leadership", agent_id=made.id)
|
||||
assert (kept.cv_text, kept.avoid_text, kept.must_text) == \
|
||||
("VP Data.", "Pure reporting.", "Permanent contract.")
|
||||
assert (kept.cv_text, kept.like_text, kept.avoid_text, kept.must_text) == \
|
||||
("VP Data.", "Building teams.", "Pure reporting.", "Permanent contract.")
|
||||
assert len(kept.cv_languages) == 2
|
||||
|
||||
cleared = store.save_agent("Data", "data leadership", agent_id=made.id, cv_text="",
|
||||
cv_languages=[], avoid_text="", must_text="")
|
||||
assert (cleared.cv_text, cleared.cv_languages, cleared.avoid_text, cleared.must_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) == ("", [], "", "", "")
|
||||
|
||||
|
||||
def test_a_cv_language_is_a_code_and_a_level_of_the_ladder() -> None:
|
||||
@@ -93,7 +96,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]
|
||||
assert migrated.migrations_applied == [28, 29, 30]
|
||||
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)
|
||||
@@ -105,7 +108,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]
|
||||
assert Store(path).migrations_applied == [28, 29, 30]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- deadline
|
||||
@@ -246,12 +249,29 @@ 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]
|
||||
assert Store(path).migrations_applied == [29, 30]
|
||||
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]
|
||||
assert Store(path).migrations_applied == [29, 30]
|
||||
|
||||
|
||||
def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
|
||||
path = tmp_path / "v29.db"
|
||||
Store(path).save_agent("Data", "data leadership", avoid_text="Reporting.")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("ALTER TABLE agents DROP COLUMN like_text")
|
||||
conn.execute("PRAGMA user_version = 29")
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [30]
|
||||
[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]
|
||||
|
||||
|
||||
def test_the_musts_text_is_one_must_have_per_line() -> None:
|
||||
|
||||
@@ -261,7 +261,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]
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
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'"
|
||||
|
||||
@@ -434,7 +434,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]
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26, 27, 28, 29, 30]
|
||||
assert migrated.agents()[0].fetch_terms == []
|
||||
|
||||
|
||||
|
||||
+16
-1
@@ -75,7 +75,8 @@ def config(tmp_path: Path) -> Config:
|
||||
|
||||
def hunter(store: Store, name: str = "Data", cv: str = CV, **kwargs: Any) -> Any:
|
||||
return store.save_agent(name, prompts=[Prompt(name="AI lead", text="Head of AI")],
|
||||
cv_text=cv, avoid_text="Pure reporting.",
|
||||
cv_text=cv, like_text="Building teams.",
|
||||
avoid_text="Pure reporting.",
|
||||
must_text="A permanent contract.", **kwargs)
|
||||
|
||||
|
||||
@@ -109,6 +110,10 @@ def test_a_run_writes_the_judgement_and_its_total(
|
||||
[system] = model.systems
|
||||
assert CV in system and "Pure reporting." in system and "A permanent contract." in system
|
||||
assert "- AI lead: Head of AI" in system and "deal-breaker" in system
|
||||
assert '<likes title="what they like: work, workplace, situations">\nBuilding teams.' \
|
||||
in system
|
||||
assert '<dislikes title="what they do not like">\nPure reporting.' in system
|
||||
assert "<avoid" not in system
|
||||
|
||||
|
||||
def test_the_musts_are_numbered_in_the_profile_and_stored_with_their_text(
|
||||
@@ -163,6 +168,16 @@ 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_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,
|
||||
like_text="Small teams.")
|
||||
assert judge.input_key(liked, "text") != judge.input_key(owner, "text")
|
||||
assert "Small teams." in judge.system(liked) and "Building teams." not in judge.system(liked)
|
||||
assert "<likes" not in judge.system(
|
||||
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id, like_text=""))
|
||||
|
||||
|
||||
def hashlib_old_key(agent: Any, text: str) -> str:
|
||||
blob = json.dumps([agent.cv_text, [[p.name, p.text] for p in agent.prompts],
|
||||
agent.avoid_text, agent.must_text, text], ensure_ascii=False)
|
||||
|
||||
@@ -120,7 +120,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]
|
||||
assert migrated.migrations_applied == [24, 25, 26, 27, 28, 29, 30]
|
||||
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]
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
one = row(migrated, "1")
|
||||
assert (one["seniority_host"], one["employment_host"], one["remote_host"],
|
||||
one["country_host"]) == ("senior", "full_time", "true", "DK")
|
||||
|
||||
@@ -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]
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30]
|
||||
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]
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30]
|
||||
|
||||
|
||||
def test_a_role_waits_for_extract_until_it_was_asked_where(store: Store) -> None:
|
||||
|
||||
+10
-9
@@ -70,7 +70,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 == 29
|
||||
assert LATEST == 30
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -170,6 +170,7 @@ def test_a_v1_file_migrates_to_the_shape_a_new_file_has(tmp_path: Path) -> None:
|
||||
conn.execute(f"DROP TABLE {table}")
|
||||
for column in ("musts", "broken"): # v29
|
||||
conn.execute(f"ALTER TABLE role_judgements DROP COLUMN {column}")
|
||||
conn.execute("ALTER TABLE agents DROP COLUMN like_text") # v30
|
||||
conn.execute("PRAGMA user_version = 1")
|
||||
|
||||
assert Store(old).migrations_applied == list(range(2, LATEST + 1))
|
||||
@@ -189,7 +190,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]
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
|
||||
@@ -394,7 +395,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]
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
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]
|
||||
@@ -418,7 +419,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]
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
|
||||
@@ -447,7 +448,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]
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
|
||||
"SELECT uid, place_fold, seniority FROM roles")}
|
||||
@@ -690,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]
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
|
||||
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) == []
|
||||
@@ -732,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]
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30]
|
||||
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 "
|
||||
@@ -750,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]
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30]
|
||||
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]
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30]
|
||||
|
||||
|
||||
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
|
||||
|
||||
Reference in new issue
Block a user