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
+22
-30
@@ -15,7 +15,7 @@ from desk.models import Item
|
||||
from desk.tools import agent
|
||||
from app.config import Config
|
||||
from app.jobs import extract
|
||||
from app.models import LEVELS, Limits
|
||||
from app.models import LEVELS
|
||||
from app.storage import Store
|
||||
from prepped import upsert
|
||||
|
||||
@@ -61,11 +61,11 @@ def config(tmp_path: Path) -> Config:
|
||||
|
||||
|
||||
def ranked(store: Store, *items: Item) -> None:
|
||||
"""Score the roles for one enabled agent, best first, so they are in the
|
||||
top extract reads. Every role given must already be stored."""
|
||||
"""Score the roles for one enabled agent, best first, each in its cut, so
|
||||
extract reads them. Every role given must already be stored."""
|
||||
agents = store.agents()
|
||||
agent_id = agents[0].id if agents else store.save_agent("Backend", "python backend").id
|
||||
store.replace_scores(agent_id, [(item.uid, 1.0 - n / 10, "")
|
||||
store.replace_scores(agent_id, [(item.uid, 1.0 - n / 10, "", "", None, None, "fit")
|
||||
for n, item in enumerate(items)])
|
||||
|
||||
|
||||
@@ -167,37 +167,28 @@ def test_an_unknown_uid_is_ignored_and_the_role_left_out_is_charged(
|
||||
assert store.extract_pending() == 0, "given up after three unanswered replies"
|
||||
|
||||
|
||||
def test_only_the_best_of_each_agent_above_the_floor_is_read(
|
||||
def test_only_the_cut_of_an_enabled_agent_is_read(
|
||||
store: Store, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""The bound that keeps extract cheap: the top of an enabled agent's
|
||||
scores, as deep and as low as that agent's own `limits` say, whatever
|
||||
the boards produced. A role nobody ranks is never sent; a batch dealt a
|
||||
uid finishes it."""
|
||||
for sid in ("best", "second", "low", "unscored", "gated"):
|
||||
"""The bound that keeps extract cheap: the cut of an enabled agent,
|
||||
whatever the boards produced. A role in no cut is never sent; a batch
|
||||
dealt a uid finishes it."""
|
||||
for sid in ("best", "kept", "low", "unscored", "gated"):
|
||||
upsert(store, posting(sid))
|
||||
one = store.save_agent("One", "python backend",
|
||||
limits=Limits(extract_top=1, extract_min=0.5))
|
||||
one = store.save_agent("One", "python backend")
|
||||
two = store.save_agent("Two", "python backend", enabled=False)
|
||||
store.replace_scores(one.id, [(posting("best").uid, 0.9, ""),
|
||||
(posting("second").uid, 0.8, ""),
|
||||
(posting("low").uid, 0.2, ""),
|
||||
(posting("gated").uid, 0.95, "country unknown")])
|
||||
store.replace_scores(two.id, [(posting("unscored").uid, 0.99, "")])
|
||||
store.replace_scores(one.id, [(posting("best").uid, 0.9, "", "", None, 0.9, "fit"),
|
||||
(posting("kept").uid, 0.3, "", "", None, 0.1, "kept"),
|
||||
(posting("low").uid, 0.2, "", "", None, 0.2, ""),
|
||||
(posting("gated").uid, 0.0, "country unknown")])
|
||||
store.replace_scores(two.id, [(posting("unscored").uid, 0.99, "", "", None, 0.99, "fit")])
|
||||
config = Config(database=str(tmp_path / "x.db"), extract={"enabled": True})
|
||||
model = stub(monkeypatch, lambda roles: [answer(r["uid"]) for r in roles])
|
||||
|
||||
assert store.extract_pending() == 1
|
||||
store.save_agent("One", "python backend", agent_id=one.id,
|
||||
limits=Limits(extract_top=5, extract_min=0.5))
|
||||
assert store.extract_pending() == 2, "the floor holds the low one back"
|
||||
store.save_agent("One", "python backend", agent_id=one.id,
|
||||
limits=Limits(extract_top=5, extract_min=0))
|
||||
assert store.extract_pending() == 3, "the disabled agent's pick never counts"
|
||||
store.save_agent("One", "python backend", agent_id=one.id,
|
||||
limits=Limits(extract_top=1, extract_min=0.5))
|
||||
assert store.extract_pending() == 2, "the disabled agent's cut never counts"
|
||||
modeltask.run(extract.TASK, config, store)
|
||||
|
||||
assert [[r["uid"] for r in batch] for batch in model.asked] == [[posting("best").uid]]
|
||||
assert [[r["uid"] for r in batch] for batch in model.asked] == [
|
||||
[posting("best").uid, posting("kept").uid]]
|
||||
assert [r.uid for r in store.extract_waiting(10, uids=[posting("low").uid])] == \
|
||||
[posting("low").uid], "a dealt uid is read whatever its rank"
|
||||
|
||||
@@ -293,9 +284,10 @@ def test_each_agents_best_come_first_then_the_rest(store: Store) -> None:
|
||||
upsert(store, item)
|
||||
one = store.save_agent("One", "python backend")
|
||||
two = store.save_agent("Two", "python backend")
|
||||
store.replace_scores(one.id, [(items[0].uid, 0.9, ""), (items[1].uid, 0.8, ""),
|
||||
(items[2].uid, 0.7, "")])
|
||||
store.replace_scores(two.id, [(items[3].uid, 0.6, "")])
|
||||
store.replace_scores(one.id, [(items[0].uid, 0.9, "", "", None, None, "fit"),
|
||||
(items[1].uid, 0.8, "", "", None, None, "fit"),
|
||||
(items[2].uid, 0.7, "", "", None, None, "cv")])
|
||||
store.replace_scores(two.id, [(items[3].uid, 0.6, "", "", None, None, "kept")])
|
||||
|
||||
got = [r.uid for r in store.extract_waiting(10)]
|
||||
|
||||
|
||||
Reference in new issue
Block a user