From bf1e5f013b9d5a58b8df2294768a33c0222cf8e6 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Fri, 13 Nov 2026 20:35:28 +0000 Subject: [PATCH] unmapped backers: stop the phantom finding (the members query had no createdAt) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first production run reported a null-account node as an uncredited payer. The cause was in my port, not the data: the members query selected id-less, date-less nodes, so every null-account node fell into the date "" bucket, matched no same-day order, and was reported as unattributable — while the host-side script (correctly) said clean. Two fixes: select id + createdAt in fetch_all_member_nodes, and never emit a null-account finding when the node carries no date — there is nothing to attribute it against, and guessing is what produced the phantom. 27 checks in the suite. --- app/main.py | 12 +++++++++++- tests/test_unmapped_backers.py | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 5d31136..d19c6e1 100644 --- a/app/main.py +++ b/app/main.py @@ -1440,7 +1440,7 @@ async def fetch_all_member_nodes() -> list[dict]: for _ in range(20): # hard cap: 20 pages × 100 = 2000 members query = ( '{ collective(slug: "%s") { members(limit: 100, offset: %d) { ' - "totalCount nodes { role tier { name } account { name slug type ... on Individual { email } } } } } }" + "totalCount nodes { id role createdAt tier { name } account { name slug type ... on Individual { email } } } } } }" % (OC_COLLECTIVE_SLUG, offset) ) r = await _oc_graphql_post( @@ -8143,6 +8143,16 @@ async def reconcile_unmapped_backers(notify: bool = True) -> dict: # incognito-hidden). Attribute via same-day current orders; stay # silent when every same-day payer is already mapped. day = str(n.get("createdAt") or "")[:10] + if not day: + # Without the node's date there is nothing to attribute it + # against, and guessing here is how a phantom finding appears: + # the first run of this check reported a null-account node as + # uncredited while the node's day was unknown to us (the + # members query did not select createdAt at all). + logger.warning("unmapped-backer check: a member node carries no " + "createdAt; cannot attribute it (role=%s tier=%s)", + n.get("role"), (((n.get("tier") or {}) or {}).get("name"))) + continue current = [o for o in orders if str(o.get("createdAt") or "")[:10] == day and (o.get("status") or "") in CURRENT_ORDER_STATUS] diff --git a/tests/test_unmapped_backers.py b/tests/test_unmapped_backers.py index 25f2588..09be8a0 100644 --- a/tests/test_unmapped_backers.py +++ b/tests/test_unmapped_backers.py @@ -121,6 +121,11 @@ async def main(): node("BACKER", "Membership", account=False, created="2026-11-01T00:00:00Z"), # null-account node on a day with an UNMAPPED payer -> finding node("BACKER", "Membership", account=False, created="2026-11-02T00:00:00Z"), + # null-account node with NO date -> NOT a finding: there is nothing to + # attribute it against, and reporting it is how a phantom appears (the + # members query did not select createdAt, so every such node looked like an + # uncredited payer on the day ""). + {"role": "BACKER", "tier": {"name": "Membership"}, "createdAt": None, "account": None}, ] ORDERS[:] = [ order("alice", day="2026-11-01"), @@ -134,6 +139,8 @@ async def main(): 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("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"])