Skip to content

A type-only retype names a contract base, never a mixin - #476

Merged
trissim merged 1 commit into
mainfrom
s-nra/contract-base-retype
Nov 18, 2026
Merged

trissim merged 1 commit into
mainfrom
s-nra/contract-base-retype

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

An annotation is identity evidence: it says which type a value is. Step 1 (#472) widened annotations to the nearest base below the reader that passed mypy. When the reader reads no member, that erases identity, and mypy can't see the loss. On agent-comms it retyped Todo to StoreRows, a __slots__ = () marker, and the type check passed.

The rule now

  • Target: the nearest base below the reader that is a contract base. That means it declares an abstract member of its own, or it belongs to a registry family, as root or member. This uses the index's abstract_method_names and is_registration_authority.
  • Protocols: never named. They are structural and carry no nominal identity.
  • Bases that only supply code: passed over. When they are the only bases below the reader, BaseIsImplementationMixin names them as a typed refusal with OPERATION input: a contract base declared below is what's needed.

Fixtures

  • Refused: a marker base like StoreRows.
  • Passed over: a mixin nearer than an ABC, so the ABC is chosen.
  • Accepted: a registry-family base, registered via __init_subclass__.
  • Still applies: the existing ABC case, which is the NativeAttestation → SnapshotAttestation shape. SnapshotAttestation is ABC with abstract conflicts.

Tests: the targeted set passes, 171 of 171: type_only, hidden_import_cuts, hidden_imports, downstream_consumers, composition_layering, repository_architecture and restated_fact_detectors.


Generated by Claude Code

An annotation says which type a value is. Widening it to any base that
passes the type check erases that when the reader reads no member, and
the check cannot see the loss: Todo -> StoreRows passed mypy while
saying a goal row is a store marker.

The retype target is now the nearest base below the reader that declares
a contract: an abstract member of its own, or membership in a registry
family (its root or a member). A Protocol names no nominal identity.
Bases below that only supply code are passed over; when they are all
there is, BaseIsImplementationMixin names them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016gZLduhisRHdamZ5LNK72Z
@trissim
trissim merged commit ff6fb73 into main Nov 18, 2026
1 of 10 checks passed
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.

2 participants