Diffo.Provider.Calculations.InheritedCharacteristic (Diffo v0.5.1)

Copy Markdown View Source

Backing calculation for inherited_characteristic DSL declarations.

Traverses AssignmentRelationship by alias inward (this instance is the target; follow to the source) to reach source instances, then reads each source's typed characteristic at the declared role.

Injected automatically by TransformInheritedRefs — do not reference this module directly; use the inherited_characteristic DSL entity inside characteristics do.

Cross-world resolution

Unlike inherited_place / inherited_party (which query universal PlaceRef / PartyRef), the typed characteristic module varies per source resource. This calc resolves it at runtime via AshNeo4j.worlds/1 on the source struct and Diffo.Provider.Extension.Info.provider_characteristics/1 on the source's outermost resource. Late-binding by design — the source resource may not exist at the consumer's compile time.

Result shape

A list per input record. Each entry corresponds to one source instance reached by the traversal. The entry is:

  • A BaseCharacteristic-derived record (or a list of such records when the source's characteristic declaration is {:array, M}).
  • %Diffo.Unknown{} when the source can't be projected to a loadable resource module, or its module declares no characteristic at this role.

Reason vocabulary (local to this world)

This calc emits %Diffo.Unknown{} with one of:

  • :no_concrete_worldAshNeo4j.worlds/1 returned []; the source struct has no labels resolvable to a loaded AshNeo4j.DataLayer resource. The :context carries %{source_id: id}.
  • :role_not_declared — the outermost world's resource exists but its provider_characteristics/1 has no entry for the declared role. The :context carries %{source_id: id, resource: module, role: atom}.

Per the Cross-domain lookups AGENTS.md section, reasons are world-local — consumers in other worlds should treat them as opaque and (if composing) wrap via :inner_unknown.

Summary

Functions

describe(opts)

Callback implementation for Ash.Resource.Calculation.describe/1.

has_calculate?()

has_expression?()

Callback implementation for Ash.Resource.Calculation.has_expression?/0.

init(opts)

Callback implementation for Ash.Resource.Calculation.init/1.

strict_loads?()

Callback implementation for Ash.Resource.Calculation.strict_loads?/0.