Diffo.Provider.Extension.Verifiers.VerifyProviderDomain (Diffo v0.7.0)

Copy Markdown View Source

Verifies that a provider resource (Instance / Party / Place — anything composing Diffo.Provider.Extension) carries the :Provider Neo4j label.

:Provider is what makes provider polymorphism work: cross-world projection (Diffo.Provider.get_place_by_id!/1 and friends, AshNeo4j.worlds/1) and PlaceRef / PartyRef / belongs_to resolution all MATCH on [:Provider, <base-type>]. A node gets :Provider either because its domain is Diffo.Provider (the built-in leaves — :Provider is their domain_label) or because its domain composes Diffo.Provider.DomainFragment (which writes :Provider as the domain-fragment label).

Forget the fragment on a consumer domain and the node simply lacks :Provider: provider readers stop finding it and projection silently returns nothing. This verifier turns that silent footgun into a compile-time error pointing at the fix.

Resolution (and why it isn't the persisted :all_labels)

We can't trust the :all_labels AshNeo4j persists, because its domain-fragment slot is resolved with Code.ensure_loaded? at compile time — if the domain hasn't loaded yet (resource/domain compile order), it bakes a nil fragment label even though the node does get :Provider at runtime (where domain_fragment_label/1 falls back to the domain). So we resolve the domain ourselves:

If the domain genuinely can't be resolved at this point in compilation, we stay silent — a best-effort guard never false-positives on a resource that may be correct at runtime. In practice the domain is available by the time a consumer's resource compiles, so the forgotten-fragment case is caught.