Diffo.Provider.Calculations.InheritedPlace (Diffo v0.7.0)

Copy Markdown View Source

Backing calculation for inherited_place DSL declarations.

Traverses AssignmentRelationship by alias to reach source instances, then reads their PlaceRef records for the declared source_role. Injected automatically by TransformInheritedRefs — do not reference this module directly; use the inherited_place DSL entity instead.

See Diffo.Provider.Extension.InheritedPlaceDeclaration for the DSL options.

Result shape

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

  • One or more Diffo.Provider.Place values when the source has matching PlaceRef records at source_role.
  • %Diffo.Unknown{} when the source is reached but carries no PlaceRef at source_role.

When no sources are reached at all (e.g. no assignment), the result is []. Unknown is reserved for "we got here but the role isn't declared" — the X-state from the AGENTS.md Diffo.Unknown discipline.

Reason vocabulary

Only one reason is possible here — PlaceRef is a universal indirection so no cross-world dispatch is needed (which is why this calc is cleaner than the characteristic equivalents):

  • :role_not_declared — source instance reached but its PlaceRef records carry no entry at source_role. :context is %{source_id: id, role: source_role}.

:world stamping

TransformInheritedRefs passes the consumer's resource as :world at compile time. Each emitted %Diffo.Unknown{} stamps it.

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.