Skip to content

fix(macro): round-20 schema macro fixes - #384

Open
owjs3901 wants to merge 4 commits into
mainfrom
fix/schema-macro-round20
Open

owjs3901 wants to merge 4 commits into
mainfrom
fix/schema-macro-round20

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

Round-20 schema macro audit fixes (crates/vespera_macro, schema macro / schema_impl / multipart_impl areas). Each finding was checked against the code before fixing; all were confirmed real, none refuted.

Per-finding outcome

Finding Outcome Change
S20-0-1 Fixed schema_impl/tests.rs was 1001 lines; identity and count tests moved to schema_impl/tests_identity.rs.
S20-0-2 Fixed count_items_named now skips fn, impl, trait, const and static items under a false cfg. Cases added.
S20-0-3 Fixed Raw non-keyword field (r#tags) is matched against bare default fn names with the r# prefix stripped on both sides. Test added.
R20-L1 Fixed A literal default_value on a non-primitive field no longer emits #[schema(default)] when no serde default is generated. Test updated.
R20-L2 Fixed Exact # [schema (default = "0")] assertion.
R20-SM2-01 Fixed target_shape drops omit_default primary keys and un-picked HasMany the way generate_type does. Cases added.
R20-SM2-02 Fixed Vacuous inline_field_struct_holds_constructor_inputs removed.
R20-SM3-01 Fixed A same-file item that is not #[derive(Schema)] yields to the stored Schema. A Schema-derived file item still wins (round-19 behaviour kept). Pure-function tests added.
R20-SM3-02 Fixed Draft(WIP) is a literal. A call with arguments must name a known SQL function. Cases and a defaults-level test added.
R20-SM3-03 Fixed An explicitly imported bare name of an item with no #[derive(Schema)] is an error. Glob imports stay lenient. Fixture-crate test added.
R20-S4-M1 Fixed A leading self/super run resolves as one prefix (super::super::x). Case added.
R20-S4-L1 Fixed A name supplied only by an external glob import is emitted through that glob. Tests added.
R20-S4-L2 Fixed Raw path keywords (r#self, r#super, r#crate, r#Self, r#_) rejected as field names. Cases added.
R20-S4-L3 Fixed Const generic block arguments are re-rooted like array lengths. Case added.
R20-S4-L4 Fixed Ecosystem default test now covers a Date imported from a non-ecosystem crate.

No finding was refuted.

Verification

  • cargo test -p vespera_macro (lib 5125 passed, integration 1 passed)
  • cargo test -p vespera (all suites pass)
  • cargo clippy -p vespera_macro --all-targets -- -D warnings and --all-features clean
  • cargo fmt -p vespera_macro -- --check clean
  • No insta snapshot drift.
  • Tarpaulin coverage and the other CI gates are not run locally. The new cases were written to fail on the old code but were not re-run against it.

Notes

  • Changepack: .changepacks/changepack_log_schema_macro_round20.json (all 7 packages, Patch).
  • Limited scope: changes stay inside crates/vespera_macro/src/schema_macro/**, schema_impl*, and multipart_impl/**, plus the one changepack file. The parser is untouched.

🤖 Generated with Claude Code

owjs3901 and others added 4 commits November 17, 2026 15:38
Verified against the round-20 audit findings (S20-0-1..3, R20-L1..L2,
R20-SM2-01..02, R20-SM3-01..03, R20-S4-M1, R20-S4-L1..L4):

- multipart: a raw non-keyword field (r#tags) shadowing a bare default
  function is renamed like its plain twin (the r# prefix kept them apart).
- schema_impl: count_items_named ignores items under a false cfg on fn,
  impl, trait, const and static (their bodies were walked).
- schema_impl/tests.rs split: identity / count tests moved to
  tests_identity.rs (the file was 1001 lines).
- defaults: a literal default_value on a non-primitive field no longer
  advertises an OpenAPI default that serde does not fill (422 otherwise).
- from_model/target_shape: omit_default primary keys and un-picked HasMany
  fields are dropped the way generate_type drops them.
- same-file adapters: a plain, not Schema-derived struct of the adapter's
  name in the call-site file yields to the stored Schema.
- seaorm: a text default with an unspaced parenthesis (Draft(WIP)) is a
  literal; a call with arguments needs a known SQL function name.
- schema!: an explicitly imported bare name of an underived item is an
  error (glob imports stay lenient).
- type_utils: a leading super run resolves as one prefix (super::super);
  const generic arguments are re-rooted; names only an external glob
  import supplies are emitted through that glob.
- validation: raw path keywords (r#self, r#super, r#crate, r#Self, r#_)
  are rejected as field names.
- test integrity: exact schema default assertion; vacuous inline_types
  constructor test removed; ecosystem default test covers an import from
  a non-ecosystem crate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… default

R20-L1 stops advertising a SeaORM literal default that serde does not fill,
so MemoStatus refs no longer carry "default": "draft". Regenerate
openapi.json and the integration_test__openapi snapshot to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tarpaulin gate reported an uncovered line in the Counter visitor. The
new trait override had no case where the trait is active, so its walk
never ran. Add one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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