Skip to content

test(mcp): compare enum numbers by value - #5

Merged
barbatdev merged 1 commit into
mainfrom
fix/mcp-contract-numeric-enum-equality
Sep 1, 2026
Merged

test(mcp): compare enum numbers by value#5
barbatdev merged 1 commit into
mainfrom
fix/mcp-contract-numeric-enum-equality

Conversation

@barbatdev

Copy link
Copy Markdown
Owner

Summary

  • compare MCP contract enum membership using JSON instance equality
  • compare JSON numbers by exact mathematical value with json.Number and math/big.Rat
  • preserve serialized enum lexemes and fixture bytes while covering nested arrays and objects

Why

Cortex adversarial QA found that lexical enum comparison falsely rejected mathematically equal JSON Schema numbers such as 1, 1.0, and 1e0. JSON Schema 2020-12 defines numeric instance equality by mathematical value, and enum uses instance equality.

TDD evidence

  • RED: equivalent numeric lexemes and nested values produced enum-narrowed
  • GREEN: focused numeric-equality regression passed with exact rational comparison
  • TRIANGULATE: primitive type distinctions, array order, object member order, arbitrary-precision inequality, existing expansion, and true narrowing all pass
  • REFACTOR: gofmt and focused comparator/codec/fixture tests pass

Verification

  • go test ./internal/mcp -count=1
  • go test -cover ./internal/mcp — 88.8%
  • focused race tests for enum comparison
  • go vet ./internal/mcp
  • go build ./...
  • go test -tags e2e ./internal/server/...
  • Cortex cortex-adversarial-tester with nan/deepseek-v4-flashPASS
  • fixture SHA-256 unchanged: e4c6839c690c93247c7e9603c07bce66a1155136e79321748dba032b8e3007df

Full repository tests retain only the pre-existing macOS /private/var versus /var path failures in cmd/engram and internal/project.

Scope

  • one test-only file
  • 116 insertions, 1 deletion
  • no production/runtime changes
  • no fixture changes

Related to Gentleman-Programming#717.

@barbatdev barbatdev added the type:bug Bug fix label Sep 1, 2026
@barbatdev
barbatdev merged commit 930eb87 into main Sep 1, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant