Skip to content

Reject two model elements at the same position that share a name #19

Description

@goloroden

What is this feature about?

Element identity in ESDM is (containment position + name), and today uniqueness is only a per-kind, per-array modeling convention the schema does not enforce. The resolver indexes each kind into its own map, so two elements of different kinds that occupy the same containment position and share a name coexist silently: an aggregate and a dynamic-consistency-boundary both named loan in one bounded context, a bounded-context and a policy both named orders in one domain, or a command and an event both named place-order under one aggregate.

The reference notation (#8) turns this from a smell into a correctness requirement. A reference is a containment path that carries no kind (esdm:library/lending/loan), resolved by walking the hierarchy by name. For that walk to land on exactly one element, a name must identify exactly one element at each position, across all kinds that can sit there. The notation depends on this invariant, so a violation must be an error, not a warning.

What needs to be done to implement this feature?

  • Add a lint rule that throws when two model elements occupy the same containment position and share a name, across kinds, at every position where more than one kind can sit:
    • under a domain (bounded-context, subdomain, policy, event-handler, process-manager, external-system, domain-story),
    • under a bounded context (aggregate, dynamic-consistency-boundary, read-model, query, entity, value-object, domain-service, actor, and free-standing events),
    • under an aggregate or dynamic-consistency-boundary (command, event, and - once Feature documents are keyed on domain and name, discarding their scope #38 is fixed - feature).
  • Severity is Error: the reference notation relies on this uniqueness, so a clash is a defect, not a suggestion. Confirm the exact category and the diagnostic wording; both are user-facing and need sign-off.
  • Place the rule in the rules package, not next to the resolver's existing duplicate-name check. Rules only run when the model is otherwise error-free, so a collision reported by the resolver would silence every other rule - on a large model the author would see that one error and nothing else.
  • Cover the migration: models that lint clean today go red on upgrade. The diagnostic has to make the cause obvious on first read, and the release note has to say what changed and why.
  • Cover the rule with tests for the throwing and the non-throwing cases.
  • Document the rule and its rationale.

What else should we know?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions