Problem
The schema string that Yardl embeds in every binary/NDJSON file does not record whether an enum-like type is a !flags type. As a result, a !flags definition and an !enum definition are byte-for-byte identical in the embedded schema. Any consumer that works purely from the embedded schema (e.g. a dynamic/schema-only reader, or a third-party tool) cannot reproduce Yardl's own flags semantics, and cannot even reproduce Yardl's own NDJSON output for affected protocols.
Concrete differences between Yardl's SDK output and a schema-only reader on the models/test/unittests.yml protocols:
| Protocol |
Yardl SDK |
Schema-only reader |
Flags — MONDAY+WEDNESDAY+FRIDAY |
["monday","wednesday","friday"] |
21 |
Flags — SUNDAY |
["sunday"]` |
"sunday" |
Enums — RecordWithEnums.flags |
[] |
0 |
Unions — [null, Fruits, DaysOfWeek] holding Fruits.APPLE |
"apple" (simple) |
{"T1":"apple"} (tagged) |
These are the only fidelity differences observed across all 29 protocols in unittests.yml; everything else round-trips byte-for-byte. (Discovered while prototyping a dynamic, schema-only binary reader.)
Proposed fix
Emit the flags marker in the protocol schema. Simplest is to give EnumDefinition a custom MarshalJSON (or add an isFlags field) so the embedded types[] carries it — mirroring the existing enum/flags distinction in TypeDefinitions.MarshalJSON.
Problem
The schema string that Yardl embeds in every binary/NDJSON file does not record whether an enum-like type is a
!flagstype. As a result, a!flagsdefinition and an!enumdefinition are byte-for-byte identical in the embedded schema. Any consumer that works purely from the embedded schema (e.g. a dynamic/schema-only reader, or a third-party tool) cannot reproduce Yardl's own flags semantics, and cannot even reproduce Yardl's own NDJSON output for affected protocols.Concrete differences between Yardl's SDK output and a schema-only reader on the models/test/unittests.yml protocols:
Flags—MONDAY+WEDNESDAY+FRIDAY["monday","wednesday","friday"]21Flags—SUNDAY"sunday"Enums—RecordWithEnums.flags[]0Unions—[null, Fruits, DaysOfWeek]holdingFruits.APPLE"apple"(simple){"T1":"apple"}(tagged)These are the only fidelity differences observed across all 29 protocols in unittests.yml; everything else round-trips byte-for-byte. (Discovered while prototyping a dynamic, schema-only binary reader.)
Proposed fix
Emit the flags marker in the protocol schema. Simplest is to give
EnumDefinitiona customMarshalJSON(or add anisFlagsfield) so the embeddedtypes[]carries it — mirroring the existingenum/flagsdistinction inTypeDefinitions.MarshalJSON.