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:
+31
-3
@@ -35,7 +35,7 @@ def conn():
|
||||
c.close()
|
||||
|
||||
|
||||
def _add(conn, article_id, vector, constructive, when="2026-05-30T10:00:00+00:00"):
|
||||
def _add(conn, article_id, vector, constructive, when="2026-05-30T10:00:00+00:00", accepted=1):
|
||||
conn.execute(
|
||||
"INSERT INTO articles (id, source_id, canonical_url, title, published_at, url_hash) "
|
||||
"VALUES (?, 1, ?, ?, ?, ?)",
|
||||
@@ -44,8 +44,8 @@ def _add(conn, article_id, vector, constructive, when="2026-05-30T10:00:00+00:00
|
||||
conn.execute(
|
||||
"INSERT INTO article_scores (article_id, constructive_score, agency_score, "
|
||||
"human_benefit_score, cortisol_score, ragebait_score, pr_risk_score, accepted) "
|
||||
"VALUES (?, ?, 0, 0, 0, 0, 0, 1)",
|
||||
(article_id, constructive),
|
||||
"VALUES (?, ?, 0, 0, 0, 0, 0, ?)",
|
||||
(article_id, constructive, accepted),
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO article_embeddings (article_id, vector, dim, model) VALUES (?, ?, ?, 'test')",
|
||||
@@ -69,6 +69,34 @@ def test_near_duplicates_collapse_to_highest_ranked(conn):
|
||||
assert dup_of[3] is None # C stands alone
|
||||
|
||||
|
||||
def test_accepted_member_beats_a_higher_quality_rejected_one(conn):
|
||||
# The rep must be SERVEABLE: an accepted page may never be retired to a rejected
|
||||
# representative (that page would 404 with nothing to 301 to). Accepted wins even
|
||||
# though the rejected twin scores higher on quality.
|
||||
_add(conn, 1, [1.0, 0.0, 0.0, 0.0], constructive=9, accepted=0) # higher quality, REJECTED
|
||||
_add(conn, 2, [0.99, 0.02, 0.0, 0.0], constructive=3, accepted=1) # lower quality, accepted
|
||||
cluster_duplicates(conn, threshold=0.86, window_days=3)
|
||||
dup_of = {r["id"]: r["duplicate_of"] for r in conn.execute("SELECT id, duplicate_of FROM articles")}
|
||||
assert dup_of[2] is None # the accepted article is the representative (serves 200)
|
||||
assert dup_of[1] == 2 # the rejected one points at it
|
||||
|
||||
|
||||
def test_established_rep_stays_stable_when_a_better_twin_arrives(conn):
|
||||
# An already-indexed canonical shouldn't churn just because a higher-quality near
|
||||
# duplicate shows up later. Establish 1 as rep (with follower 3), then a stronger 2
|
||||
# arrives — 1 must remain the representative for URL stability.
|
||||
_add(conn, 1, [1.0, 0.0, 0.0, 0.0], constructive=5)
|
||||
_add(conn, 3, [0.99, 0.01, 0.0, 0.0], constructive=1)
|
||||
cluster_duplicates(conn, threshold=0.86, window_days=3) # run 1: 1 is rep (score 5 > 1)
|
||||
assert conn.execute("SELECT duplicate_of FROM articles WHERE id=1").fetchone()[0] is None
|
||||
|
||||
_add(conn, 2, [0.995, 0.01, 0.0, 0.0], constructive=9) # higher quality newcomer
|
||||
cluster_duplicates(conn, threshold=0.86, window_days=3) # run 2
|
||||
dup_of = {r["id"]: r["duplicate_of"] for r in conn.execute("SELECT id, duplicate_of FROM articles")}
|
||||
assert dup_of[1] is None # incumbent stays canonical despite 2's higher score
|
||||
assert dup_of[2] == 1 and dup_of[3] == 1
|
||||
|
||||
|
||||
def test_distinct_articles_are_not_clustered(conn):
|
||||
_add(conn, 1, [1.0, 0.0, 0.0, 0.0], constructive=5)
|
||||
_add(conn, 2, [0.0, 1.0, 0.0, 0.0], constructive=5)
|
||||
|
||||
Reference in New Issue
Block a user