0004. Identifiers, references and relation keys
Status: accepted (language 0.2)
Context
Section titled “Context”IDs are separate from labels and must stay stable so manual adjustments survive edits. Relation names are optional in small examples, but the editor must be able to point at any relation, and compiling must never write to the file.
Decision
Section titled “Decision”- Identifiers match
[A-Za-z_][A-Za-z0-9_]*. Hyphens are excluded soa->blexes without spaces. - Inside a diagram, elements and relations share one flat namespace; a duplicate is
ref.duplicate-id. Groups do not create namespaces inflow0.2. - Qualified references (
shop.api) are parsed everywhere but only resolve inmodelandc4(not yet compiled). Inflow, a dotted name is valid only as a port:api.east. - Ports in 0.2 are
north,south,east,westandauto. - An anonymous relation gets the key
<from>-><to>#<n>, wherenis its 1-based position among all relations with the same source and target, named or not, in source order. Counting named relations too keeps keys stable when another relation between the same elements is named. - Keys live in the model, the JSON and the edit layer, never in the file. Edits that need a
persistent reference first run
materializeRelationId, which writesas <id>.
Alternatives considered
Section titled “Alternatives considered”- Hyphenated identifiers (
order-service): conflicts with->and-->without mandatory spaces. - Writing generated IDs on compile: violates “compiling never modifies a file”.
- Counting only anonymous relations for keys: naming the first relation would renumber the others.
Consequences
Section titled “Consequences”- Renaming an element changes the keys of its anonymous relations; the editor refreshes keys after each edit.
- Named ports, group namespaces and cross-type linking remain open questions for grammar 0.3.