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
+32
-27
@@ -218,34 +218,39 @@ def window(store: Store) -> list[str]:
|
||||
return [row["uid"] for _, row, _, _ in judge.waiting(store)]
|
||||
|
||||
|
||||
def test_the_judge_also_reads_the_closest_to_the_cv_the_score_leaves_out(
|
||||
store: Store) -> None:
|
||||
owner = store.save_agent("Data", prompts=[Prompt(name="AI", text="Head of AI")],
|
||||
cv_text="VP Data.",
|
||||
limits=Limits(judge_top=2, judge_min=0.5, judge_cv_top=2))
|
||||
top, second, low, near, nearer, nearest_gated, far = ranked(store, owner, [
|
||||
("top", 0.9, "", 0.1), ("second", 0.8, "", 0.99), ("low", 0.4, "", 0.2),
|
||||
("near", 0.3, "", 0.6), ("nearer", 0.2, "", 0.7), ("gated", 0.0, "country SE", None),
|
||||
("far", 0.1, "", 0.05)])
|
||||
assert window(store) == [top, second, nearer, near]
|
||||
def test_the_cut_takes_the_closest_to_the_cv_the_fit_list_leaves_out_and_judge_reads_it(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
"""One role in by fit to the prompt, the one closest to the CV that the
|
||||
fit list leaves out by CV closeness, a liked one kept; a gated role is in
|
||||
no list however close, liked or not."""
|
||||
backend = role(store, "1", "Backend Python", "Backend python python.", country="DK")
|
||||
frontend = role(store, "2", "Frontend React", "Frontend react react.", country="DK")
|
||||
data = role(store, "3", "Data", "Data.", country="DK")
|
||||
other = role(store, "4", "Data again", "Data data.", country="DK")
|
||||
gated = role(store, "5", "Frontend React", "Frontend react react.", country="SE")
|
||||
owner = store.save_agent("Data", prompts=[Prompt(name="Backend", text="python backend")],
|
||||
gates=[Gate(field="country", values=["DK"])],
|
||||
cv_text="Frontend react developer.",
|
||||
limits=Limits(cut_fit_top=1, cut_fit_min=0, cut_cv_top=1,
|
||||
cut_cv_min=0))
|
||||
store.set_vote(owner.id, data, 1)
|
||||
store.set_vote(owner.id, gated, 1)
|
||||
run(config, store, embed.run_embed)
|
||||
result = run(config, store, score.run_score)
|
||||
|
||||
assert store.cut(owner.id) == {backend: "fit", frontend: "cv", data: "kept"}
|
||||
assert result["cut"] == 3
|
||||
with store.transaction() as conn:
|
||||
fits = dict(conn.execute("SELECT uid, fit FROM scores WHERE agent_id = ?",
|
||||
(owner.id,)).fetchall())
|
||||
assert fits[backend] > fits[other] and fits[gated] is None
|
||||
assert window(store) == [backend, frontend, data]
|
||||
|
||||
# No count, no list: what is liked is kept all the same.
|
||||
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id,
|
||||
limits=Limits(judge_top=2, judge_min=0.85, judge_cv_top=2))
|
||||
assert window(store) == [top, second, nearer], \
|
||||
"a role under the bar is no part of the first set, so it may come in by the CV"
|
||||
|
||||
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id,
|
||||
limits=Limits(judge_top=2, judge_min=0.5, judge_cv_top=0))
|
||||
assert window(store) == [top, second]
|
||||
assert low and far and nearest_gated
|
||||
|
||||
|
||||
def test_a_gated_role_stays_out_of_the_window_however_close(store: Store) -> None:
|
||||
owner = store.save_agent("Data", prompts=[Prompt(name="AI", text="Head of AI")],
|
||||
cv_text="VP Data.",
|
||||
limits=Limits(judge_top=1, judge_min=0.5, judge_cv_top=5))
|
||||
top, _gated = ranked(store, owner, [("top", 0.9, "", 0.1), ("gated", 0.0, "remote", 1.0)])
|
||||
assert window(store) == [top]
|
||||
gates=owner.gates, limits=Limits(cut_fit_top=0, cut_cv_top=0))
|
||||
run(config, store, score.run_score)
|
||||
assert store.cut(owner.id) == {data: "kept"}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------- order
|
||||
@@ -277,7 +282,7 @@ def test_migration_31_adds_the_column_and_the_table_and_runs_twice(tmp_path: Pat
|
||||
conn.execute("DROP TABLE agent_cv_vectors")
|
||||
conn.execute("ALTER TABLE scores DROP COLUMN cv_fit")
|
||||
conn.execute("PRAGMA user_version = 30")
|
||||
assert Store(path).migrations_applied == [31]
|
||||
assert Store(path).migrations_applied == [31, 32]
|
||||
step = {v: s for v, _, s in MIGRATIONS}[31]
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert callable(step)
|
||||
|
||||
Reference in new issue
Block a user