Rank by the cut: fetch gate overrides in scoring, the cut per agent, stages read the cut, fetch text renamed from enrich, the feed kept to the fetch gate, and migration 32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
060ccf66e6
commit
617356e60c
35 files changed
+1054
-751
No files matched your search
+42
-39
@@ -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 == 31
|
||||
assert LATEST == 32
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -190,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, 30, 31]
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
|
||||
@@ -395,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, 30, 31]
|
||||
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.agent(backend.id).prompts == [ # type: ignore[union-attr]
|
||||
Prompt(name="Backend", text="python backend")]
|
||||
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
|
||||
@@ -419,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, 30, 31]
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
|
||||
@@ -448,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, 30, 31]
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
|
||||
"SELECT uid, place_fold, seniority FROM roles")}
|
||||
@@ -494,22 +494,21 @@ def test_prompts_are_saved_replaced_reordered_and_deleted(store: Store) -> None:
|
||||
assert conn.execute("SELECT COUNT(*) FROM agent_prompts").fetchone()[0] == 0
|
||||
|
||||
|
||||
def test_an_agent_whose_prompts_are_all_empty_feeds_neither_model_stage(
|
||||
def test_an_agent_whose_prompts_are_all_empty_does_not_choose_what_summarise_reads(
|
||||
store: Store) -> None:
|
||||
upsert(store, posting("a"))
|
||||
upsert(store, posting("b"))
|
||||
a, b = posting("a").uid, posting("b").uid
|
||||
top = Limits(extract_top=1, extract_min=0, summarise_top=1, summarise_min=0)
|
||||
top = Limits(summarise_top=1)
|
||||
blank = store.save_agent("Blank", limits=top,
|
||||
prompts=[Prompt(name="One"), Prompt(name="Two", text=" \n")])
|
||||
store.replace_scores(blank.id, [(a, 0.9, "")])
|
||||
assert store.extract_waiting(10) == [] and store.summarise_waiting(10) == []
|
||||
store.replace_scores(blank.id, [(a, 0.9, ""), (b, 0.8, "")])
|
||||
assert store.summarise_waiting(10) == []
|
||||
|
||||
# One prompt with text is enough.
|
||||
store.save_agent("Blank", agent_id=blank.id, limits=top,
|
||||
prompts=[Prompt(name="One"), Prompt(name="Two", text="python")])
|
||||
assert [r.uid for r in store.extract_waiting(10)] == [a]
|
||||
assert b not in {r.uid for r in store.summarise_waiting(10)}
|
||||
assert [r.uid for r in store.summarise_waiting(10)] == [a]
|
||||
|
||||
|
||||
def test_state_is_a_mapping(store: Store) -> None:
|
||||
@@ -691,7 +690,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]
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
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 +732,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]
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32]
|
||||
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 +750,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]
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32]
|
||||
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]
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32]
|
||||
|
||||
|
||||
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
|
||||
@@ -1277,21 +1276,34 @@ def test_votes_are_per_agent(store: Store) -> None:
|
||||
|
||||
def test_roles_with_an_agent_but_not_by_score_are_newest_first_with_votes(
|
||||
store: Store, clock: Clock) -> None:
|
||||
for sid in ("1", "2", "3"):
|
||||
for sid in ("1", "2", "3", "4"):
|
||||
upsert(store, posting(sid))
|
||||
clock.tick()
|
||||
uid = {r.source_id: r.uid for r in store.roles()}
|
||||
agent = store.save_agent("A")
|
||||
store.replace_scores(agent.id, [(uid["1"], 0.9, ""), (uid["2"], 0.1, "")]) # 3 unscored
|
||||
store.replace_scores(agent.id, [(uid["1"], 0.9, ""), (uid["2"], 0.1, ""),
|
||||
(uid["4"], 0.0, "country not DK")]) # 3 unscored
|
||||
store.set_vote(agent.id, uid["1"], 1)
|
||||
|
||||
newest = store.roles(agent=agent.id, by_score=False)
|
||||
assert [r.source_id for r in newest] == ["3", "2", "1"]
|
||||
assert [r.score for r in newest] == [None, None, None]
|
||||
assert [r.vote for r in newest] == [None, None, 1]
|
||||
assert store.count_roles(agent=agent.id, by_score=False) == 3
|
||||
assert [r.source_id for r in newest] == ["4", "3", "2", "1"]
|
||||
assert [r.score for r in newest] == [None, None, None, None]
|
||||
assert [r.vote for r in newest] == [None, None, None, 1]
|
||||
assert store.count_roles(agent=agent.id, by_score=False) == 4
|
||||
assert [r.source_id for r in store.roles(agent=agent.id)] == ["1", "2"]
|
||||
|
||||
# Kept to the agent's fetch gate, newest lists only what it scored and
|
||||
# passed, as the score order does; `gated` shows the rest with the reason.
|
||||
fenced = store.roles(agent=agent.id, by_score=False, fetch_gate=True)
|
||||
assert [r.source_id for r in fenced] == ["2", "1"]
|
||||
assert [r.score for r in fenced] == [None, None]
|
||||
assert store.count_roles(agent=agent.id, by_score=False, fetch_gate=True) == 2
|
||||
page = store.roles_page(agent=agent.id, by_score=False, fetch_gate=True, gated=True)
|
||||
assert [(r.uid, r.gated_reason) for r in page] == [
|
||||
(uid["4"], "country not DK"), (uid["2"], ""), (uid["1"], "")]
|
||||
assert store.count_roles(agent=agent.id, by_score=False, fetch_gate=True,
|
||||
gated=True) == 3
|
||||
|
||||
|
||||
def test_read_state_is_set_cleared_and_a_vote_marks_read(
|
||||
store: Store, clock: Clock) -> None:
|
||||
@@ -1738,39 +1750,30 @@ def test_a_summarys_tags_land_with_it_and_not_on_a_rejected_late_answer(
|
||||
|
||||
def test_summarise_waits_on_the_top_of_each_enabled_agent_by_its_own_limits(
|
||||
store: Store) -> None:
|
||||
"""Each agent contributes its own top, as deep and as low as its own
|
||||
`limits` say; a closed role and a gated score are in nobody's top. A
|
||||
"""Each agent contributes the top of its feed, its best `summarise_top`
|
||||
final scores; a closed role and a gated score are in nobody's top. A
|
||||
hidden company needs no case: `score` writes no rows for it under the
|
||||
agent that hid it. An agent saved before v8 has `limits` of '{}', which
|
||||
reads as the defaults."""
|
||||
agent that hid it. `limits` of '{}' reads as the defaults."""
|
||||
for sid in "abcd":
|
||||
upsert(store, posting(sid))
|
||||
a, b, c, d = (posting(s).uid for s in "abcd")
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET closed_at = ? WHERE uid = ?", (store.now(), d))
|
||||
one = store.save_agent("One", "python backend",
|
||||
limits=Limits(summarise_top=1, summarise_min=0))
|
||||
two = store.save_agent("Two", "python backend",
|
||||
limits=Limits(summarise_top=1, summarise_min=0))
|
||||
one = store.save_agent("One", "python backend", limits=Limits(summarise_top=1))
|
||||
two = store.save_agent("Two", "python backend", limits=Limits(summarise_top=1))
|
||||
store.replace_scores(one.id, [(d, 0.99, ""), (a, 0.9, ""), (b, 0.5, "")])
|
||||
store.replace_scores(two.id, [(a, 0.95, "remote"), (c, 0.7, ""), (b, 0.8, "")])
|
||||
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b}
|
||||
|
||||
# Two goes deeper: its second, c, joins; One's second, b, was in already.
|
||||
store.save_agent("Two", "python backend", agent_id=two.id,
|
||||
limits=Limits(summarise_top=2, summarise_min=0))
|
||||
store.save_agent("Two", "python backend", agent_id=two.id, limits=Limits(summarise_top=2))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b, c}
|
||||
assert store.summarise_pending() == 3
|
||||
assert [r.uid for r in store.summarise_waiting(10, uids=[d])] == [d]
|
||||
# The floor is Two's own: c at 0.7 drops, One's b at 0.5 stays.
|
||||
store.save_agent("Two", "python backend", agent_id=two.id,
|
||||
limits=Limits(summarise_top=2, summarise_min=0.75))
|
||||
store.save_agent("One", "python backend", agent_id=one.id,
|
||||
limits=Limits(summarise_top=2, summarise_min=0))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b}
|
||||
# '{}' is the defaults, 30 at 0.65: One's b at 0.5 drops, but Two's b at
|
||||
# 0.8 and c at 0.7 clear it.
|
||||
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.
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE agents SET limits = '{}'")
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b, c}
|
||||
|
||||
Reference in new issue
Block a user