Offer only the remote tokens within the asking agent's scope, so an agent kept to Europe is not offered Remote · United States

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 16:27:09 +02:00
1 parent 5c3c187dca
commit 9e2631ffe3
3 files changed
+44 -9

No files matched your search

+21
View File
@@ -425,6 +425,25 @@ def test_remote_is_suggested_after_remote_any_and_before_the_regions(
assert shown("re") == [t for t in shown("re") if t[1] != "remote:any"]
def test_an_agent_kept_to_europe_is_offered_only_remote_tokens_in_europe(
store: Store, roles: dict[str, str]) -> None:
gaz = store.gazetteer()
europe = {gaz.by_key[("continent", "europe")]}
denmark = {gaz.by_key[("country", "DK")]}
def tokens(q: str, scope: set[int]) -> list[str]:
return [s.token for s in suggest(q, store.open_places(), 50,
remote=store.open_remote_areas(), gaz=gaz, scope=scope)
if s.kind == "remote"]
assert "remote:country:US" in tokens("remote", set())
assert "remote:country:US" not in tokens("remote", europe)
assert "remote:country:EU" in tokens("remote", europe)
assert "remote:country:DK" in tokens("remote den", europe)
# A scope of one country still offers the wider places it lies in.
assert tokens("remote", denmark) == ["remote:country:EU", "remote:country:DK"]
def test_a_suggested_remote_token_finds_the_roles_it_counted(
store: Store, roles: dict[str, str]) -> None:
gaz = store.gazetteer()
@@ -457,6 +476,8 @@ def test_the_api_suggests_labels_and_filters_the_remote_tokens(tmp_path: Path) -
"count": 1} in found
other = client.get("/api/suggest/places", params={"q": "remote", "agent": agent.id})
assert other.json()[0]["count"] == 2
tokens = [s["token"] for s in other.json()]
assert "remote:country:EU" in tokens and "remote:country:US" not in tokens
labels = client.get("/api/places/labels", params=[
("tokens", "remote:country:DK"), ("tokens", "remote:anywhere"),
("tokens", "remote:country:ZZ")]).json()