Skip to content

docs(proposal): add targeted ALTER for message definitions, and the nesting measurement that requires it - #375

Merged
ako merged 2 commits into
mainfrom
feat/spec-message-definitions
Sep 2, 2026
Merged

docs(proposal): add targeted ALTER for message definitions, and the nesting measurement that requires it#375
ako merged 2 commits into
mainfrom
feat/spec-message-definitions

Conversation

@ako

@ako ako commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Follow-up to #371, which merged the first draft of this proposal. Docs only.

What changed and why

The first draft had only collection-level CREATE / DROP / DESCRIBE /
SHOW, resting on an unstated assumption that a message definition is a flat
field list. Measuring the corpus shows it is not. Definitions nest to
depth 7:

depth 0 1 2 3 4 5 6 7
elements 56 356 265 142 208 477 974 2,208

Most elements sit at depths 5–7. Object elements carry a mean of 4.7 members,
with a tail out to 22.

So a whole-document CREATE OR MODIFY is a poor tool for "expose one more
attribute": restating a seven-level document to add a leaf is exactly the
diff-unfriendliness ADR-0003
argues against, and is why ALTER ENTITY ADD ATTRIBUTE exists rather than only
CREATE OR MODIFY ENTITY.

Added

alter message definition collection Sales.MD_Order
  add definition Line for Sales.Line as 'Lines' ( Sku, Quantity );
alter message definition collection Sales.MD_Order drop definition Line;
alter message definition collection Sales.MD_Order rename definition Line to OrderLine;

alter message definition Sales.MD_Order.Order add member Total;
alter message definition Sales.MD_Order.Order drop member Sku in Lines;
alter message definition Sales.MD_Order.Order set member Total as 'GrandTotal';

Collection-level ALTER matters for the 8 collections holding more than one
definition; member-level ALTER applies to all 36.

Three choices a reviewer should push on

  • Module.Collection.Definition as the address — the same three-part
    reference WITH MESSAGE DEFINITION already takes, so the two cannot drift
    apart.
  • SET member … AS, not RENAME … TO. ALTER ENTITY RENAME ATTRIBUTE
    renames in the model and rewrites every reference to it; this changes only the
    element's ExposedName and touches nothing else. Borrowing the verb would
    promise something far larger than it delivers.
  • in <path> for a nested member, written in exposed names, rather than a
    /-joined name — / already means "association to entity" inside a member
    (Sales.Order_Line/Sales.Line), and overloading it in the same clause would be
    ambiguous to a reader even where the grammar could tell them apart.

Deliberately not designed

A wildcard member (( * ) for "expose every attribute"). Studio Pro's UI is a
checkbox tree, so it is a natural thing to want, and with a tail out to 22
members it would save real typing — but * appears nowhere else in MDL and
nothing in the corpus says anyone wants it. Raised as an open question instead
of proposed, on the same principle that killed the import group = node.

Also

The verification plan gains the control that matters for ALTER specifically: add
one member and assert every other element is byte-identical — that is what
separates a targeted edit from a rebuild that happened to produce the same
result.

🤖 Generated with Claude Code

ako and others added 2 commits September 1, 2026 20:33
…requires it

The first draft had only collection-level CREATE/DROP/DESCRIBE/SHOW, on an
unstated assumption that a definition is a flat field list. Measuring the
corpus shows it is not: definitions nest to depth 7, with most elements at
depths 5-7 (2,208 at depth 7 alone), a mean of 4.7 members per object element
and a tail out to 22.

So a whole-document CREATE OR MODIFY is a poor tool for "expose one more
attribute" — restating a seven-level document to add a leaf is exactly the
diff-unfriendliness ADR-0003 argues against, and is why ALTER ENTITY ADD
ATTRIBUTE exists rather than only CREATE OR MODIFY ENTITY.

Adds two statement families:

  alter message definition collection M.MD_Order add|drop|rename definition ...
  alter message definition M.MD_Order.Order add|drop|set member ...

Three choices worth reviewing. The definition is addressed as
Module.Collection.Definition, the three-part reference WITH MESSAGE DEFINITION
already takes, so the two cannot drift apart. It is SET member ... AS, not
RENAME ... TO, because ALTER ENTITY's RENAME changes the model and rewrites
every reference while this changes only the element's ExposedName — borrowing
the verb would promise something far larger. And a nested member is reached
with `in <exposed-name path>` rather than a /-joined name, because / already
means "association to entity" inside a member.

Also raises a wildcard member (`( * )`) as an open question rather than
designing it: the checkbox-tree UI makes it a natural thing to want, but
nothing in the corpus says anyone does, and proposing it would be designing for
a shape with no document behind it.

Verification plan gains the control that separates a targeted edit from a
rebuild: add one member and assert every other element is byte-identical.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ako
ako merged commit 7d1639a into main Sep 2, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant