Skip to content

refactor(hm-plugin-protocol): Mark the wire-protocol BuildEvent enum #[non_exhaustive]#123

Merged
markovejnovic merged 2 commits into
mainfrom
cq/hm-plugin-protocol-mark-the-wire-protocol-buildevent-enum-n-27
Jun 10, 2026
Merged

refactor(hm-plugin-protocol): Mark the wire-protocol BuildEvent enum #[non_exhaustive]#123
markovejnovic merged 2 commits into
mainfrom
cq/hm-plugin-protocol-mark-the-wire-protocol-buildevent-enum-n-27

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

The smell

BuildEvent in crates/hm-plugin-protocol/src/events.rs is the central wire event type for the build event stream. It is a plain, exhaustive pub enum, matched exhaustively in hm-render (progress.rs, human.rs) and hm-exec. The protocol is explicitly designed to grow — several variants' doc comments already describe them as "replacing ad-hoc log lines," and more event kinds are expected over time.

Because the enum is exhaustive, adding any new variant is a breaking change for every downstream match and a semver-major bump for the crate.

The change

Add #[non_exhaustive] to enum BuildEvent. This is a single-attribute change in this crate. Downstream match arms over BuildEvent will then need a _ => {} wildcard, after which new variants can be added without breaking external callers.

Type-safety pattern

This applies the #[non_exhaustive] pattern used by diesel and ripgrep (and the standard library's own error/event enums) for public enums that are expected to grow — error kinds, event types, message kinds. It converts "adding one variant is a major break for every matcher" into a non-breaking change, while the compiler still enforces exhaustiveness for matches inside this crate. BuildEvent is the prototypical growing event stream.

Validation

Only cargo check -p hm-plugin-protocol was run locally (passes). The full build and TS build were intentionally not run. Full CI runs on this PR.

This is a draft pending review. The change is behavior-preserving (an attribute only); it does not alter serialization or runtime behavior. Downstream crates in this same workspace already match exhaustively, so CI will confirm whether any in-workspace matcher needs a wildcard arm added (a non-#[non_exhaustive] enum allows in-crate exhaustive matches, but #[non_exhaustive] only forces wildcards for out-of-crate matchers — so in-workspace matches should be unaffected).

@markovejnovic markovejnovic marked this pull request as ready for review June 10, 2026 20:13
@markovejnovic markovejnovic merged commit 804247d into main Jun 10, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant