fix(globi): hasHost with a pollinator subject is forage, not pest_pressure - #2
Open
vbeefy wants to merge 1 commit into
Open
fix(globi): hasHost with a pollinator subject is forage, not pest_pressure#2vbeefy wants to merge 1 commit into
vbeefy wants to merge 1 commit into
Conversation
…ssure `lib/globi-classify.js::resolveVariable` resolved GloBI's `hasHost` with the generic rule "invertebrate has host plant => pest_pressure". A bee IS an invertebrate and its "host plant" is the plant it FORAGES on, so every bee->plant hasHost record became a harmful crop-pest claim — a sign inversion (a mutualist recorded as harm). Fix: a pollinator guard placed BEFORE the generic invertebrate rule — subject primary_role='pollinator' OR a POLLINATOR_FAMILIES bee family (Apidae, Halictidae, Andrenidae, Megachilidae, Colletidae, Melittidae, Stenotritidae) with a plant object => pollination/beneficial. The family fallback matters because much of the corpus carries primary_role='unclassified'; the role check independently catches non-bee flower-visitors such as Syrphidae. Regression-pinned: a genuine herbivore still => pest_pressure and a fungal pathogen still => pathogen_pressure, so the guard cannot over-correct. Also adds fix-globi-pollinator-category.cjs, which re-derives already- loaded claims by re-running the FIXED classifyTriple over the affected set and writing back only where the derived category changes. That is deliberately self-limiting — a real pest re-derives to pest_pressure and is left alone — and keeps one source of truth rather than duplicating the mapping. Dry-run by default; every change is revision-logged. This is the same bug class as the earlier "hasVector is dispersal, not disease" correction: GloBI's broad terms (hasHost, hasVector) are resolved by generic bio_category rules, and each such rule needs a mutualist guard. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
lib/globi-classify.js::resolveVariableresolves GloBI'shasHostterm with a generic rule:A bee is an invertebrate, and its "host plant" is the plant it forages on. So every bee→plant
hasHostrecord became a harmful crop-pest claim — a sign inversion: a mutualist recorded as harm.This is the most damaging error class for an agroecology knowledge base. It doesn't just add noise — it inverts the recommendation ("this bee damages your dandelion" instead of "this bee pollinates it"). It also corrupts anything downstream that treats "organism harming a crop" as a pest node.
Fix
A pollinator guard placed before the generic invertebrate rule:
primary_role='pollinator'OR aPOLLINATOR_FAMILIESbee family (Apidae, Halictidae, Andrenidae, Megachilidae, Colletidae, Melittidae, Stenotritidae)pollination/ beneficialBoth signals are needed. The family fallback matters because much of the corpus carries
primary_role='unclassified'; the role check independently catches non-bee flower-visitors such as Syrphidae (hoverflies), which no bee-family list would.Not over-correcting
Regression tests pin the paths that must not change:
pest_pressurepathogen_pressureRetroactive re-derive
fix-globi-pollinator-category.cjscorrects already-loaded claims by re-running the fixedclassifyTripleover the affected candidate set and writing back only where the derived category changes.Two deliberate properties:
pest_pressureand is left untouched.Dry-run by default; every change is revision-logged (fully reversible).
Same bug class as
hasVectorGloBI's broad terms (
hasHost,hasVector) get resolved by genericbio_categoryrules, and each such rule can silently mis-brand mutualists — cf. the earlier "hasVectoris dispersal, not disease" correction, which had mislabeled seed-dispersers as disease vectors. Useful heuristic when adding or auditing one of these rules: ask which mutualist it would mis-brand.Test plan
node --test backend/lib/globi-classify.test.js→ 10/10 pass (verified against this branch's base).🤖 Generated with Claude Code