Skip to content

P2: Test Expectations Misalignment — API Documentation & Coverage #1716

Closed

Description

@ashleyshaw

Overview

Priority: P2 (Testing/Quality)
Type: Test Quality & Documentation
Blocking: No (tests pass, but weak test coverage)
Effort: 4–5 hours
Related: PR #1713 (Phase 3 findings)

Problem Statement

The handle-needs-triage handler tests codify arbitrary behavior instead of verifying the documented handler API. Tests accept overly-permissive assertions that may mask logic bugs in the issue triage automation system.

Files Affected

  • scripts/automation/__tests__/handle-needs-triage.test.js (lines 17, 27, 37, 46, 57, 50-58)
  • scripts/agents/includes/handle-needs-triage.js (handler implementation)
  • Docs: docs/HANDLER_API_REFERENCE.md (documentation)

Impact Assessment

  • Current State: Non-blocking (tests pass 100%, but weak)
  • Risk Scope: Issue triage handler inference logic, confidence score interpretation
  • Blocking Tests: None (tests pass)
  • CI Status: ✅ CI passes (tests pass, but assertions are weak)
  • Quality Risk: Weak tests may mask logic bugs during refactoring

Problem Details

Issue 1: Arbitrary Default Behavior

Lines 17, 27, 37, 46, 57
Tests assert that confidence < 0.3 for generic input remains untyped, but tests don't verify:

  • Why this threshold exists
  • What the handler actually implements
  • Whether behavior matches documentation

Issue 2: Overly-Permissive Assertions

Lines 50-58
Tests accept first zero-score entry instead of requiring meaningful confidence:

  • Current: expect(result.type).toBe(firstZeroScoreEntry.type)
  • Problem: Accepts any low-confidence match, doesn't verify meaningful inference
  • Risk: May mask bugs in scoring logic

Issue 3: Weak Edge Case Coverage

Missing tests for:

  • Empty issue content
  • Mixed keywords (ambiguous typing)
  • Low confidence scores
  • Boundary conditions

Remediation Scope

1. Audit Handler Implementation

  • Review handle-needs-triage.js actual behavior
  • Document actual confidence thresholds
  • Identify undocumented quirks or edge cases
  • Map test assertions to handler code paths

2. Update Test Expectations

  • Match test assertions to actual handler behavior
  • Fix overly-permissive tests
  • Document why tests assert what they do (WHY comments)
  • Link test assertions to handler documentation

3. Add Edge Case Tests

  • Empty issue content → should not crash, returns default
  • Mixed keywords → ambiguous typing, return lowest-confidence option
  • Low confidence scores → verify threshold behavior
  • Boundary conditions → confidence exactly at threshold

4. Document Handler API

  • Configuration options
  • Confidence threshold behavior (≥0.3 for type, <0.3 untyped)
  • Return value semantics (type field, confidence field, etc.)
  • Known limitations and assumptions

Completion Criteria

  • All test assertions justified
  • Edge cases covered
  • Handler API documented
  • No weak tests that mask bugs
  • All tests passing (existing + new)
  • Code review approved
  • Merged to develop

Testing

  • Unit tests for each confidence level (0, 0.15, 0.3, 0.5, 1.0)
  • Edge case tests (empty, ambiguous, boundary)
  • Integration test with real issue data
  • Documentation review

References


Suggested Owner: @ash (or assign based on availability)
Timeline: After issue #1715 completes
Labels: type:testing-coverage, priority:important, area:automation, meta:needs-changelog

Activity

  1. linear-code commented on Aug 10, 2026

    @linear-code
  2. added a commit that references this issue on Aug 10, 2026
  3. github-actions commented on Aug 10, 2026

    @github-actions
    Contributor

    ⚠️ This issue does not follow a required issue template.

    Missing required section(s): Definition of Ready (DoR), Definition of Done (DoD)

    The issue will remain open and flagged until the body is corrected.
    Please update the issue with one of the official templates:

    If this was opened by automation, update the automation to preserve the template sections before creating the issue.

  4. github-actions commented on Aug 10, 2026

    @github-actions
    Contributor

    ⏱️ Aging and SLA annotation

    • Age: 0 day(s)
    • SLA state: Within SLA
    • Thresholds: warn at 7 days, breach at 14 days
    • Last updated: 2026-08-10T16:54:06.097Z

    Maintained by project-meta-sync workflow.

  5. self-assigned this
    on Sep 8, 2026
  6. github-actions commented on Sep 8, 2026

    @github-actions
    Contributor

    ⚠️ Bare Labels Detected

    This issue has labels that are not in the canonical taxonomy:

    • migrate:priority:important
    • migrate:priority:normal
    • migrate:status:needs-more-info
    • migrate:meta:needs-changelog
    • migrate:type:bug
    • migrate:type:test
    • status:needs-template-fix

    Valid Canonical Labels

    Please use labels with a prefix from the canonical taxonomy:

    • Type: type:bug, type:feature, type:task, type:documentation, etc.
    • Status: status:needs-triage, status:in-progress, status:done, etc.
    • Priority: priority:critical, priority:high, priority:normal, priority:low
    • Area: area:ci, area:docs, area:labels, area:security, etc.
    • Meta: meta:needs-changelog, meta:duplicate, meta:blocked, etc.

    For the complete list, see .github/labels.yml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions