[v0.1/P1] Make the unset-means-default unions explicit oneof variants #331
Labels
No labels
priority/P0
priority/P1
priority/P2
release/v0.1.0
status/blocked
status/planned
type/bug
type/design
type/test-gap
type/tracker
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
natsukium/felis#331
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
The project's own rule is "when the presence of a field is what selects a mode, the mode belongs in a type", and "optional fields are for data that is genuinely absent". Three unions still use an unset arm to carry meaning, so a non-Rust peer reading the descriptor cannot see the mode.
Findings
1.
SessionAttachsibling target fieldsSessionAttach(felis.proto:1664-1673) carriesidandid_prefixas sibling fields with "exactly one set" enforced only by the validator. The proto comment rejects aoneofsolely because it "would renumber a released field" — no released field exists before the freeze. Make it:Then "both set" and "neither set" are unrepresentable in the schema instead of being decode refusals, and a generated peer reads the choice from the descriptor.
2.
RetargetTargetunset carrier means "default local"RetargetTarget(:2060-2061) documents an unsetcarrieras the third, default-local arm. Add an explicit empty variant (RetargetLocal {}) so the union has three named arms and the "nothing to carry, so unset" convention disappears. The byte cost is one tag-length on a one-shot request.3.
OpsStopunset mode meansif_emptyOpsStop(:2145-2148) treats an unsetmodeoneof asStopIfEmpty, whileSwitchScopedeclares an unset oneof malformed. Pick one policy for mode-selecting oneofs and apply it to both.Acceptance criteria
convert/,docs/reference/ipc.md, and the protocol tests match.CHANGELOG.mdrecords the wire change.Related
Duplicate of #327, which already tracks all three cases (RetargetTarget.carrier unset, OpsStop.mode unset, SessionAttach id/id_prefix siblings) plus the theme/palette reset spelling. Filed before the earlier review comment was visible; nothing unique here. Closing so the tracker keeps one issue per finding.