Skip to content

refactor(metrics): make PrometheusObserver inherit SpecObserver protocol#976

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:audit/arch-25-prometheus-inherit-spec-observer
Jun 12, 2026
Merged

refactor(metrics): make PrometheusObserver inherit SpecObserver protocol#976
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:audit/arch-25-prometheus-inherit-spec-observer

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

The Prometheus-backed observer matched the spec observer protocol only by structural typing, so a drift between the two (a renamed or removed hook) would go unnoticed until runtime.

This makes the class explicitly inherit the protocol, turning conformance into a type-checked contract: the type checker now verifies every protocol member is implemented.

Changes

  • PrometheusObserver now inherits SpecObserver.
  • Added the import of the protocol.

All three protocol members were already implemented, so no behavior changes.

Verification

  • uv run pytest tests/node/metrics/test_spec_observer.py — 9 passed.
  • just check — ruff, ruff format, ty (validates protocol conformance), codespell, mdformat all pass.

🤖 Generated with Claude Code

Inheriting the protocol turns conformance into a type-checked contract.
The type checker now verifies every protocol member is implemented,
instead of relying on implicit structural typing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit 238f23d into leanEthereum:main Jun 12, 2026
14 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.

1 participant