Align the teaching source and language contract with compact defaults

This commit is contained in:
2026-09-13 06:46:08 -07:00
parent d7c065991d
commit e624d5b9c4
31 changed files with 163 additions and 546 deletions
+56 -16
View File
@@ -171,11 +171,11 @@ These omissions are accepted in newly authored source 7, not only in schema-2
compatibility input. Earlier schema admission of constructors and fields is
still governed by its version rules.
Canonical formatting writes the hydrated occurrence references and default
``message_kind``, ``reply_to`` and ``values`` explicitly. An absent
``operation`` remains omitted in canonical output. Lossless no-op updates and
unrelated name edits retain authored omissions; canonical formatting is a
different operation. An admitted incomplete occurrence can still produce model
Canonical formatting omits optional occurrence references equal to ``none``,
the default Asynchronous ``message_kind``, empty ``values``, and absent
``operation``. Required fields of a selected constructor remain present.
Lossless updates retain unchanged explicit defaults and authored omissions;
canonical formatting is a different operation. An admitted incomplete occurrence can still produce model
checks requesting its missing work, exchange, lifeline or referenced scenario.
.. list-table:: Occurrence body constructors
@@ -933,18 +933,30 @@ DataTypeDefinition has exactly the following constructors:
* - Constructor
- Required fields
- Optional fields (omission value)
* - Boolean
- None
- None
* - Integer
- ``minimum``, ``maximum``: optional signed 64-bit integers
- None
- ``minimum``, ``maximum``: signed 64-bit integers? (none)
* - Real
- ``minimum``, ``maximum``: optional finite IEEE-754 binary64 values
- None
- ``minimum``, ``maximum``: finite IEEE-754 binary64 values? (none)
* - String
- ``minimum_length``: u32; ``maximum_length``: optional u32
- ``minimum_length``: u32
- ``maximum_length``: u32? (none)
* - Enumeration
- ``literals``: unique nonempty, case-sensitive strings
- None
* - Record
- ``supertype``: same-layer Record ref?
- None
- ``supertype``: same-layer Record ref? (none)
Optional fields may be absent or explicitly ``none``. Selected String and
Enumeration constructors still require ``minimum_length`` and ``literals``,
respectively, including zero and an empty list. Selecting a constructor does
not merge fields from the default String definition. Unknown fields reject.
Bounds are inclusive and ordered; an absent bound means unbounded within the
represented numeric domain. Integer comparisons MUST NOT convert to binary64.
@@ -1840,11 +1852,30 @@ Map order is irrelevant. The writer preserves signed coordinate zero and
emits decimals that recover the original binary32 value.
Canonical output uses LF, four-space indentation, explicit identities,
defaults, and JSON-escaped strings. Elements are emitted in UUID order, then
and JSON-escaped strings. It omits fields equal to the omission defaults of
their actual declaration or selected constructor, as specified in the field
tables. This includes an empty project description. It MUST NOT omit a required
field merely because its value is zero, false, empty, or ``none``. Elements are emitted in UUID order, then
relations; diagrams and their nodes follow, then artifacts, then traces.
Fields use deterministic name order. Output ends with LF. Alias values come
from the model, never from regenerating display names.
Omission is context-sensitive: Scenario uses the source default MixedLegacy;
BoundaryExchange and CommunicationMean have different orientation defaults;
state declarations determine their state-kind discriminator. A nonempty or
whitespace-only description remains exact. Present-empty optional strings or
collections, unbounded multiplicity versus a finite default, selected operation
intent, and negative coordinate zero remain distinct values. A nondefault
geometry record retains all required coordinates or dimensions.
Only specified optional fields inside selected constructors may be omitted.
For example, Integer bounds and LegacyPortContract.interface may be absent;
String.minimum_length, Signal.items, port-contract payload lists, and historical
snapshot name/description fields remain required. A LegacyPortContract record
still requires direction. Historical semantic baseline payloads are retained
without generic empty/default pruning. Compact output MUST preserve every
persistent model field after parsing, including these distinctions.
Comments and input whitespace are lexical trivia to the canonical writer.
Canonical export does not preserve them. The source-project editor and compiler
preserve authored comments and whitespace on Apply while inserting missing
@@ -1890,11 +1921,19 @@ adjusts to the destination scope; other token spelling remains authored.
Updates MUST NOT canonicalize surviving declarations in full. Header, field and
nested value positions are derived from the existing syntax parser. Unchanged
fields retain their exact bytes, including field order, omitted defaults, number
fields retain their exact bytes, including field order, explicit and omitted defaults, number
and string spelling, comments, indentation and line endings. Changed literals and
references replace only the required tokens; a reference with comments between
``@`` and its alias retains those comments. A previously omitted default is
inserted only if its semantic value changes. New fields use the existing record's
``@`` and its alias retains those comments. A previously omitted field is
inserted only when needed to express the requested value in its new declaration
context. This includes an unchanged value whose omission default changes with
the declaration kind. For example, changing BoundaryExchange to CommunicationMean
while retaining orientation true requires ``oriented true;`` if previously
implicit. Unchanged explicit defaults MUST survive unrelated sibling edits,
including persistence-serializer omissions such as ``operation none``,
``port_anchors []`` and ``baseline.semantic none``. New fields and value fragments
use compact generation while retaining required selected-constructor payloads.
New fields use the existing record's
indentation and line-ending style without reformatting its other fields.
A constructor tag change retains shared nested fields in place. Removed fields,
@@ -2173,7 +2212,7 @@ Text edits describe a complete candidate and must remove or repair dependencies
explicitly before Apply succeeds.
8.1. Focused diagram removal
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Delete is scoped to the focused diagram and the exact visible selection.
Text fields retain their own Delete behavior; diagram shortcuts MUST NOT apply
@@ -2294,8 +2333,9 @@ This compatibility applies equally to source and JSON. It adds explicit
defaults without changing any prior identity, name, reference, order, geometry,
artifact or trace field. The original V2 golden source/JSON in
``crates/oa-core/tests/fixtures`` MUST NOT be regenerated from the newer demo;
they verify that every old persistent field survives. Canonical output writes
the added defaults through explicit migration to the current schema 7.
they verify that every old persistent field survives. Canonical output uses
the current schema 7 and omits values equal to its specified source defaults;
parsing recovers the complete migrated model.
The V2 adapter preserves every original identity, alias, prose, parent,
placement, trace and artifact. Generic ports become Legacy with their original