A provenance/entailment audit CONFIRMED the grounding moat is sound (500k+ adversarial fuzz
iterations could not break the slice(start,end)===text invariant; fabricated spans always
dropped) and pharmacovigilance math exact. It found real verdict-INVERTING bugs in
detectPolarity, whose output multiplies the final support/refute label:
- Double negation ('the therapy was not without benefit') was read as negative -> a true
benefit claim was REFUTED by confirming evidence. Now negation PARITY: an even number of
negations cancels, odd denies. Overlapping cues ('did not' contains 'not') merge to one
instance so parity is correct.
- Scoped negation ('reduced mortality but not blood pressure') flipped the whole claim
negative. Polarity is now decided on the PRIMARY clause (before any contrastive marker),
so a negation scoped to a secondary clause no longer inverts the primary assertion.
- Lexicon gaps: added 'negligible', 'ruled out', 'devoid of', 'absent'.
Also (low severity, from the same audit sweep): variantPathogenicity now resolves a combined
'Benign/Likely benign' to the stronger 'Benign' tier, symmetric with the pathogenic side, so a
benign claim against ClinVar's real aggregate is not spuriously flagged overstated_certainty.
Full suite green (1072 passed). Grounding invariant, pharmacovigilance disproportionality
(PRR/ROR/CIs/chi-square/BCPNN), and ClinVar star-mapping were all audited and CONFIRMED correct.
34 lines
1.7 KiB
TypeScript
34 lines
1.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { detectPolarity } from "@/lib/grounding/negationEntailment";
|
|
|
|
// detectPolarity is a deterministic multiplier on the final support/refute label, so a wrong
|
|
// polarity INVERTS the verdict. These cases pin the two verdict-inverting bugs a biostatistics
|
|
// audit found (double negation, scoped negation) plus lexicon coverage.
|
|
describe("detectPolarity — parity + scope", () => {
|
|
it("classifies a plain benefit claim positive", () => {
|
|
expect(detectPolarity("Drug X reduced mortality by 30%").polarity).toBe("positive");
|
|
});
|
|
|
|
it("classifies a single negation negative (overlapping cues merge to one)", () => {
|
|
expect(detectPolarity("The drug did not reduce mortality").polarity).toBe("negative");
|
|
expect(detectPolarity("does not cause harm").polarity).toBe("negative");
|
|
expect(detectPolarity("There was no significant difference").polarity).toBe("negative");
|
|
});
|
|
|
|
it("cancels a DOUBLE negation to positive (was inverted to a false refute)", () => {
|
|
expect(detectPolarity("The therapy was not without benefit").polarity).toBe("positive");
|
|
});
|
|
|
|
it("scopes a negation to its secondary clause, keeping the primary polarity", () => {
|
|
// "not" denies blood pressure only; the primary assertion (reduced mortality) is positive.
|
|
expect(
|
|
detectPolarity("Drug X reduced mortality but not blood pressure").polarity
|
|
).toBe("positive");
|
|
});
|
|
|
|
it("covers lexicon gaps that previously read as positive", () => {
|
|
expect(detectPolarity("The effect was negligible").polarity).toBe("negative");
|
|
expect(detectPolarity("The trial ruled out any survival benefit").polarity).toBe("negative");
|
|
});
|
|
});
|