Skip to content

formats: an ElementIdRef's sub is the next field's name length on about 93% of references #1101

Closed

Description

@DrunkOnJava

FieldType::ElementIdRef { referenced_tag, sub } reads a reference field's encoding as 0e 00 00 00, the referenced class's tag (u16), and a second u16 it documents as "secondary discriminator (meaning unknown; empirically varies per-field and per-version)". Measured over the whole page-stripped schema of the 2024, 2026 and 2027 sample families (Measure run 40949596730, examples/probe_re264_schema_field_encodings.rs, RE-264 §4): where the reference is followed by another field of the same class, sub equals the length of that next field's name on

Schema sub == next name length sub == 0 other
2024 1,819 124 1 (2)
2026 1,932 133 1 (2)
2027 1,966 135 1 (2)

So on most references sub is the low half of the next record's u32 name length: the encoding is six bytes, 0e 00 00 00 <tag>, and only some references carry two zero bytes after the tag. The same spill decides ElementId against ElementIdRef { referenced_tag: 0x14, .. }, which is why several fields flip between the two across releases when only their neighbour changes (ParamValueDouble::m_paramId, CurveAssocProp::m_assocId).

What would settle it: whether the six-byte and eight-byte forms differ in meaning (the two zero bytes on the 124 to 135), checked against the next-record boundary the parser already finds by name. If sub is the spill, ElementIdRef should drop it (a breaking change to the public variant, or a documented "not part of the encoding"), and encode should not write it back. No reader depends on sub today; the schema writer (encode) does.

Activity

  1. added
    area:reader
    area:writer
    on Oct 29, 2026
  2. DrunkOnJava commented on Oct 29, 2026

    @DrunkOnJava
    OwnerAuthor

    Scope check (main 2713706): nothing in the library serializes a schema record from FieldType::encode. Its only callers are examples/probe_schema_roundtrip.rs and examples/probe_re264_schema_field_encodings.rs, and the writer (writer.rs) copies Formats/Latest byte for byte. So the spilled sub reaches no written file today; it is a reading and naming problem in ElementIdRef, plus a wrong round-trip promise in encode's doc comment for six-byte references.

  3. added a commit that references this issue on Oct 30, 2026
  4. added
    priority:P1
    type:bug
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:readerarea:writerpriority:P1type:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions