Closer to Home: gate "Near you" on high/medium confidence (both modes)

Codex polish before deploy: anything elevated as Near you / Close to home must have
geo_confidence in (high, medium) — the feature's promise is relevance. Country-only
mode now gates "near" too; since it has no "country" tier, the "world" scope is
widened to absorb low-confidence home-country stories so they surface there instead
of vanishing between tiers (the same edge-case class, fixed). State mode unchanged.

364 tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jay
2026-06-19 20:29:31 -04:00
parent 3861ed4060
commit 2239549799
2 changed files with 26 additions and 7 deletions
+9 -4
View File
@@ -67,13 +67,18 @@ def test_sparse_near_folds_into_country(app_db):
assert "country" in _sections(r["items"]) # US stories still surface as your country
def test_country_only_home_has_no_country_tier(app_db):
def test_country_only_home_gates_near_on_confidence(app_db):
r = TestClient(app_db).get("/api/feed?home=US&limit=50").json()
secs = set(_sections(r["items"]))
items = r["items"]
secs = set(_sections(items))
assert "country" not in secs # no state -> near IS the whole country
assert secs <= {"near", "world"}
near_ids = {it["id"] for it in r["items"] if it["section"] == "near"}
assert near_ids == {1, 2, 3, 4, 5, 6, 7, 8} # all US (incl. the low-conf one, country match)
near_ids = {it["id"] for it in items if it["section"] == "near"}
# "Near you" requires high/medium confidence: high-conf US stories only, NOT the
# low-confidence US story (#5), which must still appear, in "world".
assert near_ids == {1, 2, 3, 4, 6, 7, 8}
a5 = next(it for it in items if it["id"] == 5)
assert a5["section"] == "world" # low-conf home-country -> world, not vanished
def test_no_home_is_unchanged_and_unsectioned(app_db):