Skip to content

Test coverage: Ai::OpenAiService — summarization, vote extraction, and error handling #57

@AndreRobitaille

Description

@AndreRobitaille

Summary

Ai::OpenAiService has grown substantial test coverage since this issue was filed. Several method groups remain untested.

What's already covered

  • Briefing pipeline — 5 tests in open_ai_service_briefing_test.rb (analyze_topic_briefing, render_topic_briefing, generate_briefing_interim, parse error handling)
  • Topic extraction prompts — 2 tests in open_ai_service_extract_topics_test.rb (category name blocking, re_extract_item_topics)
  • Description generation — 4 tests in open_ai_service_generate_description_test.rb (activity-based prompt, concept-based prompt, empty/nil response handling)
  • Committee context — 3 tests in committee_context_test.rb (active committees, empty set, committee_type inclusion)
  • Committee member extraction — 3 tests in extract_committee_members_test.rb (request/response, text truncation, JSON keyword in prompt)

Methods still needing tests

Summarization (meeting-level)

  • summarize_packet_with_citations() — Two-pass summarization with JSON planning
  • summarize_packet() — Packet analysis
  • summarize_minutes() — Minutes recap
  • analyze_meeting_content() — Meeting content analysis pass
  • render_meeting_summary() — Meeting summary rendering pass

Topic analysis (per-meeting)

  • analyze_topic_summary() — Governance-compliant topic analysis
  • render_topic_summary() — Markdown rendering from analysis JSON

Vote extraction

  • extract_votes() — Motion and vote extraction from minutes

Triage

  • triage_topics() — Topic merging, approval, blocking recommendations

Catch-all refinement

  • refine_catchall_topic() — Refines broad ordinance topics into specific concerns

Infrastructure

  • Error handling and retries across all methods
  • Provider selection (OpenAI vs Gemini)
  • gemini_generate() path

Approach

  • Stub API responses with WebMock or mock objects
  • Test prompt construction (verify governance elements: citations, anti-speculation, confidence scoring)
  • Test response parsing (JSON extraction from various formats)
  • Test error handling (API timeouts, malformed responses)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions