With an agent named, the rail's tag, company and place counts, Remote included, cover the roles that agent's feed shows, past its fetch gate; and the affinity note names the order What I'm looking for.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-10-05 09:35:32 +02:00
1 parent 0b92f19f4d
commit 8c3c51dd9f
4 files changed
+106 -35

No files matched your search

+5 -1
View File
@@ -15,7 +15,7 @@ import pytest
from desk.models import Item
from app import places, prep
from app.jobs import extract, reach
from app.jobs import extract, reach, score
from app.models import Agent, Gate
from app.places import Gazetteer, label, known, parse, seed, suggest
from app.prep import words
@@ -468,6 +468,10 @@ def test_the_api_suggests_labels_and_filters_the_remote_tokens(tmp_path: Path) -
prep.run(store, dupes=False)
agent = store.save_agent("Europe", "python backend", [
Gate(field="country", values=EUROPE, mode="require")])
# Scored as `score` would, since a named agent's counts are its feed's.
store.replace_scores(agent.id, [
(c.uid, 0.5, ", ".join(score.failed_gates(c, agent.gates)))
for c in store.score_candidates(agent.id, agent.gates)])
with TestClient(app) as client:
found = client.get("/api/suggest/places", params={"q": "remote"}).json()
assert found[0] == {"token": "remote:any", "label": "Remote", "kind": "remote",
+34 -1
View File
@@ -219,11 +219,44 @@ def test_suggest_companies_folds_the_name_and_leaves_out_the_hidden(
assert [c["name"] for c in suggest("big da")] == ["Big Data Corp"]
assert [c["name"] for c in suggest("data", limit=1)] == ["Big Data Corp"]
assert suggest("") == []
# Another agent hid nothing.
# Another agent hid nothing; named, it counts what its feed shows.
other = store.save_agent("B")
store.replace_scores(other.id, [(r.uid, 0.5, "") for r in store.roles()])
assert "Hidden Data" in [c["name"] for c in suggest("data", agent=other.id)]
def test_a_named_agents_rail_counts_are_what_its_feed_shows(
client: TestClient, store: Store) -> None:
"""Tag, company and place counts, "Remote" included, cover the roles the
feed lists for a named agent: past its fetch gate, of a company it has
not hidden. Without one they count as before."""
for sid in "1234":
upsert(store, posting(sid, company="Gone" if sid == "4" else "Acme",
place="Malmö", remote="remote"))
uid = {r.source_id: r.uid for r in store.roles()}
for one in uid.values():
store.set_tags(one, ["python"])
store.save_agent("Default")
agent = store.save_agent("A")
store.replace_scores(agent.id, [(uid["1"], 0.5, ""), (uid["2"], 0.4, ""),
(uid["3"], 0.0, "title sales"), (uid["4"], 0.3, "")])
store.set_affinity(agent.id, "gone", -1)
def counts(**params: Any) -> tuple[int, int, int, int]:
tags = client.get("/api/filters", params=params).json()["tags"]
[acme] = client.get("/api/suggest/companies", params={"q": "acme", **params}).json()
malmo = client.get("/api/suggest/places", params={"q": "malm", **params}).json()
remote = client.get("/api/suggest/places", params={"q": "remote", **params}).json()
return (tags[0]["count"], acme["count"],
next(s["count"] for s in malmo if s["token"] == "place:malmo"),
next(s["count"] for s in remote if s["token"] == "remote:any"))
feed = client.get("/api/roles", params={"agent": agent.id, "order": "newest"}).json()
assert feed["total"] == 2
assert counts(agent=agent.id) == (2, 2, 2, 2)
assert counts() == (4, 3, 4, 4)
def test_suggest_places_and_read_labels_back(client: TestClient, store: Store) -> None:
for sid, place in (("1", "Malmö"), ("2", "Malmö"), ("3", "Lund"),
("4", "København K"), ("5", "Kolding")):