Fixes the federal mismatch class (boys' camp × NIH research center): - Peer precedent: federalPrecedent paginates USASpending (≤500 awards/ program) and name-matches every recipient against primary-ICP NH registry orgs (shared normalizeOrgNameForMatching, also used by the self-match gate). The 25-pt precedent tiers now key off program_state_peer_award_count — Dartmouth renewals and SBIR LLCs no longer grant precedent to community nonprofits. Raw count + peer- annotated award list stay as review evidence (peer badges, peers-first). - Mission-fit floor (12/30, grants_gov only): below it a match is stored with fit_viable=false and hidden from the pending queue, hero selection, and easy-win. Foundation-synthesized grants exempt (generic synopses). - Mission-fit judge live (judgeMatches, 06:15, 200/night best-first): JUDGE_MODEL reads the synopsis against the org profile with an explicit ignore-eligibility-breadth instruction; graded verdict with required citations; deterministic verdict→points map (27/18/8/0) sets missionFit, total, easy-win, and viability. Verdicts survive nightly re-scores via an upsert splice and re-enter the judge queue when the org profile is re-researched (org_profiles.updated_at). First sweep: 81/149 programs have NH history, only 6 have peer history; queue-head judging zeroes the research-mechanism garbage (mismatch) while surfacing genuine strong fits. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@novelpad/outreach-ai
LLM access layer for the HelmDocs grant-match outreach engine. Modeled on
novelpad-desktop's packages/ai, trimmed to what this engine needs: a
Vertex/Gemini client, an embeddings helper, model-tier constants, and two
structured-output agents (org profiler, mission-fit judge).
Provenance
src/gemini.ts and src/embeddings.ts are copied near-verbatim from
novelpad-desktop at commit 62c56b87 (see the header comment in each file
for the exact source path). They are kept as close to the original as
compiles standalone in this workspace — do not "clean up" drift between them
and the source without checking whether the source has moved on too.
src/agents/*/run.ts follow the structured-JSON-output pattern from
novelpad-desktop's packages/ai/src/agents/grant/section-drafter/run.ts
(prompt builder + generateContent with responseMimeType: 'application/json'
and a hand-written responseSchema), but are new code for this repo's domain,
not copies — both are currently NOT IMPLEMENTED stubs pending the
source-fetching / hard-gate scoring infrastructure they depend on. Each stub's
doc comment shows the intended call shape.
Never mix embedding models
generateQueryEmbedding / generateDocumentEmbedding / generateDocumentEmbeddings
are pinned to gemini-embedding-001 at outputDimensionality: 1536. Do not
change either value, and do not add a second embedding model/dimensionality
into this package. Every vector this package produces has to remain
comparable (same model, same dimensionality) against every other vector
already stored in the HelmDocs RAG index — switching models or dimensions
silently corrupts similarity search for anything embedded before the switch,
with no error at write time. If a better embedding model becomes available,
that's a deliberate, full-reindex migration, not a constant change here.
Model tiering
See src/models.ts: BULK_MODEL (gemini-2.5-flash) for high-volume
mechanical work (classification, effort estimates, first-pass org-profile
extraction); JUDGE_MODEL (gemini-2.5-pro) for anything a wrong answer
could put in front of a real prospect (mission-fit judge, email
personalization QA).
Layout
src/gemini.ts—getAi()Vertex client singleton +CHAT_MODEL.src/embeddings.ts— query/document embedding helpers.src/models.ts—BULK_MODEL/JUDGE_MODELconstants.src/agents/org-profiler/—OrgProfileSchema(per-field source URL + confidence) and the profiler agent stub.src/agents/mission-fit-judge/—MissionFitVerdictSchema(fit,citedOrgProgram,citedGrantPriority,reasoning) and the judge agent stub.src/index.ts— barrel export.