[go: up one dir, main page]

Skip to content

Refactor checksummed and not_checksummed scopes to reduce confusion and improve maintainability

Problem

Currently, our Geo verification scopes are confusing and inconsistent. The checksummed and not_checksummed scopes are defined in VerificationState but are overridden in all primary models, while registries don't override them. This creates confusion about where these scopes should live and how they should work.

Current Issues:

  • VerificationState is included in VerifiableModel, which is then included in parent models
  • The base checksummed scope in VerificationState doesn't work for parent models, requiring overrides
  • All primary models override these scopes with nearly identical implementations
  • Registry models don't override them, creating inconsistency
  • The abstractions are confusing and hard to understand

Example of Current Duplication:

Every primary model has similar scope overrides like:

scope :checksummed, -> { joins(:model_state).where.not(model_states: { verification_checksum: nil }) }
scope :not_checksummed, -> { joins(:model_state).where(model_states: { verification_checksum: nil }) }

Proposed Solution

Move the checksummed and not_checksummed scopes from VerificationState to VerifiableModel where they can be implemented generically to work for both:

  • Models with separate state tables (using joins)
  • Models with inline verification state (using direct column queries)

This would:

  • Eliminate the need for model-specific overrides
  • Reduce code duplication
  • Make the abstractions clearer and more maintainable
  • Ensure consistent behavior across all verifiable models

Context

The concept of "checksum" in Geo should only apply to primary models, not secondary registries, which are verified. This refactoring aligns with that principle by moving the scopes to the appropriate abstraction layer.

References

Edited by 🤖 GitLab Bot 🤖