recency_guard module + wired propagate_stack_now + top20 (Tony 2026-07-13)

This commit is contained in:
Epictetus
2026-07-13 21:38:32 +00:00
parent 2dfa3a9708
commit 7e33ffd36f
6 changed files with 2183 additions and 2178 deletions
+19 -17
View File
@@ -201,22 +201,22 @@ def _get_half_life(item):
# spec, shorter than evergreen). Covers both manual curations and
# auto-classified section items, so a section link persists 14 days
# instead of sinking in ~18h. Beyond this window the item is routed to
# Archive (generator).
ms = (item.get("manual_section") or "").upper()
if ms in ("HARDWARE", "TIPS"):
return 336.0
sec = (item.get("computed_section") or "").upper()
if sec in ("HARDWARE", "TIPS"):
return 336.0
tier = item.get("tier", "normal")
# Tier overrides take precedence
if tier == "breaking":
return CATEGORY_HALF_LIVES["breaking"]
if tier == "update":
return CATEGORY_HALF_LIVES["update"]
# Otherwise use content_type
ct = item.get("content_type", "OTHER")
return CATEGORY_HALF_LIVES.get(ct, CATEGORY_HALF_LIVES["OTHER"])
def _get_half_life(item):
"""Return section/tier-specific half-life in hours, or None to fall back
to decay_index's half_life_h argument (default 18h news half-life)."""
# Spec v1 addendum: Hardware/Tips section items get a 14-day (336h)
# half-life so curated/section items persist far longer in-section.
ms = (item.get("manual_section") or "").upper()
if ms in ("HARDWARE", "TIPS"):
return 336.0
tier = item.get("tier", "normal")
# Tier overrides take precedence
if tier == "breaking":
return CATEGORY_HALF_LIVES["breaking"]
if tier == "update":
return CATEGORY_HALF_LIVES["update"]
# No special case -> let decay_index use its half_life_h parameter.
return None
def decay_index(items, half_life_h=18.0):
@@ -235,8 +235,10 @@ def decay_index(items, half_life_h=18.0):
age = _age_hours(it)
it["age_hours"] = round(age, 1)
base = it.get("clickability", 0) or 0
# Category-specific half-life
# Category-specific half-life, falling back to the passed half_life_h
hl = _get_half_life(it)
if hl is None:
hl = half_life_h
k = math.log(2) / hl
it["clickability_decayed"] = round(base * math.exp(-k * age), 4)
it["effective_half_life"] = hl