You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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),
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.
Implementation trap: the composite keys invite a naive cross-kind comparison, but event keys carry four segments where the others carry three. A free-standing event keys as domain/bc//name, an entity at the same position as domain/bc/name - so a plain key comparison misses exactly the free-standing-event collisions listed above.
Related to esdm view does not render entities and free-standing events #36: today a collision has no observable symptom, because path narrowing silently returns the first matching sibling. Once narrowing renders every match, a collision becomes directly visible instead of something the modeler has to infer. That shapes how the rule's documentation should describe detection: the symptom is not a missing document, it is a path that resolves to the wrong element.
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
aggregateand adynamic-consistency-boundaryboth namedloanin one bounded context, abounded-contextand apolicyboth namedordersin one domain, or acommandand aneventboth namedplace-orderunder 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?
What else should we know?
domain/bc//name, an entity at the same position asdomain/bc/name- so a plain key comparison misses exactly the free-standing-event collisions listed above.domain/name, which both hides collisions at the unit position and invents duplicates across units. The checklist entry above depends on that fix.