Skip to content

test: pin signatures, output shape & model fields in API contract#4

Merged
sligara7 merged 1 commit into
mainfrom
test/api-contract-signature-pins
Jun 6, 2026
Merged

test: pin signatures, output shape & model fields in API contract#4
sligara7 merged 1 commit into
mainfrom
test/api-contract-signature-pins

Conversation

@sligara7

@sligara7 sligara7 commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

Strengthens the API contract test from name-only pinning to also pin signatures, the primary output shape, and model fields — so the bulk of accidental breaking changes turn CI red instead of shipping silently. Test-only; no source or version change.

What's now enforced (additions to tests/test_api_contract.py)

#1 — Full signature pins (TestPublicSignatures)

  • Pins the exact signature string (param names, order, defaults, return type) of all 35 public functions + the DiceEngine constructor.
  • Also asserts the pinned set equals the live set of public functions, so a new public function can't ship without a pinned signature.
  • Catches: reordered/renamed params, changed defaults, new required args, changed return types.

#2 — Output-shape pin (TestOutputShape)

  • Pins the exact 29-key set returned by evaluate_character.
  • Verified empirically that the key set is stable across caster/non-caster and full/minimal input before pinning (so it's not brittle).

#3 — Model-field pins (TestModelFields)

  • Pins the field set of all 18 exported pydantic models, plus the NodeType enum members.
  • Asserts the pinned set equals the live set of exported models, so a new model can't ship without a field contract.
  • Catches: renamed/removed fields, and added (optional) fields — forcing a conscious "I'm extending this" edit.

Each pin has a clear was: … now: … failure message and a header comment documenting the deliberate update path (edit expected value → bump version → note in CHANGELOG).

Tests

1575 passed (was 1568; +7 new), ruff clean.

🤖 Generated with Claude Code

Strengthens tests/test_api_contract.py from name-only pinning to also pin:
- Full signatures of all public functions + the DiceEngine constructor
  (param names, order, defaults, return type).
- The evaluate_character output key set (verified stable across class types
  and input completeness, so exact-match is safe).
- The field set of every exported pydantic model, plus NodeType members.

Each pin also asserts the pinned set equals the live public set, so a new
public function/model can't ship without a contract entry. Catches signature
drift, output-shape changes, and field rename/removal that the name-level
contract missed. Test-only; no source or version change. 1575 passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sligara7
sligara7 merged commit 0bd45bd into main Jun 6, 2026
4 checks passed
@sligara7
sligara7 deleted the test/api-contract-signature-pins branch June 6, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant