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:
WolfandClaude Opus 5.5 committed 2026-10-04 15:11:43 +02:00
1 parent 060ccf66e6
commit 617356e60c
35 files changed
+1054 -751

No files matched your search

+22 -14
View File
@@ -14,7 +14,7 @@ import pytest
from app.config import Config
from app.jobs import judge, stages
from app.models import CvLanguage, Limits, Prompt
from app.models import CvLanguage, Prompt
from app.storage import Store
from desk import modeltask
from desk.models import Item
@@ -85,7 +85,8 @@ def ranked(store: Store, owner: Any, *ids: str) -> list[str]:
for sid in ids:
store.upsert_role(posting(sid))
uids.append(posting(sid).uid)
store.replace_scores(owner.id, [(uid, 0.9 - n / 100, "") for n, uid in enumerate(uids)])
store.replace_scores(owner.id, [(uid, 0.9 - n / 100, "", "", None, 0.9 - n / 100, "fit")
for n, uid in enumerate(uids)])
return uids
@@ -192,20 +193,27 @@ def test_only_enabled_agents_with_a_cv_and_a_prompt_are_judged(store: Store) ->
assert judge.waiting(store) == []
def test_the_agents_judge_limits_bound_what_is_read(store: Store) -> None:
owner = hunter(store, limits=Limits(judge_top=2, judge_min=0.885))
uids = ranked(store, owner, "a", "b", "c")
assert [row["uid"] for _, row, _, _ in judge.waiting(store)] == uids[:2]
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id,
limits=Limits(judge_top=2, judge_min=0.895))
assert [row["uid"] for _, row, _, _ in judge.waiting(store)] == uids[:1]
def test_the_agents_cut_is_what_is_read_by_fit_then_cv_then_kept(store: Store) -> None:
owner = hunter(store)
for sid in "abcdef":
store.upsert_role(posting(sid))
uid = {sid: posting(sid).uid for sid in "abcdef"}
store.replace_scores(owner.id, [
(uid["a"], 0.5, "", "", 0.9, 0.5, "kept"),
(uid["b"], 0.6, "", "", 0.7, 0.4, "cv"),
(uid["c"], 0.7, "", "", 0.1, 0.7, "fit"),
(uid["d"], 0.8, "", "", 0.1, 0.8, "fit"),
(uid["e"], 0.9, "", "", 0.9, 0.9, ""),
(uid["f"], 0.9, "", "", 0.8, 0.3, "cv")])
assert [row["uid"] for _, row, _, _ in judge.waiting(store)] == [
uid["d"], uid["c"], uid["f"], uid["b"], uid["a"]]
def test_a_role_without_text_is_not_judged(store: Store) -> None:
owner = hunter(store)
item = posting("empty", body="")
store.upsert_role(item)
store.replace_scores(owner.id, [(item.uid, 0.9, "")])
store.replace_scores(owner.id, [(item.uid, 0.9, "", "", None, 0.9, "fit")])
assert judge.waiting(store) == []
@@ -218,7 +226,7 @@ def test_a_judgement_is_read_again_only_when_what_it_read_changed(
assert judge.pending(store) == 0
# A rescore and the role closing leave it be.
store.replace_scores(owner.id, [(uid, 0.8, "")])
store.replace_scores(owner.id, [(uid, 0.8, "", "", None, 0.8, "fit")])
assert judge.pending(store) == 0
with store.transaction() as conn:
conn.execute("UPDATE roles SET closed_at = '2026-10-01' WHERE uid = ?", (uid,))
@@ -274,7 +282,7 @@ def test_a_batch_holds_one_agents_pairs_with_that_agents_profile(
first = hunter(store, "First", cv="First CV.")
second = hunter(store, "Second", cv="Second CV.")
shared = ranked(store, first, "a", "b")
store.replace_scores(second.id, [(uid, 0.9, "") for uid in shared])
store.replace_scores(second.id, [(uid, 0.9, "", "", None, 0.9, "fit") for uid in shared])
model = stub(monkeypatch)
modeltask.run(judge.TASK, config, store)
@@ -295,7 +303,7 @@ def test_the_finder_cuts_per_agent_and_finds_nothing_while_the_switch_is_off(
first = hunter(store, "First")
second = hunter(store, "Second")
uids = ranked(store, first, *"abcdefg")
store.replace_scores(second.id, [(uids[0], 0.9, "")])
store.replace_scores(second.id, [(uids[0], 0.9, "", "", None, 0.9, "fit")])
found = judge.judge_task().finder(config, store)
assert [len(b.payload["uids"]) for b in found] == [5, 2, 1]
assert found[0].label == "Judging 5 roles for First, 1 of 3"
@@ -309,7 +317,7 @@ def test_a_job_given_two_agents_keys_asks_once_for_each(
first = hunter(store, "First", cv="First CV.")
second = hunter(store, "Second", cv="Second CV.")
[uid] = ranked(store, first, "a")
store.replace_scores(second.id, [(uid, 0.9, "")])
store.replace_scores(second.id, [(uid, 0.9, "", "", None, 0.9, "fit")])
model = stub(monkeypatch)
result = judge.run_batch(config, store, uids=[f"{first.id}:{uid}", f"{second.id}:{uid}"])