Skip to content

[H-9 / Phase 3] [MEDIUM] Penalize the score, not just confidence, on hallucinated IDs #15

@matthewod11-stack

Description

@matthewod11-stack

Full spec: docs/hardening-roadmap-2026-04-16.md#h-9

Description

grounding-validator.ts:69 reduces confidence proportionally to invalid-ID fraction but leaves score untouched. An LLM that hallucinates 1/10 IDs keeps full score with 10% lower confidence. Policy decision required.

Current State

  • Only confidence is scaled; score is invariant to hallucination rate.

Suggested Fix (needs policy choice first)

Options:

  • Strict: hallucinationRate > 20% → dimension score = 0 (forces re-extraction).
  • Soft: scale score by sqrt(ratio) — gentler than linear, nonzero.
  • Bifurcated: keep score + confidence, add groundingQuality: 'clean' | 'partial' | 'poor' field for tier assignment to consider.

Implementation once chosen:

  • Make policy configurable: SearchConfig.groundingStrictness: 'strict' | 'soft' (default 'soft').
  • Update ExtractedSignals schema + all readers.
  • Tests: soft policy → reduced confidence + reduced score; strict → score 0; default is soft (non-breaking).

Verification

  • pnpm build passes
  • pnpm test passes
  • pnpm typecheck clean

Automation Hints

scope: packages/scoring/src/grounding-validator.ts, packages/core/src/scoring.ts
do-not-touch: adapters
approach: refactor-types
risk: medium
max-files-changed: 6
blocked-by: none
bail-if: grounding tests fail

Priority

Medium — blocks H-12 (scoring test coverage)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-design-decisionRequires human product/design input — agent skipstech-debtEligible for automated overnight fixing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions