From 231ef3411ae40a4605b93cb2bae1e47c81365840 Mon Sep 17 00:00:00 2001 From: siddharthd Date: Wed, 12 Aug 2026 18:26:24 +1000 Subject: [PATCH] orders: record why line items may not exempt a row from the phantom filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Board 219 nulled 263 unstated zero totals in the spine, which moved 149 rows into the lifecycle-only hide predicate — they had been failing its "no amount" test on a technicality, an unstated 0 they should never have carried, while matching the phantom signature on every other count. Tried exempting rows that carry line items, on the theory that naming what was bought proves a purchase. It surfaced 442 rows and the first window checked showed why it is wrong: the Amazon "Ordered:" mail that mints a msg- phantom carries the item list too, so Xelsluthe and YIWENTEC each rendered TWICE again — the exact complaint this page was fixed for today. Reverted, and the reason recorded in place so it is not re-attempted. Items do not separate an orphan purchase from an item-carrying echo. Only deduplication does, and that is board 210. No behaviour change from the previous commit; comments and counts only. --- src/lib/order-feed.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/order-feed.ts b/src/lib/order-feed.ts index a42ad44..21c2629 100644 --- a/src/lib/order-feed.ts +++ b/src/lib/order-feed.ts @@ -103,8 +103,13 @@ export interface OrderFilters { * Rows with no amount, no order reference and a single lifecycle event are not * purchases — they are a second entity minted from a mail describing an order * that already exists (Amazon "share your experience", DoorDash no-contact - * delivery details, shipment notices). 755 of them; hiding lifts amount - * coverage from 74% to 84%. + * delivery details, shipment notices). 904 of them as of 2026-08-12. + * + * It hid 755 when written. Board 219's zero-to-null repair took it to 904: + * those 149 rows had been failing the "no amount" test on a technicality — an + * unstated 0 they should never have carried — and they match the phantom + * signature on every other count, so hiding them is the predicate working, not + * collateral damage. * * This is a WORKAROUND for board 210, not a fix. The upstream defect is that a * lifecycle mail printing no order reference cannot join its own order, so it @@ -114,6 +119,14 @@ export interface OrderFilters { const LIFECYCLE_ONLY = `NOT ( f.order_total IS NULL AND f.reference_source = 'message_id_fallback' + -- TRIED AND REVERTED, 2026-08-12: exempting rows that carry line items, on + -- the theory that naming what was bought proves a purchase. It surfaced 442 + -- rows and the very first window showed why it is wrong — the Amazon + -- "Ordered:" mail that mints a msg- phantom carries the item list too, so + -- Xelsluthe and YIWENTEC each rendered TWICE again, which is the exact + -- complaint this page was fixed for. Items do not separate an orphan + -- purchase from an item-carrying echo; only real deduplication does, and + -- that is board 210, deliberately not attempted here. AND (SELECT count(*) FROM extracted_facts ef WHERE ef.fact_type = 'order_event' AND ef.payload->>'_order_entity_key' = f.entity_key) <= 1