Skip to content

[H-12 / Phase 4] [MEDIUM] Grow scoring-package test coverage #16

@matthewod11-stack

Description

@matthewod11-stack

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

Description

packages/scoring/src/__tests__/ has 3 files vs 12 in apps/cli/. Grounding logic, tier edge cases, and red-flag handling are under-covered in the package where correctness matters most.

Current State

  • signal-extractor.test.ts, score-calculator.test.ts, narrative-generator.test.ts only.
  • No grounding-validator.test.ts.

Suggested Fix

  • New grounding-validator.test.ts:
    • all-valid IDs → no violations, no confidence loss
    • all-invalid IDs → signal retained with confidence=0
    • mixed → proportional (post-H-9: policy-dependent) adjustment
    • empty evidence array → no crash
  • Expand score-calculator.test.ts:
    • tier boundaries (score = exactly threshold)
    • all confidences = 0 → score = 0
    • negative weights if supported
  • Expand narrative-generator.test.ts with post-H-1 injection fixtures — narrative must not echo injected instructions.

Verification

  • pnpm build passes
  • pnpm test passes
  • pnpm typecheck clean
  • packages/scoring test count at least doubles
  • grounding-validator.ts line coverage > 90%

Automation Hints

scope: packages/scoring/src/tests
do-not-touch: production code unless specifically required
approach: add-tests
risk: low
max-files-changed: 5
blocked-by: #5, #15
bail-if: existing scoring tests break

Priority

Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtEligible for automated overnight fixingtestingCan combine with tech-debt — agent will add tests

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions