Skip to content

Go: the table wire's id-table form (#435) #511

Description

@gafferongames

The table wire moved to its id-table form in #507 (docs/SPEC-TABLES.md §3): the form byte, id reference, kind, payload terminated by the zero reference, canonical LEB128 for every length, count, index and reference, sixty-four-bit identity, and the trailing id table located from the end. The C++ reference and the compiler's own engine carry it; this port still writes the previous form.

What moves

  • Identity at sixty-four bits. A field's id, an enum variant's, a union arm's and a table's own name id are all fnv1a64(name), no fold and no rebound. The reserved node-table id is 0xFFFFFFFFFFFFFFFF.
  • Every number is a canonical LEB128 — length, count, index, id reference — and a non-minimal spelling is malformed. A length cannot be patched in place any more, so every body's length is measured before it rides.
  • The id table. Every id the body used, once each, in first-use order over the whole wire; the body names them by 1-based reference, and reference 0 names no id. It is the last thing in the file and a reader finds it from the END: the final eight bytes are the entry count, a fixed little-endian u64.
  • The form byte is 1 and is read FIRST. A byte this reader does not know is a REFUSAL by name, never damage, and the read report carries a verdict beside its five counters.
  • Three kinds: 30 an enum, carrying the reference to its variant name's id; 31 the escape; 32 the payload-free arm.
  • An arm header is a field header and carries the arm's KIND, so a retyped arm is an ordinary kind mismatch.
  • The node table rides in ONE field under the reserved id — a 64-bit L frames a numbering of any size.

What to pass

The corpus is pinned in the new form. The five wire-carrying conformance surfaces are ABSENT for this port until the codecs move: wire, report, json-read, json-write and json-hostile — every surface whose expectation is wire bytes. Restoring them means passing, over testdata/conformance/tables/MANIFEST.txt:

  • every instance row byte for byte after a save, which holds elision, first-use order and distinctness at once;
  • every report row's five counters AND its verdict, including form_zero, form_two and form_ff (the refusal), the escape_* and nopayload_* rows (kinds 31 and 32 at every position), the a2_arm_* rows (the arm's kind byte and its length), and k1_as_k2 / k2_as_k1 (the enum kind against the raw integer);
  • tables-<lang>-wire-fuzz against the compiler's engine as the oracle, with the reference-class, id-table, canonical-spelling and form-byte passes §4.2 names.

Part of #349 and #435. PORTING.md carries the cell.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions