Sync repo to deployed state: SEO recovery, Publishing Desk, Play games, emoji picker
The deploy pipeline runs from the working tree, so a wave of shipped features
had never been committed. This snapshots git to what's actually running.
SEO impression recovery (live + verified):
- Duplicate /a/{id} now 301-redirect to their canonical twin instead of 404
(a hard 404 silently dropped already-indexed URLs and tanked impressions).
- Dedup representative selection reworked: accepted/serveable -> established
rep (URL stability) -> quality score, so an accepted page never retires to a
rejected rep and an indexed canonical doesn't churn when a newer twin arrives.
- HEAD /a/{id} returns the same status as GET (api_route GET+HEAD) instead of
falling through to the static mount and 404ing.
- `dedup --force-recluster`: cycle-locked, model-free re-cluster to re-apply the
policy to the existing corpus (shared cycle_lock context manager).
- CLI honors GOODNEWS_DB for its default --db (was silently ignored).
Publishing Desk (admin tool to post highlights to X via Web Intents):
- publishing.py queue/rank/handle-resolution; admin UI; full searchable emoji
picker (bundled data, no CDN) for the blurb editor.
Play games + site:
- Bloom (word-wheel), Memory Match, daily ritual set, Zen Den (dev-gated).
- English-only language gate; source prospecting; paywall + dedup hardening.
Tests: full suite green (349). Ignores tightened (node_modules, data/*.db).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -114,3 +114,27 @@ def test_brief_cache_boundary(client):
|
||||
assert "public" in client.get("/api/brief").headers.get("cache-control", "")
|
||||
assert client.get("/api/brief", params={"prefs": json.dumps({"mute_topics": ["health"]})}).headers.get("cache-control") == "private, no-store"
|
||||
assert client.get("/api/brief", params={"exclude": "3"}).headers.get("cache-control") == "private, no-store"
|
||||
|
||||
|
||||
def test_search_relevance_source_and_boundaries(client):
|
||||
import os, sqlite3, json as _j
|
||||
# A distinctively-named source proves source-name matching (the NYT use case).
|
||||
c = sqlite3.connect(os.environ["GOODNEWS_DB"])
|
||||
c.execute("INSERT INTO sources (id,name,feed_url,trust_score) VALUES (2,'Nature Digest','http://n/f',7)")
|
||||
c.execute("INSERT INTO articles (id,source_id,canonical_url,title,published_at,url_hash) "
|
||||
"VALUES (3,2,'http://n/3','Coral reefs rebound','2026-05-30T10:00:00+00:00','h3')")
|
||||
c.execute("INSERT INTO article_scores (article_id,accepted,topic,flavor) VALUES (3,1,'environment','hopeful')")
|
||||
c.commit(); c.close()
|
||||
# title match (index builds lazily on first search)
|
||||
assert client.get("/api/search?q=coral").json()["items"][0]["id"] == 3
|
||||
# SOURCE-NAME match — searching the publication finds its articles (Codex's requirement)
|
||||
assert 3 in [it["id"] for it in client.get("/api/search?q=nature").json()["items"]]
|
||||
# empty / junk query → empty, no error
|
||||
assert client.get("/api/search?q=").json()["count"] == 0
|
||||
assert client.get("/api/search?q=%20%21%21").json()["count"] == 0
|
||||
# boundary: a muted topic is excluded from search too (mirrors the visitor view)
|
||||
muted = client.get("/api/search", params={"q": "coral", "prefs": _j.dumps({"mute_topics": ["environment"]})}).json()
|
||||
assert muted["count"] == 0
|
||||
# boundary: a hard avoid-term filters a textual match
|
||||
avoided = client.get("/api/search", params={"q": "election", "prefs": _j.dumps({"avoid_terms": ["election"]})}).json()
|
||||
assert all(it["id"] != 2 for it in avoided["items"])
|
||||
|
||||
Reference in New Issue
Block a user