Skip to content

v1.1.0 — PB Decimal wire fix, keyed repeated fields

Latest

Choose a tag to compare

@bfrancojr bfrancojr released this 31 Oct 22:58
· 28 commits to main since this release
9eb88f8

Fixed

  • pxf.Decimal.scale and pxf.BigFloat.exponent are plain varints on the
    PB wire
    (#55). Protowire.Pb read and wrote both with zigzag, but
    bignum.proto declares them int32, so it disagreed with every other
    port on every non-zero value: a wire scale of 2 read as 1, and 4096 as
    2048. Bytes written by earlier versions read back wrong. This is the
    bug protowire-go fixed in protowire-go#96 (STABILITY.md § v1.13).
  • A zero magnitude is empty on the PB wire. Protowire.Pb wrote a zero
    BigInt, Decimal.unscaled or BigFloat.mantissa as one 0 byte, and
    kept a BigFloat zero's exponent. A zero now has the one encoding
    STABILITY.md § v1.13 describes. Earlier bytes still decode.

Changed

  • The vendored shared schemas are re-synced with trendvidia/protos v0.1.2 (trendvidia/protowire#447). They gain protos' file options, and envelope.proto's go_package now names a published package. Declarations and field numbers are unchanged, and so is this port's public API.

  • Proto bindings are regenerated by tool/generate.sh, not buf generate
    (#24). buf generate proto wrote to src/Pxf/, src/Envelopes/,
    src/Sbe/ — directories no project compiles — while the compiled
    copies under each project's Generated/ folder were left as they were,
    and the SPDX header was lost on every run. buf.gen.yaml now targets a
    gitignored .generated/ staging tree; the script moves each file to the
    project that compiles it, prepends the header, and refuses output it
    has no table row for. tool/generate.sh --check runs in CI and fails on
    drift, a missing header, or an orphaned binding. The four committed
    stray copies are removed.

  • A map's { and every PB map entry count toward the nesting limit
    (protowire#449, HARDENING.md § Recursion). The PXF decoder did not count
    a map's own {, and PB counted neither a map entry nor anything about a
    scalar-valued one, so maps could nest past the limit in both. This
    narrows what decodes: a document nesting maps past 50 levels is now
    rejected, as it is by the text parser here and by protowire-go.
    check-decode's Tree gains branches and tags. Without them the
    corpus rows for this were skipped as unknown fields and tested nothing.

Added

  • Quoted entry names and keyed repeated fields (#15, trendvidia/protowire#116). The parser accepts a string as a field-entry name and the AST keeps the unquoted value plus Assignment.KeyQuoted / Block.NameQuoted, so Format reproduces the spelling. (pxf.key) = 1316 is back in proto/pxf/annotations.proto, and a repeated message field carrying it can be written as a block of named blocks: the entry name fills the key field and entry order is list order. The decoder rejects duplicate names (compared unquoted), an empty key in either surface form, an entry name that disagrees with an explicit key assignment, and a quoted name outside a keyed block, as KeyedException with a KeyedErrorKind. The encoder writes the keyed form whenever every key is present, non-empty and distinct, and the anonymous list form otherwise. Keyed.Canonicalize is the schema-aware half of fmt; run it before Format.FormatDocument. Schema.ValidateDescriptor and Schema.ValidateFile report misplaced (pxf.key) annotations across the import closure, and Decoder refuses such a schema. The pb and SBE wire outputs do not change. The cross-port fixtures from the spec repo's testdata/keyed are vendored under tests/Protowire.Pxf.Tests/testdata/keyed and all run.

  • dump-envelope --pb FDS MESSAGE DOC and --sbe FDS MESSAGE DOC (#26),
    the two legs of protowire's cross_envelope_check.sh that prove a port
    reads (pxf.required) = 1314, (pxf.default) = 1315 and the SBE
    numbers 1319–1323 from a schema. Decoder.UnmarshalFull and Sbe.Codec
    already read them from the generated types' descriptors; the dumper maps
    MESSAGE to those types (settings.v1.Settings generated from a copy of
    protowire's testdata/annotations/settings.proto, bench.v1.Order from
    sbe-bench.proto) and reads FDS only to check it declares MESSAGE.

Fixed

  • MaxNumericLiteralDigits is enforced (#34, HARDENING.md § Mandatory
    limits). The port had no digit cap, so a big-number literal of any length
    reached BigInteger.Parse, on generated messages, POCOs and
    (pxf.default) strings alike. A pxf.BigInt, pxf.Decimal or
    pxf.BigFloat literal of exactly 4096 significant digits now decodes and
    one digit more is rejected naming the limit. Leading zeros, the sign, the
    point, an exponent and a precision suffix are not counted (protowire#410).
    A pxf.Decimal literal's scale is bounded by the same number.
    check-decode links adversarial.v1.BigNumHolder. It did not, so
    pxf/long-numeric was rejected as an unknown schema, never by a cap.

  • uint32 / uint64 fields decode (#26). The reflection decode path
    had no branch for uint or ulong, so a generated message with either
    was rejected with unsupported type System.UInt64; protowire's shared
    sbe-bench.pxf tripped it at order_id.

  • (pxf.required) with (pxf.default) on one field is refused when the
    schema is bound
    (#57, draft -01 "Required and Default"). Decoder used
    to accept such a schema, and which option won depended on whether the
    document omitted the field and on which engine read it. Unmarshal and
    UnmarshalFull now check the file declaring the bound message and its
    transitive imports before reading the document, and
    Schema.ValidateDescriptor / Schema.ValidateFile report the same
    violations. (pxf.required) = false beside a default stays accepted.
    [PxfRequired] with [PxfDefault] on one property of a hand-written type
    is refused the same way.

  • Nesting depth counts every descent, from a root at depth 0 (#33,
    HARDENING.md § Recursion). The PXF decoder did not count a [, so
    children = [{ … }] nested twice as deep as the limit said, and it did
    not bound a value skipped for an unknown field at all; both now count
    from the enclosing body. An Any body written as details { @type … }
    counted its one { twice, and so did the text parser for a directive
    body, which rejected a document one level short of the limit. PB now
    counts a map entry as a descent when its value is a message.
    check-decode's Tree gains the children field the corpus rows
    pxf/deep-nesting-lists-100 / -101 use. Without it those rows were
    skipped as an unknown field and never reached the list decoder.