diff --git a/src/vouch/digest.py b/src/vouch/digest.py index d7bae664..2043d9de 100644 --- a/src/vouch/digest.py +++ b/src/vouch/digest.py @@ -20,7 +20,7 @@ from typing import Any from .metrics import DEFAULT_STALE_DAYS, compute -from .models import ClaimStatus, ProposalStatus +from .models import ClaimStatus, PageStatus, ProposalStatus from .page_filters import filter_pages from .storage import KBStore @@ -179,8 +179,12 @@ def build( stale.sort(key=lambda pair: pair[0]) stale_rows = [row for _, row in stale[:limit]] + # archived pages are excluded for the same reason the stale loop above + # skips retired claims: a followup that has been archived is no longer + # something the reviewer is being asked to act on, and leaving it in the + # due list makes archiving decorative on the surface it matters most. due_pages = filter_pages( - store.list_pages(), + [p for p in store.list_pages() if p.status is not PageStatus.ARCHIVED], kind="followup", before={"due_at": now.date().isoformat()}, ) diff --git a/tests/test_digest.py b/tests/test_digest.py index 4d3eae40..7d4cea5d 100644 --- a/tests/test_digest.py +++ b/tests/test_digest.py @@ -146,6 +146,25 @@ def test_build_limit_caps_sections(store: KBStore) -> None: assert len(d.decisions) <= 1 +def test_build_excludes_archived_followups(tmp_path: Path) -> None: + # the stale-claims loop right above the followup query skips retired + # claims; the followup query has no status predicate, so archiving a + # followup page left it showing up as due forever. + s = KBStore.init(tmp_path) + due = (NOW - timedelta(days=2)).date().isoformat() + for pid, status in (("fu-live", PageStatus.ACTIVE), ("fu-archived", PageStatus.ARCHIVED)): + s.put_page( + Page( + id=pid, title=pid, type="followup", status=status, + metadata={"due_at": due, "followup_status": "open"}, + ) + ) + + d = digest_mod.build(s, now=NOW) + + assert [r.id for r in d.followups_due] == ["fu-live"] + + def test_build_limit_caps_followups(tmp_path: Path) -> None: # --limit documents that it caps every section including followups; seed # more due-open followups than the limit and confirm the list is bounded