diff --git a/app/main.py b/app/main.py index b94eb6f..cbfda6d 100644 --- a/app/main.py +++ b/app/main.py @@ -9087,12 +9087,28 @@ UNMAPPED_BACKERS_MARKER = "unmapped_backers_fingerprint" def _oc_memberish(node: dict) -> bool: - """Mirror fetch_members()'s member definition (ADMIN, or Membership/legacy tier).""" + """Mirror fetch_members()'s member definition exactly. + + ADMIN, a BACKER on the Membership tier, or a LEGACY no-tier BACKER who + joined before LEGACY_NO_TIER_BEFORE. A no-tier BACKER who joined after that + cutoff is a plain DONATION: OC grants BACKER role for any one-time + contribution, but a donation is not a membership and has no account to + provision. Treating every no-tier BACKER as memberish made a $75 donation + from Workers.vc (2026-11-21) mail info@ as "a paid contributor with no + account" — a notice about a missing account that was never supposed to + exist. Only unattached credit packs keep a hold-and-notify path; a donation + is silent. + """ role = node.get("role") or "" if role not in ("BACKER", "ADMIN"): return False + if role == "ADMIN": + return True tier = (((node.get("tier") or {}) or {}).get("name") or "").strip() - return role == "ADMIN" or not tier or "membership" in tier.lower() + if "membership" in tier.lower(): + return True + joined = (node.get("createdAt") or "")[:10] + return bool(joined) and joined < LEGACY_NO_TIER_BEFORE async def reconcile_unmapped_backers(notify: bool = True) -> dict: diff --git a/tests/test_unmapped_backers.py b/tests/test_unmapped_backers.py index 09be8a0..112cc41 100644 --- a/tests/test_unmapped_backers.py +++ b/tests/test_unmapped_backers.py @@ -107,6 +107,14 @@ async def main(): node("ADMIN", "Membership", "adminco", "admin@x.org", name="Co-op"), # NOT a member: a credit-pack-only BACKER takes the held-credits path node("BACKER", "Credit pack", "packbuyer", "pack@x.org", name="Pack Buyer"), + # NOT a member: a plain DONATION (no tier, joined after the legacy cutoff). + # OC grants BACKER role for any one-time contribution; a donation must stay + # silent instead of mailing info@ about a "missing account". + node("BACKER", None, "donor", "donor@x.org", name="Donor", + created="2026-11-21T15:10:00Z"), + # FINDING: a LEGACY no-tier BACKER (before the tier system) IS a member + node("BACKER", None, "legacy", "legacy@x.org", name="Legacy", + created="2026-01-01T00:00:00Z"), # not a member role node("MEMBER", "Membership", "roleonly", "role@x.org", name="Role Only"), # FINDING: visible email -> the sweep should have provisioned this @@ -137,15 +145,19 @@ async def main(): res = await m.reconcile_unmapped_backers() check(f"the check runs (got {res.get('status')})", res.get("status") == "ok") classes = sorted(res.get("classes") or []) - check(f"four findings in three classes (got {res.get('findings')} {classes})", - res.get("findings") == 4 and classes == ["hidden", "null-account", "org", "visible"]) + check(f"five findings in four classes (got {res.get('findings')} {classes})", + res.get("findings") == 5 and classes == ["hidden", "null-account", "org", "visible"]) check("a node with no createdAt is NOT reported (nothing to attribute it against)", sum(1 for f in res["detail"] if f["class"] == "null-account") == 1) slugs = sorted(f["slug"] or "(null-account)" for f in res["detail"]) check(f"exactly the unmapped member-ish nodes are findings (got {slugs})", - slugs == ["(null-account)", "gammaorg", "han", "vic"]) + slugs == ["(null-account)", "gammaorg", "han", "legacy", "vic"]) check("a Credit-pack-only BACKER is not a member finding", not any(f["slug"] == "packbuyer" for f in res["detail"])) + check("a post-cutoff no-tier BACKER (a plain donation) is not a finding", + not any(f["slug"] == "donor" for f in res["detail"])) + check("a LEGACY no-tier BACKER is still a member finding", + any(f["slug"] == "legacy" for f in res["detail"])) check("a MEMBER-role node is not a member finding", not any(f["slug"] == "roleonly" for f in res["detail"])) vis = {f["slug"]: f["email_visibility"] for f in res["detail"]} @@ -170,7 +182,7 @@ async def main(): # Same set again: a report, but NO second email. res2 = await m.reconcile_unmapped_backers() check(f"the same finding set is not re-emailed (got {len(SENT)} emails)", - res2.get("findings") == 4 and res2.get("reported") is False and len(SENT) == 1) + res2.get("findings") == 5 and res2.get("reported") is False and len(SENT) == 1) # The set CHANGES (one finding resolved): mail again. NODES[:] = [n for n in NODES @@ -181,7 +193,7 @@ async def main(): # got shorter. Only genuinely NEW keys speak. check(f"a smaller set re-mails nobody (got {res3.get('findings')} findings, " f"{res3.get('new')} new, {len(SENT)} emails)", - res3.get("findings") == 3 and res3.get("new") == 0 and len(SENT) == 1) + res3.get("findings") == 4 and res3.get("new") == 0 and len(SENT) == 1) # Fully clear: silent, and the marker is cleared so a recurrence speaks up. NODES[:] = [node("BACKER", "Membership", "alice", "alice@x.org", name="Alice")]