Skip to content

feat: Schema canonicalization#1138

Open
Stranger6667 wants to merge 1 commit into
masterfrom
canonical-schema-foundation
Open

feat: Schema canonicalization#1138
Stranger6667 wants to merge 1 commit into
masterfrom
canonical-schema-foundation

Conversation

@Stranger6667

@Stranger6667 Stranger6667 commented May 23, 2026

Copy link
Copy Markdown
Owner

This PR introduces a canonical schema algebra that transforms a reasonable subset of JSON Schemas into a canonical representation and provides operations such as intersection, union, negation, subtraction + additional reasoning about schema satisfiability.

This work is motivated by two primary use cases:

  • data generation in Schemathesis. Specifically for negative data generation and various transformations needed for covering boundary scenarios
  • Analyzing compatibility and breaking changes in JSON Schemas (notable in Django Modern REST)

@codspeed-hq

codspeed-hq Bot commented May 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 114 untouched benchmarks
🆕 30 new benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 Simulation canonicalize/deep_allof_chain N/A 559.3 µs N/A
🆕 Simulation canonicalize/many_small_allofs_inside_object N/A 934 µs N/A
🆕 Simulation canonicalize/object_with_properties N/A 144.4 µs N/A
🆕 Simulation canonicalize/wide_anyof_in_allof N/A 1.3 ms N/A
🆕 Simulation canonicalize/geojson N/A 13.1 ms N/A
🆕 Simulation canonicalize/open_api N/A 115.5 ms N/A
🆕 Simulation canonicalize/swagger N/A 17.2 ms N/A
🆕 Simulation canonicalize/fhir N/A 352.1 ms N/A
🆕 Simulation canonicalize/kestra_like/160 N/A 6.4 ms N/A
🆕 Simulation canonicalize/kestra_like/320 N/A 12.6 ms N/A
🆕 Simulation canonicalize/kestra_like/80 N/A 15.8 ms N/A
🆕 Simulation canonicalize/kubernetes N/A 25.1 ms N/A
🆕 Simulation canonicalize/recursive N/A 4.6 ms N/A
🆕 Simulation canonicalize_symbolic/kestra_like/320 N/A 12.8 ms N/A
🆕 Simulation canonicalize_symbolic/kubernetes N/A 24.7 ms N/A
🆕 Simulation canonicalize_symbolic/open_api N/A 52 ms N/A
🆕 Simulation emit/fhir N/A 38.3 ms N/A
🆕 Simulation emit/kestra_like/160 N/A 1.2 ms N/A
🆕 Simulation emit/kubernetes N/A 1.8 ms N/A
🆕 Simulation emit/open_api N/A 3.1 ms N/A
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing canonical-schema-foundation (175d2b6) with master (14e1011)

Open in CodSpeed

@Stranger6667
Stranger6667 force-pushed the canonical-schema-foundation branch 21 times, most recently from 28183a2 to ccbd9c3 Compare May 24, 2026 11:52
@codecov

codecov Bot commented May 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.23360% with 129 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.63%. Comparing base (14e1011) to head (175d2b6).

Files with missing lines Patch % Lines
crates/jsonschema/src/canonical/emit.rs 96.74% 29 Missing ⚠️
crates/jsonschema/src/canonical/ir/mod.rs 96.72% 13 Missing ⚠️
...chema/src/canonical/algebra/intersect/value_set.rs 96.23% 11 Missing ⚠️
...ates/jsonschema/src/canonical/ir/bound_fraction.rs 96.27% 8 Missing ⚠️
...tes/jsonschema/src/canonical/algebra/negate/mod.rs 97.66% 7 Missing ⚠️
...jsonschema/src/canonical/algebra/negate/numeric.rs 95.58% 6 Missing ⚠️
...jsonschema/src/canonical/leaves/numeric/modular.rs 93.47% 6 Missing ⚠️
crates/jsonschema/src/canonical/mod.rs 88.00% 6 Missing ⚠️
...schema/src/canonical/algebra/intersect/dispatch.rs 98.40% 5 Missing ⚠️
...s/jsonschema/src/canonical/leaves/numeric/bound.rs 97.05% 5 Missing ⚠️
... and 17 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1138      +/-   ##
==========================================
+ Coverage   95.96%   96.63%   +0.66%     
==========================================
  Files         142      208      +66     
  Lines       32269    45931   +13662     
==========================================
+ Hits        30968    44386   +13418     
- Misses       1301     1545     +244     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Stranger6667
Stranger6667 force-pushed the canonical-schema-foundation branch 7 times, most recently from 6d20080 to df79dc2 Compare May 24, 2026 16:46
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
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