Skip to content

feat: models-only build behind a default-on validation feature - #751

Draft
gronke wants to merge 3 commits into
csaf-rs:mainfrom
gronke:feat/validation-feature
Draft

feat: models-only build behind a default-on validation feature#751
gronke wants to merge 3 commits into
csaf-rs:mainfrom
gronke:feat/validation-feature

Conversation

@gronke

@gronke gronke commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The demonstration PR for #733: validation is a default-on feature; disabling it builds the generated schema types plus the JSON plumbing with serde, serde_json, regress, and uuid as the only dependencies.

Design, matching the module graph:

  • Every gate is a module-root #[cfg(feature = "validation")] - 12 in lib.rs, 3 in macros/mod.rs; zero function-level cfg. The converter gate at lib.rs:1 was the precedent.
  • The csaf umbrella (traits, rich types, RawDocument, loaders) gates with validation, as the issue sketched; models-only consumers deserialize via serde_json or the ungated JsonSource. Keeping RawDocument/detect_version models-side is possible later by moving two impl blocks out of raw.rs - left out to keep this diff minimal.
  • converter = ["validation"] (it builds on the trait layer). The bench declares required-features = ["validation"].
  • The macro gate sits inside macros/mod.rs rather than on the module declaration, so the string-newtype macro from feat: AsRef<str> and PartialEq<str> for generated string newtypes #717 lands ungated beside it without conflict.

Two discoveries the issue text did not know:

  • csaf-ffi already sets default-features = false and imports csaf::validation; it compiled only because validation was unconditional. Its isolated -p csaf-ffi builds (the wasm/go binding scripts and the CI wasm job) see no feature unification, so the manifest now pins features = ["validation"].
  • The existing workspace-level --no-default-features CI step never disables csaf-rs defaults - the other members re-enable them through resolver-2 unification. The second commit adds the -p csaf-rs --no-default-features test step that actually exercises models-only.

Numbers (local, directional): resolved dependency graph:
152 → 25 crates; cold debug build 32.7 s → 17.7 s wall, 193 s → 79 s CPU.

@gronke gronke changed the title Feat/validation feature feat: models-only build behind a default-on validation feature Jul 24, 2026
@gronke
gronke force-pushed the feat/validation-feature branch from 540b594 to 74f1bca Compare July 27, 2026 13:56
gronke added 3 commits July 28, 2026 10:30
Without the feature the crate builds the generated schema types and the JSON plumbing, with serde, serde_json, regress, and uuid as the only dependencies; the other ten move behind `validation`, which stays in the default set so nothing changes for existing users.
Every gate sits on a module declaration in lib.rs and macros/mod.rs — no function-level cfg.
`converter` implies `validation` (it builds on the trait layer), the bench declares `required-features`, and csaf-ffi pins `features = ["validation"]` since its isolated `-p` builds (wasm/go bindings) see no feature unification from the other workspace members.
The workspace-level --no-default-features step never disables csaf-rs defaults: the other members request them on their dependency edges and resolver 2 unifies the features back on.
Only a `-p csaf-rs` invocation isolates the crate, so the new step is the one that actually compiles and tests models-only.
@gronke
gronke force-pushed the feat/validation-feature branch from 74f1bca to 3526bbd Compare July 28, 2026 09:03
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