Skip to content

refactor(memory): use typing.Protocol for MemoryBackend interface#19

Merged
Patel230 merged 3 commits into
mainfrom
fix/ecosystem-boundaries
Jun 25, 2026
Merged

refactor(memory): use typing.Protocol for MemoryBackend interface#19
Patel230 merged 3 commits into
mainfrom
fix/ecosystem-boundaries

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

  • Replaced duck-typing hasattr checks with typing.Protocol structural interface
  • MemoryBackend is @runtime_checkable for isinstance validation
  • Any object with remember/recall methods satisfying the Protocol is accepted

Architecture compliance

Aligns with hawk-eco principle: Python SDKs use structural interfaces (Protocol), not concrete imports from engines.

Patel230 added 3 commits June 25, 2026 10:57
- Replace duck-typing hasattr checks with structural Protocol
- MemoryBackend is runtime_checkable for isinstance validation
- Aligns with hawk-eco architecture: SDKs use structural interfaces
…ckend detection

- Import Sequence under TYPE_CHECKING to satisfy ruff UP035/TC003
- Use hasattr instead of isinstance(Protocol) for backend detection
  since runtime_checkable checks class attrs, not instance attrs,
  breaking MagicMock-based tests on Python 3.12+
@Patel230 Patel230 merged commit d0174e0 into main Jun 25, 2026
10 checks passed
@Patel230 Patel230 deleted the fix/ecosystem-boundaries branch June 25, 2026 13:47
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