Skip to content

test: expand granite formatter unit tests — edge cases & granite-common alignment #827

Closed

Description

@planetf1

Context

PR #818 added ~200 unit tests for mellea/formatters/granite/ (3.2, 3.3, intrinsics, shared functions). During review, two follow-up threads emerged:

  1. Missing edge cases — @ajbozarth's review flagged unclosed citation tags, duplicate citation IDs, and other malformed model output scenarios not yet covered
  2. granite-common test alignment — @jakelorocco pointed out granite-common/tests which has complementary test coverage

Proposal

Expand the granite formatter test suite in a follow-up PR with two workstreams:

1. Edge cases from review feedback

  • Unclosed/malformed citation tags (e.g. <co>1 without </co>)
  • Duplicate citation IDs with conflicting doc indices
  • Other adversarial/malformed model output patterns for the output parsers

2. Porting viable tests from granite-common

Based on the overlap analysis in PR #818:

Area Action
Granite 3.2/3.3 input processing — tokenizer golden-truth validation Cherry-pick tokenizer validation tests — needs import rewrites, @pytest.mark.slow, skip-if-no-model, module-scoped HF fixtures
Base types (ToolCall, messages, ChatCompletion, GraniteChatCompletion validation) Port — pure Pydantic unit tests, only needs granite_common → mellea.formatters.granite import rewrites. Fills a real coverage gap
IntrinsicsRewriter golden files (answer_relevance_*, gpt_oss_*) Copy missing testdata and add scenarios to existing fixtures
Meta: orphan file check Add trivial meta-test ensuring every testdata file is referenced by a test

Already covered in #818 (skip): Granite 3.2/3.3 output parsing, OpenAI SDK compat, shared output functions.

Out of scope (separate PR): Retrievers (Elasticsearch, InMemoryRetriever, embeddings), E2E with real models.

Related

Activity

  1. self-assigned this
    on Apr 13, 2026
  2. ajbozarth commented on Apr 13, 2026

    @ajbozarth
    Member

    A note from Claude that it gave in my re-review of #818 on the scope of this follow-up issue:


    The two workstreams here have pretty different complexity, and I'd suggest splitting them to avoid the easy stuff getting blocked behind the harder stuff.

    The edge cases (unclosed citation tags, duplicate citation IDs) are simple self-contained unit tests with no new dependencies. The granite-common porting involves import rewrites, HF fixtures, @pytest.mark.slow infra, and some judgment calls about what's worth bringing over.

    Suggestion: land the edge cases in a small first PR, then the granite-common alignment in a follow-up. That way the most production-relevant gap (malformed model output handling) gets closed quickly regardless of how the granite-common work goes.


  3. jakelorocco commented on May 19, 2026

    @jakelorocco
    Contributor

    I think some of these tests may have already been added. We should first look at what tests we have for intrinsics before rewriting / adding these.

  4. planetf1 commented on May 20, 2026

    @planetf1
    ContributorAuthor

    Some of this is already done — the gpt_oss_* scenarios and orphan-file meta-test are all in test_intrinsics_formatters.py from #818.

    What's still missing: malformed <co> tag edge cases (the regex skips them silently, with an untested warning branch), answer_relevance_* scenarios, and invalid-input Pydantic validation. The original split still seems sensible — edge cases first, the rest as a follow-up.

  5. added
    area/adapter-functions
    area/stdlib
    area/formatter
    on May 20, 2026
  6. added
    p2
    on Jun 18, 2026
  7. planetf1 commented on Jun 19, 2026

    @planetf1
    ContributorAuthor

    Closing as superseded by #1304. PR #1165 (which covered the test work for this issue) was closed after confirming in discussion #1166 that the granite3/ formatter pipeline is dead code — the Granite32/33 processors are not part of any active Mellea code path. Any residual formatter edge-case testing should be scoped under the removal work in #1304 or a fresh issue once that lands.

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

Metadata

Metadata

Assignees

Labels

area/adapter-functionsarea/formatterarea/stdlibp2testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions