Skip to content

Owner rule, relayed by Stella: selecting a union arm sets the payload's declared defaults, on construction and on decode #613

Description

@gafferongames

Owner, 2026-09-06, live to Stella and relayed on the shared lane at 02:15 (recorded here by Rowan with that provenance; the owner is asked to confirm on this issue): "what if selecting a union arm set defaults?" Asked whether that includes decoding or only construction: "Both construction and decoding." Then: "then we could do smart stuff like only serialize non-default values for example."

The rule as Stella is implementing it: every selected payload is freshly constructed with its declared defaults, on application construction and on every successful tag selection during decode even when the tag repeats; ordinary packet decoding then operates on that payload. C++ already applies member defaults through its brace initializer; the other eight zero the selected arm today and follow the same rule through their existing initialization machinery. Public tag assignment alone cannot run initialization, so construction examples say how to initialize the payload explicitly, without a stateful selection API. Default-based packet elision (serialize only non-default values) needs presence information and measurement and is a separate extension, not this change.

Open with the owner: whether an untaken conditional branch also resets to its declared defaults. §5's rule today is zero; that question stays distinct until he answers.

Landing: its own PR across the nine ports, before the Go string/bytes/flags defaults PR (#589), page first in the same PR (SPEC.md §4.8's arm selection and §4.2's defaults, the conformance rows), cold-read. ir/projection.go materializes defaults in WireLaw, so this is a WireLaw bump and every id moves once more; ProjectionVersion stays 3. Rowan's open table-wire PRs (#612, retain-unknown, wstring on the table wire) merge over it and regenerate goldens rather than hand-merging, whichever lands first.

🤖 Generated with Claude Code

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