ADL 9 · Part I — Documents and conformance

0.5.1 baseline + 0.6 edition note

Canonical serialization and digests

ADL 0.6.0 reference · Review draft 1 · November 14, 2026.

Contents · Source map · Evidence

The 0.6 edition note

This chapter retains the detailed language contract and its source-specific observations. Its chapter number and numbered sections remain stable. The 0.6 additions do not by themselves change this subject’s defaults or supply fresh execution evidence for it.

Reverification should cover canonical bytes and digest stability across source order and serialization. Use the original examples and evidence links below to recover the earlier test context. The new edition’s source map records this chapter as inherited detail; the current draft does not claim those historical tests were rerun.

Retained reference detail

The numbered sections below are carried from 09-canonical-serialization-and-digests.md. Their original baseline and evidence remain attached to the source. Statements about “current” or “checked” behavior in this retained text refer to those original observations unless the edition note explicitly updates them. This is a consolidated draft, not a claim of complete re-verification.

9.1 Purpose and scope

Canonical serialization gives a model a reproducible byte representation. A digest identifies those bytes. Equivalent inputs should produce identical canonical bytes; changes that affect the canonical model should change them. SHA-256 provides collision resistance, not a mathematical guarantee that different byte strings can never share a digest.

Draft 05 §21.1–§21.6 governs this chapter. There is no standalone legacy ADL 9 body. The recorded enum-order ruling narrows order-semantic mappings to enum values; the earlier Phase-09 delivery note’s broader proposal is superseded. The Spec-04 ruling requires Lua bodies in source-digest coverage and makes publisher signing a v0.5.1 non-goal. The source correspondence is in the revision record.

Failure classWhat happenedConsequence
False differenceEquivalent models produce different bytesDigest churn, unnecessary lockfile changes, misleading change detection
False identityDistinct models produce identical bytesA meaningful change can escape integrity or change checks

The second deserves particular attention under §21.1. A stable hash function cannot recover distinctions already lost while parsing or constructing the canonical model. The decimal observation in §9.6 demonstrates that boundary.

ADL 4 owns ingestion and the parse pipeline; ADL 6 owns version admission and monotonicity; ADL 7 owns addresses and pins; ADL 8 owns imports and lockfile verification. This chapter owns the bytes and the meaning of each digest.

9.2 Source and resolved digests

Every domain has two digests. Each consumer MUST name which one it uses (Draft 05 §21.2). A YAML file checksum, an exporter hash, a source digest, and a resolved digest are not interchangeable.

DigestGoverning inputMeaning and consumers
SourceCanonical authored node after $include, before ${VAR}, plus the package path-to-file-digest manifestIdentifies the authored package; retained by lockfiles and detached derivedFrom provenance
ResolvedCanonical fully resolved model after references, merges, traits, and applicable pin resolutionIdentifies resolution output; used by lockfiles, artifact identity, and change detection

The source digest MUST remain independent of deployment environment and resolver changes for the same published source package. The resolved digest depends on what resolution produces. A resolver upgrade can legitimately change it, but an existing lockfile then requires verification and any mismatch must be handled as ADL 8 specifies.

The conceptual computation is:

authored document
  → expand $include
  → canonical authored node + package file manifest → bytes → SHA-256 → source
  → substitute ${VAR}; resolve composition and applicable pins
  → canonical resolved model, with provenance outside it → bytes → SHA-256 → resolved

This describes the governing stages, not a promise that one low-level parser call fetches every dependency. Cross-suite work may require a resolver with registry context. §9.10 explains how that affects a claimed resolved digest.

Both hashes can be equal in a simple document with no effective expansion or additional package files. Equality does not eliminate either field. Conversely, a changed hook file can change only the source digest in the checked parser; the lockfile must retain both forms of integrity evidence.

9.3 Ingestion order and canonical order

Ingestion preserves declaration order. Canonical emission applies the ordering rules for the collection being serialized. These are separate responsibilities: sorting every mapping at input would destroy enum order before the canonicalizer could preserve it.

The governing §21.3 requirements are:

RuleRequired treatment
Parsed representationCanonicalize nodes/models at the specified stage, rather than formatting or hashing raw YAML
Complete versioned modelEmit every defined canonical field, including defaults from the frozen table selected by adl
Ordinary mappingsNormalize keys to NFC, then sort by Unicode codepoint, independent of locale
SequencesPreserve order; apply an explicitly specified collection exception where one exists
Numeric valuesPreserve exact values without a binary-float round trip; decimal encoding is specified in §9.6
ProvenanceKeep provenance outside the hashed representation by structure
Shared implementationUse the canonicalizer in the production parser; the CLI MUST NOT independently implement it
Conformance evidencePublish paired byte-level vectors for equivalence and distinction
Mapping keysTreat scalar keys as literal text; reject non-scalar keys with KEY_NOT_SCALAR

Comments and scalar quoting are presentation differences only when the parsed values remain the same. Quoting a boolean or number can change its type; true and "true" are not automatically equivalent values. Reordering ordinary field mappings can preserve canonical bytes while the parser still retains a different field declaration order in its model.

Checked implementation. The shared canonical_cbor helper transforms an ordered JSON tree into a sorted ordinary JSON tree, with enum-pair and suite-list exceptions, then emits CBOR. It does not perform NFC normalization or complete the versioned default model. These limitations do not replace the requirements. §9.5 also identifies a conflict between the map rule and the selected CBOR profile.

9.4 Ordered collections and enum pair arrays

The governing ordered set in §21.4 includes:

CollectionWhy order matters
$merge listsLater entries win conflicts
Applied traits listsApplication order affects compatible overrides and composition
$include listsLater files can override earlier content
Index field listsColumn order affects the index
Enum value listsOrdinal position may be persisted

For mapping-form enum values, canonical emission preserves declaration order by representing the members as arrays of [name, body] pairs. The author still writes the accepted enum mapping. The pair array is a serialization form, not a request to rewrite the ADL declaration.

This contextual fragment occurs in the complete example in §9.7:

enums:
  State:
    values:
      draft: {}
      posted: {}

Its canonical value sequence is structurally [["draft", {}], ["posted", {}]]. Swapping the two members changes the canonical bytes. All other mappings sort under the ordinary map rule. The Owner’s closed list does not extend pair-array emission to object fields, resources, state declarations, transitions, or every mapping that a user interface displays in declaration order.

suite.domains is explicitly unordered: canonical emission sorts its entries by normalized member locator. Reversing that list alone MUST preserve bytes. This exception does not make every YAML sequence unordered. The broad “all other collections” sentence in §21.4 needs editorial reconciliation with §21.3 rule 4’s sequence requirement; this draft retains the explicit sequence rule and named suite exception. New collection kinds require classification.

Checked limits. The helper preserves ordinary arrays and sorts root suite.domains strings. It does not normalize equivalent locator spellings: a.yaml and ./a.yaml produce different helper bytes. It also recognizes order-semantic mappings by the key name values alone. An unrelated values mapping in an extension-shaped tree becomes a pair array. That probe does not establish accepted extension grammar; it identifies a missing schema-context check in the helper.

9.5 CBOR bytes and the unresolved ordering profile

Draft 05 §21.6 selects deterministic CBOR. Canonicalization emits a separate binary representation; it does not canonicalize YAML formatting in place. Digest comparison uses SHA-256 over the exact emitted bytes (§23.5).

For the illustrative parsed tree {"b": 2, "a": 1}, the checked helper emits:

CBOR hex: a2616101616202
SHA-256:  a0d3af9e86e5517f729bad0657e2c6f3b7d03899894c8d6b33759074c893b5e3

The seven bytes encode a two-entry map containing text keys a, b and integer values 1, 2. Reversing the input mapping produces the same bytes. This is a small helper example, not a complete ADL document or newly ratified vector.

A specification conflict requires a ruling. ADL §21.3 sorts normalized text keys by codepoint. RFC 8949 §4.2.1 sorts keys by their complete encoded bytes. Those orders differ for aa and z: ADL’s rule puts aa first; the RFC puts z first because its text encoding starts with a smaller length header. RFC 8949 §4.2.1

TreeChecked helper bytesRFC core deterministic order
{"z": 0, "aa": 0}a262616100617a00a2617a0062616100

The implementation follows the ADL text-key sort in this example. Calling those bytes fully conforming to the selected RFC profile would conceal the conflict. This draft preserves both cited requirements and the observed result; it does not select a new wire profile or silently regenerate published digests.

There is also an implementation difference in floating-point width. The checked tree {"value": 1.5} emits a16576616c7565fa3fc00000, using binary32 for 1.5. The RFC requires the shortest exact representation, which is binary16 here; the corresponding map bytes are a16576616c7565f93e00. RFC 8949 §4.2.1

These two examples do not change the separate rule that ADL decimal values use text. The helper emits definite-length containers and compact integers in the checked examples, including an integer beyond binary64’s consecutive-integer range. Successful decoding or stable SHA-256 output alone does not establish the selected deterministic encoding profile.

9.6 Exact decimals, literal keys, and Unicode

The later decimal ruling in Draft 05 §21.6 selects CBOR text containing the exact decimal literal, rather than tag 4. A decimal default, threshold, or constant MUST NOT pass through a binary float before canonicalization. The earlier explanatory mention of tag 4 is not the selected ADL representation.

Use an exact quoted decimal in the authoring example:

amount:
  type: decimal
  precision: 20
  scale: 17
  default: "0.10000000000000001"

The complete YAML and equivalent JSON-string examples preserve that literal and produce identical digests. The production field’s default remains the full string. Distinct quoted literals remain distinct canonical text; the chapter does not introduce arithmetic normalization that removes trailing zeros.

Observed precision loss. The parser accepts unquoted 0.10000000000000001 and 0.10000000000000000 in the same decimal field. Both become binary numeric 0.1, both yield model default string 0.1, and both produce the same source and resolved digest. That is loss before hashing, not a SHA-256 collision. The canonical helper preserves the ingested scalar type; it does not recover a decimal literal by consulting the field schema. Quoted exact values work, but accepting these lossy inputs is not conformance to the numeric requirement.

Mapping keys follow a different rule from ordinary scalar values. Bare on, yes, no, true, false, null, and 0644 are literal text keys; quoting those keys MUST preserve their canonical text identity. The checked ingestion helper produces identical bytes for the bare and quoted key maps. No claim that these are all valid domain declaration names follows from that generic mapping check. Quoting keys remains useful for third-party tools.

A non-scalar key MUST reject with KEY_NOT_SCALAR. The two checked ingestion paths disagree: AdlDirectives::content_to_json rejects a sequence key with a generic conversion error, while parse_and_resolve accepts the complete negative domain input, converts the key to an empty string, and warns about an unknown domain key. Neither result establishes the required diagnostic contract; the latter also fails the required rejection.

NFC applies to map keys before sorting. The helper emits different bytes for the composed key é and its decomposed spelling e followed by U+0301. It also retains both spellings as separate keys when given together. Normalization and handling of keys that coincide after normalization require review. This is distinct from locale-independent sorting, and it does not authorize normalizing every string value in the document.

9.7 A complete example and its byte identity

The complete domain.yaml is:

# Complete illustrative digest example; language 0.5.0 is in the 0.5.1 accept-set.
adl: "0.5.0"
domain:
  name: ledger
  version: "1.0.0"
  enums:
    State:
      values:
        draft: {}
        posted: {}
  resources:
    Entry:
      object:
        id: { type: uuid, primaryKey: true }
        note: { type: string }
        amount:
          type: decimal
          precision: 20
          scale: 17
          default: "0.10000000000000001"

The language declaration is accepted by the checked 0.5.1 production parser and permits an independent adl-ref baseline comparison. A separately recorded variant declaring 0.5.1 also parses; changing the language declaration is a different input identity, not a presentation-only transformation.

presentation.yaml changes comments, quoting, and ordinary mapping order while retaining values and enum order. Both files parse without warnings in the production CLI and adl-ref. Both production parses emit 221 resolved CBOR bytes and this source/resolved digest:

073df6631143366d40be858a51228df6673622ebae7db00c39ddecdd3e8809cd

domain.cbor.hex preserves the actual bytes. The verifier independently recomputes SHA-256 over every retained emitted byte sequence using Python’s hashing library. It does not use a second ADL canonicalizer to declare those bytes conformant.

Change to the exampleChecked source/resolved result
Presentation changes, ordinary mapping order, equivalent JSON with decimal textBoth digests unchanged
Reverse enum mapping orderBoth digests change
Change note from string to textBoth digests change
Write the omitted required: false explicitlyBoth digests change despite equal parsed required values; default expansion gap
Change between the two quoted decimal literals in §9.6Both digests change
Use the two lossy unquoted decimal literalsBoth digests collapse to the same value

The example instructions reproduce these checks. The files are illustrative, not additions to the normative fixture set.

9.8 Expansion boundaries and versioned defaults

The source digest is taken after includes, before environment substitution. An included declaration and its equivalent already-expanded form therefore have the same authored canonical node. A raw-file checksum would not have that property. The package file manifest is a separate input to this process.

composed.yaml includes properties.yaml, whose string default is ${ADL9_LABEL:North}, then references that property in a resource field. With the variable set to North and South in separate checks:

DigestNorth versus South
SourceEqual: 4b07103db1c5de0d4b1e75514047bda2256a4807fbd19d4d1b33f2774949efd2
ResolvedDifferent; the bound field’s default is North or South respectively

The equivalent expanded include input matches both digests for North. A separate trait-order example changes the winning field default and both digests when [A, B] becomes [B, A]. Existing focused trait tests also check that a trait expansion and an explicit equivalent have equal resolved digests and DDL, and that provenance reaches the bound model.

Under §21.3 rule 2, defaults come from a frozen table selected by the document’s adl. Later language defaults MUST NOT be injected while canonicalizing an older declaration. Adding an explicit default that is already implied should not create a difference merely because one author wrote it down.

The checked parser computes the resolved digest from the transformed document tree after building the DomainModel; it does not serialize a complete default-expanded model. In the §9.7 example, required is false in both models, but the tree with an explicit key hashes differently. No versioned frozen-default table is applied by the canonical helper. Supporting both language declarations is not evidence that this default-stability requirement has been implemented.

9.9 Package files and provenance

The source digest MUST cover executable package content. Spec-04 R3 resolved §20 item 4: Lua bodies must participate, rather than only their names. Draft 05 §21.2 also includes seed files in its package-file description. The original “held pending source verification” wording is historical; the ruling and amended digest table govern.

The model does not contain every external file’s bytes. The checked parser accepts a caller-supplied mapping of package-relative path to SHA-256 and folds it into the source tree under an internal __files__ key. The saved manifest contains the actual SHA-256 of the example Lua file. The verifier reads and hashes that file; it does not execute Lua or exercise hook discovery. The simple ledger document itself declares no active hook.

File-set change with the same domain textChecked result
Add the manifestSource changes; resolved unchanged
Change the Lua body bytes under the same pathSource changes again; resolved unchanged
Move identical bytes to a different manifest pathSource changes; resolved unchanged
Supply an invalid per-file digest string directly to the parser APIAccepted and hashed; the caller’s manifest is trusted by this helper

__files__, the request channel __package_files, and set_package_files are implementation mechanisms. They are not extra authored ADL declarations. The generated manifest demonstrates the fold; it does not prove that every package entry point discovers and verifies all required files.

Source-inspection limits. The reviewed bootstrap scanner walks .lua files under the supplied directory, including files not selected by an individual hook declaration. It does not enumerate seed or license files in that walk; directory errors can leave a partial manifest. Ordinary parser calls perform no automatic package walk. The explicit-suite action computes aggregate digests using a parser before passing the package manifest to member submit requests. Complete suite/file-set coverage therefore needs separate execution evidence. The standalone bootstrap path also reparses expanded YAML on submit, so its stored source identity must not be inferred from the direct parser’s pre-substitution result without checking that path.

Provenance is a separate boundary. The governing rule excludes it structurally from hashing. The checked parser retains trait origin on the bound model and removes generated $origin tags before resolved emission. Calling the generic helper on a tree that already contains $origin still hashes that value: it does not decide provenance by key spelling. Detached derivedFrom.sourceDigest is authored content expressly required by §7.3; it is not disposable diagnostic origin metadata. ADL 14 owns those derivation distinctions.

9.10 Addresses, suites, and digest consumers

Draft 05 §21.5 requires unresolved cross-suite values to retain stable textual form. The resolved digest must cover both the authored constraint and the exact version selected. A range left as the selected address is non-conforming; preserving an authored constraint in resolution evidence is a different role. ADL 7 owns spelling and pins, and ADL 8 documents the resolver/lockfile boundary.

A function named canonical_digest does not resolve an address. The helper hashes the supplied tree; a parser result named resolved_digest does not prove that a later registry-dependent operation has finished. The ADL 8 evidence records the Phase-16 import branch separately. This chapter’s checked checkout and libraries do not establish remote resolution or complete pin coverage.

Suites have their own aggregate identity. In the reviewed submit action, a suite’s root is canonicalized after replacing its member locator entries with the members’ source or resolved digests. The resulting digest list is sorted by the suite-list helper. This is the implementation’s aggregate construction, not a definition of a domain digest or proof of the package-file coverage noted in §9.9. ADL 5/6 own suite submission and version-change consequences.

Consumer or outputRequired distinction
LockfileRecords both source and resolved digests; mismatch handling belongs to ADL 8
Detached derivedFromEmbeds the required source digest; sole authored exception in the reuse contract
Version/change checksIdentify which digest comparison was performed; ADL 6 records current gate limitations
Source endpointReviewed action exposes source_digest, resolved_digest, adl_version, and resolver identity
YAML/JSON exportHuman-readable representation; hashing its text is not the specified CBOR digest
lockfileDigestDigest of a separate lockfile tree; not either provider digest or the importer’s resolved-model digest

The endpoint observation here is source inspection, not a live HTTP check. An endpoint’s canonical alias for resolved text also does not make returned YAML the canonical binary form. Digest integrity establishes neither publisher identity nor license entitlement. Signing remains a ratified v0.5.1 non-goal.

9.11 Diagnostics and conformance vectors

Canonical conformance is byte equality against published fixtures; digest comparison is secondary and uses SHA-256 over those bytes (Draft 05 §23.5). The ratified fixture shape is YAML, one vector per file, with vector, class, input, and expect, including cbor_hex and sha256 for canonical vectors. ADL 2 owns fixture conventions and conformance claims.

Required vector familyEvidence obtained for this chapter
Presentation-equivalent documentsComplete YAML pair and JSON-text variant have equal production bytes/digests
Ordered and unordered collectionsEnum and sequence distinctions; suite-list permutations agree; locator normalization gap explicit
Exact decimalsQuoted text retained; unquoted false identity recorded
Frozen language defaultsMissing default expansion demonstrated; no complete table verification
Semantic changesField type, enum order, trait winner, and package-body distinctions checked
Environment separationSource stable, resolved different for the complete include/reference example
Lockfile digest mismatches and manifest digest rejectionOwned by ADL 8’s separate recorded checks
Literal scalar and non-scalar keysLiteral-key equality checked; rejection/diagnostic disagreement recorded
Unicode and deterministic encoding profileNFC, map ordering, and float-width limitations made explicit

KEY_NOT_SCALAR, SOURCE_DIGEST_MISMATCH, RESOLVED_DIGEST_MISMATCH, and MANIFEST_DIGEST_FORBIDDEN name governing failures in their applicable contexts. A generic canonical helper does not necessarily issue a language diagnostic or HTTP status. No new error code is invented here for NFC, default-table, or CBOR-profile deficiencies.

The independently invoked adl-ref modeller accepts both complete baseline documents without warnings. Its checked surface supplies no §21 CBOR bytes or source/resolved digest oracle. Its include-file hashes and diagnostic-registry fingerprint serve different purposes. Parser agreement therefore supplements example validation without establishing independent canonicalization agreement.

9.12 Verification and remaining review

The evidence record retains 50 adapter cases, four CLI/modeller checks, and 20 passing existing Release tests, plus exact CBOR bytes, SHA-256 checks, and source/binary identities. The adapter uses production parser/canonicalizer code with the recorded libraries. It performs no server deployment, database mutation, registry fetch, or Lua execution.

The checked source revision is 42da0411; the existing build configuration identifies e3effddd-dirty. Archived headers and executable hashes are recorded separately. A fresh production build from the reviewed HEAD is not claimed.

Publication review must resolve the CBOR map-order profile, implement NFC and its collision handling, preserve decimal exactness at admission, complete the versioned default model, and enforce non-scalar-key rejection consistently. Schema-aware enum classification, normalized suite locators, package-file completeness across entry points, provenance separation, and final pin coverage also need their specified evidence. This chapter remains Draft 1; stable outputs on the supplied examples do not make these gaps conforming behavior.