Skip to content

relationships dsl #134

@matt-beanland

Description

@matt-beanland

Motivation

Instance-to-instance relationship roles have no compile-time contract today. We want a structural declaration — what roles this Instance kind may participate in, and with what target kind — introspectable at runtime, the same way parties/0 and places/0 are today.

Enforcement (validating that only declared roles are used, auto-wiring in build_after, multiplicity constraints) is behaviour and is out of scope until the expectations model is settled.

Proposed DSL

```elixir
provider do
relationships do
relationship :provides, MyApp.BackboneService
relationship :requires, MyApp.AccessService
relationship_ref :peer, MyApp.AccessService # reference — no direct edge
end
end
```

Scope

  • RelationshipDeclaration struct (name, instance_type, reference)
  • PersistRelationships — bakes relationships/0 and relationship/1 onto the module
  • VerifyRelationships — compile-time: no duplicate role names, target is a BaseInstance-derived resource
  • instance_transformer_test.exs coverage
  • AGENTS.md and usage-rules.md updated

Explicitly deferred

  • Enforcement via relate_instance/2 or VerifyBehaviour
  • Auto-wiring in build_after
  • Multiplicity constraints
  • Reverse-side declaration (target-side instances do equivalent)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions