From 8f9c19a32c7ad7f15e86d65f8dee7176d484dcf3 Mon Sep 17 00:00:00 2001 From: Croissant Le Doux Date: Thu, 16 Jul 2026 21:16:22 -0400 Subject: [PATCH] fix(scoring): definitive grantmaker exclusion + full-pool matching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Candidate orgs now also exclude any org whose EIN appears in the funders table — an org that files a 990-PF IS a private foundation regardless of its NTEE code (Bean/McIninch-style grantmakers carry E/S codes or none). 1,692 stale pending matches for PF-filer orgs cleaned. Candidate limit raised to 2,000 after the enrichment drain grew the pool 56 -> 887. Full-pool run: 856 candidates, 42,800 matches, 850 easy wins across 373 orgs, top heroes led by community-precedent pairs (Seacoast Pathways -> Foundation for Seacoast Health; Granite Backcountry Alliance -> Gibson-Woodbury). Known residual: hospital-legacy 'health foundation' grantmakers file 990 (not 990-PF), so the PF roster can't catch them — they reach the queue and rely on the human reject gate; profiler-based classification is the durable fix. Co-Authored-By: Claude Fable 5 --- apps/outreach-worker/src/workflows/match-grants.ts | 2 +- .../src/orgs/queries/list-match-candidate-orgs.server.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/outreach-worker/src/workflows/match-grants.ts b/apps/outreach-worker/src/workflows/match-grants.ts index 8d2a5ba..f26dee5 100644 --- a/apps/outreach-worker/src/workflows/match-grants.ts +++ b/apps/outreach-worker/src/workflows/match-grants.ts @@ -44,7 +44,7 @@ import type { NodePgDatabase } from 'drizzle-orm/node-postgres'; export type OutreachDb = NodePgDatabase; -const CANDIDATE_ORG_LIMIT = 500; +const CANDIDATE_ORG_LIMIT = 2_000; const GRANTS_PER_ORG = 50; const MIN_DAYS_TO_DEADLINE = 21; const MIN_AWARD_CEILING = 10_000; diff --git a/packages/outreach-core/src/orgs/queries/list-match-candidate-orgs.server.ts b/packages/outreach-core/src/orgs/queries/list-match-candidate-orgs.server.ts index 7bfc41f..977f17f 100644 --- a/packages/outreach-core/src/orgs/queries/list-match-candidate-orgs.server.ts +++ b/packages/outreach-core/src/orgs/queries/list-match-candidate-orgs.server.ts @@ -46,6 +46,12 @@ export async function serverListMatchCandidateOrgs( isNull(schema.orgs.nteeCode), sql`${schema.orgs.nteeCode} NOT LIKE 'T%'`, ), + // Definitive grantmaker check: an org that files a 990-PF IS a + // private foundation, whatever its NTEE code says (many carry + // E/S codes or none). The funders table is exactly that roster. + sql`NOT EXISTS ( + SELECT 1 FROM funders f WHERE f.ein = ${schema.orgs.ein} + )`, ), ) .limit(limit);