Score roles per search agent, and run pull into extract, embed and score

embed stores one vector per open role; score rates every open role for
every enabled agent from require and prefer gates, fit against the
agent's intent, recency and company affinity, keeping gated rows with a
reason. Schema v3 adds vectors and the cached intent vector. The page
gets an agent order, the score on each row, and an Agents tab. Two
starter agents in roles.yaml are imported once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-23 12:14:21 +02:00
1 parent 4dfb8831aa
commit bc60324fab
22 files changed
+1457 -44

No files matched your search

+46
View File
@@ -203,3 +203,49 @@ def test_index_renders_the_shell(client: TestClient) -> None:
assert "roledesk" in res.text
assert 'id="roles-list"' in res.text
assert "<desk-jobs>" in res.text
# ------------------------------------------------------------------ agents
def test_agents_are_created_updated_listed_and_deleted(client: TestClient) -> None:
body = {"name": "Berlin", "intent": "python backend",
"gates": [{"field": "place", "values": ["Berlin"], "mode": "require"}]}
created = client.post("/api/agents", json=body)
assert created.status_code == 200
agent = created.json()
assert agent["weights"] == {"fit": 0.6, "recency": 0.2, "affinity": 0.2}
assert agent["gates"][0]["weight"] == 1.0
updated = client.post("/api/agents", json={**body, "id": agent["id"], "enabled": False,
"weights": {"fit": 1, "recency": 0,
"affinity": 0}})
assert updated.json()["enabled"] is False and updated.json()["weights"]["fit"] == 1
assert [a["name"] for a in client.get("/api/agents").json()] == ["Berlin"]
assert client.post("/api/agents", json=body).status_code == 409
assert client.delete(f"/api/agents/{agent['id']}").status_code == 204
assert client.get("/api/agents").json() == []
assert client.delete(f"/api/agents/{agent['id']}").status_code == 404
def test_a_gate_on_an_unknown_field_is_refused(client: TestClient) -> None:
body = {"name": "Bad", "gates": [{"field": "salary", "values": [1]}]}
assert client.post("/api/agents", json=body).status_code == 422
def test_roles_by_agent_are_ordered_by_score_and_hide_the_gated(
client: TestClient, store: Store) -> None:
for sid in ("low", "high", "gated"):
store.upsert_role(posting(sid))
uids = {r.source_id: r.uid for r in store.roles()}
agent = store.save_agent("A")
store.replace_scores(agent.id, [(uids["low"], 0.2, ""), (uids["high"], 0.8, ""),
(uids["gated"], 0.0, "place unknown")])
shown = client.get(f"/api/roles?agent={agent.id}").json()
assert [r["source_id"] for r in shown] == ["high", "low"]
assert shown[0]["score"] == 0.8
everything = client.get(f"/api/roles?agent={agent.id}&gated=1").json()
assert everything[-1]["gated_reason"] == "place unknown"
assert client.get("/api/roles").json()[0]["score"] is None
assert client.get("/api/roles?agent=999").status_code == 404