reconcile: show a candidate's nearby ledger rows, so a manual grant isn't read as a gap
ci/woodpecker/push/woodpecker Pipeline was canceled

Widening the window to OC's whole order history found three $5 packs from
2026-09-28 reported as uncredited — ntnsndr's launch-day purchases, which WERE
credited by hand that morning: +20.00, +5.75, then a -10.75 correction ('true
contributions were 3 x $5.00'), netting exactly $15, with no per-order reference
on any row.

credit_pack_accounted() is right not to infer 'accounted for' from a nearby
amount — that would hide genuine gaps — but a reviewer could not tell the two
cases apart from the candidate alone. Each candidate now carries its nearby
ledger/held rows (7-day window, capped at 5) and the report-mode log line prints
them, so a manual grant explains itself. Nothing about the decision changes.

36 checks; all 18 suites green.
This commit is contained in:
inference-admin committed 2026-11-13 20:18:44 +00:00
1 parent d69c518b47
commit f2b6153aa6
2 files changed
+85 -4

No files matched your search

+33 -1
View File
@@ -106,7 +106,7 @@ async def fake_index():
raise Boom("member index unavailable")
return {e: {"slug": e.split("@")[0]} for e in
("alice@x.org", "bob@x.org", "carol@x.org", "dave@x.org",
"erin@x.org", "frank@x.org")}
"erin@x.org", "frank@x.org", "gina@x.org")}
BUDGET_PUSHES = []
@@ -264,6 +264,38 @@ async def main():
check(f"still one row for the order (got {len(ledger_rows())})",
len(ledger_rows()) == 4)
# ---------- a candidate must SHOW the nearby rows a human needs ----------
# A manual grant can be real and carry no per-order reference: ntnsndr's three
# launch-day $5 packs were credited as +20.00 then corrected by -10.75, netting
# exactly 3 x $5.00, with no reference on any row. The matcher must NOT read
# that as accounted for (that would hide real gaps), so the candidate has to
# carry enough context for a reviewer to tell the two apart.
seed()
conn = m.get_db()
conn.execute("INSERT INTO members (email, slug, active, account_type, credit_balance) "
"VALUES ('gina@x.org', 'gina', 1, 'member', 0)")
conn.execute("INSERT INTO credit_ledger (email, delta, reason, reference, created_at) "
"VALUES ('gina@x.org', 7.5, 'manual application', NULL, ?)", (stamp(0.5),))
conn.commit()
conn.close()
async def only_gina(per_page=100, max_pages=3):
return [order("or_GGG", "gina", 10, 0.5)]
saved_orders = m.fetch_collective_orders
m.fetch_collective_orders = only_gina
res = await m.reconcile_credit_packs(apply=False)
cand = (res.get("candidates") or [{}])[0]
check(f"an unreferenced nearby grant is SURFACED on the candidate "
f"(got {cand.get('nearby_book_rows')})",
any(abs(float(n["delta"]) - 7.5) < 0.01
for n in cand.get("nearby_book_rows") or []))
check("a nearby unreferenced grant does NOT count as accounted for",
len(res.get("candidates") or []) == 1)
check(f"the pass still leaves the money alone (got {balance('gina@x.org')})",
balance("gina@x.org") == 0.0)
m.fetch_collective_orders = saved_orders
# ---------- the endpoint -------------------------------------------------
# Re-seed: the direct apply above already credited carol, so the endpoint
# would have no candidate and the check would pass for the wrong reason.