Skip to content

refactor(hm-config): Mark public config structs #[non_exhaustive]#120

Merged
markovejnovic merged 1 commit into
mainfrom
cq/hm-config-mark-public-config-structs-non-exhaustiv-25
Jun 10, 2026
Merged

refactor(hm-config): Mark public config structs #[non_exhaustive]#120
markovejnovic merged 1 commit into
mainfrom
cq/hm-config-mark-public-config-structs-non-exhaustiv-25

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

Smell

Config, CloudConfig, and Preferences in crates/hm-config/src/lib.rs are public structs with all-public fields and no #[non_exhaustive]. They are designed to grow over time (config knobs), but every new field is a breaking change for any external struct-literal constructor, and downstream code can build partially-validated configs by hand, bypassing the centralized Default/load_from_paths construction path.

Change

  • Added #[non_exhaustive] to Config, CloudConfig, and Preferences.
  • Updated the internal save_and_reload_roundtrip test to construct via ..Default::default() / ..CloudConfig::default() instead of fully-enumerated struct literals, so construction funnels through Default (where defaults and future invariants live). Other internal Default impls already centralize field initialization.

This is behavior-preserving: serde derives, defaults, and load/save logic are unchanged.

Type-safety pattern

This applies the #[non_exhaustive] on public config structs pattern (as used in diesel). Marking these structs non-exhaustive makes adding a field a non-breaking change for downstream crates and forces external construction through Default/load, centralizing default values and any future validation invariants. External crates can no longer build partially-valid configs by hand.

CI

Full CI runs on this PR. Locally only cargo check -p hm-config (and cargo test -p hm-config, all green) was run per the scope of this change; the full workspace/TS build was not run locally.

@markovejnovic markovejnovic marked this pull request as ready for review June 10, 2026 19:43
@markovejnovic markovejnovic merged commit e4c55c1 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