Context
The Basketry IR currently stores named definitions in separate top-level arrays for types, enums, and unions. In practice, these definitions already share a single logical namespace, since names must be unique across all three collections. This means consumers must search multiple arrays to resolve a named definition, even though the result is conceptually just “a named definition in the service.”
Because Basketry IR is machine-oriented and intentionally optimized for reparsing and inspection, this split adds unnecessary traversal and symbol-resolution complexity. The IR should provide a single obvious place to look up any named definition.
Change
- Replace the top-level
types, enums, and unions arrays with a single top-level definitions map.
- Use the definition name as the map key for direct lookup.
- Allow
definitions values to be Type, Enum, SimpleUnion, or DiscriminatedUnion.
- Preserve each definition’s embedded
name literal for source mapping and diagnostics.
- Rename
ComplexValue to DefinedValue.
- Rename
ComplexValue.typeName to DefinedValue.definitionName.
Consequences
- Named definition lookup becomes simpler and more efficient for rules, generators, and other tooling.
- Duplicate names across definition kinds become structurally impossible within a single service.
- The IR more clearly models named definitions as a single symbol table.
- Source-mapped name literals remain available after lookup for diagnostics and provenance.
- Requires Basketry validation to ensure each definition map key exactly matches
definition.name.value.
- Consumers will need to migrate from array traversal to keyed definition lookup.
- This lays the groundwork for future definition kinds, such as aliases, without requiring another namespace redesign.
Context
The Basketry IR currently stores named definitions in separate top-level arrays for
types,enums, andunions. In practice, these definitions already share a single logical namespace, since names must be unique across all three collections. This means consumers must search multiple arrays to resolve a named definition, even though the result is conceptually just “a named definition in the service.”Because Basketry IR is machine-oriented and intentionally optimized for reparsing and inspection, this split adds unnecessary traversal and symbol-resolution complexity. The IR should provide a single obvious place to look up any named definition.
Change
types,enums, andunionsarrays with a single top-leveldefinitionsmap.definitionsvalues to beType,Enum,SimpleUnion, orDiscriminatedUnion.nameliteral for source mapping and diagnostics.ComplexValuetoDefinedValue.ComplexValue.typeNametoDefinedValue.definitionName.Consequences
definition.name.value.