schemurai 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -7
  3. data/ext/schemurai_native/Cargo.lock +59 -1
  4. data/ext/schemurai_native/Cargo.toml +4 -1
  5. data/ext/schemurai_native/extconf.rb +5 -1
  6. data/ext/schemurai_native/glue.c +1679 -62
  7. data/ext/schemurai_native/protocol.def +45 -0
  8. data/ext/schemurai_native/src/budget.rs +49 -0
  9. data/ext/schemurai_native/src/container.rs +460 -0
  10. data/ext/schemurai_native/src/content.rs +56 -27
  11. data/ext/schemurai_native/src/diagnostics/array.rs +392 -0
  12. data/ext/schemurai_native/src/diagnostics/object.rs +218 -0
  13. data/ext/schemurai_native/src/diagnostics.rs +1064 -325
  14. data/ext/schemurai_native/src/enumeration.rs +6 -1
  15. data/ext/schemurai_native/src/evaluation.rs +49 -20
  16. data/ext/schemurai_native/src/format.rs +8 -6
  17. data/ext/schemurai_native/src/graph.rs +37 -0
  18. data/ext/schemurai_native/src/instance_graph.rs +90 -0
  19. data/ext/schemurai_native/src/lib.rs +910 -237
  20. data/ext/schemurai_native/src/memo.rs +11 -38
  21. data/ext/schemurai_native/src/number/arbitrary.rs +210 -0
  22. data/ext/schemurai_native/src/number.rs +250 -59
  23. data/ext/schemurai_native/src/pattern.rs +113 -101
  24. data/ext/schemurai_native/src/pointer.rs +97 -0
  25. data/ext/schemurai_native/src/runtime/properties.rs +162 -0
  26. data/ext/schemurai_native/src/runtime/reports.rs +266 -0
  27. data/ext/schemurai_native/src/runtime/scopes.rs +430 -0
  28. data/ext/schemurai_native/src/runtime.rs +1020 -0
  29. data/ext/schemurai_native/src/scope.rs +60 -16
  30. data/ext/schemurai_native/src/string.rs +68 -0
  31. data/ext/schemurai_native/src/tracking.rs +244 -174
  32. data/lib/schemurai/container_checks/array_diagnostics.rb +119 -0
  33. data/lib/schemurai/container_checks/object_diagnostics.rb +152 -0
  34. data/lib/schemurai/container_checks.rb +534 -0
  35. data/lib/schemurai/decimal.rb +11 -0
  36. data/lib/schemurai/dialect.rb +0 -12
  37. data/lib/schemurai/ecma_regexp.rb +46 -0
  38. data/lib/schemurai/evaluation_limits.rb +65 -0
  39. data/lib/schemurai/evaluation_pool.rb +66 -0
  40. data/lib/schemurai/evaluator.rb +9 -48
  41. data/lib/schemurai/json_pointer.rb +11 -0
  42. data/lib/schemurai/limited_evaluator.rb +2 -59
  43. data/lib/schemurai/native/diagnostics.rb +4 -3
  44. data/lib/schemurai/native/evaluator.rb +38 -10
  45. data/lib/schemurai/native/null_numeric.rb +23 -0
  46. data/lib/schemurai/number_checks.rb +128 -0
  47. data/lib/schemurai/string_checks.rb +166 -0
  48. data/lib/schemurai/type_checks.rb +59 -0
  49. data/lib/schemurai/value_equality.rb +72 -0
  50. data/lib/schemurai/version.rb +1 -1
  51. data/lib/schemurai/vm/compiler.rb +18 -26
  52. data/lib/schemurai/vm/evaluator.rb +87 -545
  53. data/lib/schemurai/vm/limited_evaluator.rb +8 -78
  54. metadata +25 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f82df02813a6067fc242975190077fb66c9d104866c0e373497ad639f1ba12e3
4
- data.tar.gz: d8ba792bfd5a7fbbdf2295bfa98f26e5804c702ad249ebf6efd3e8ba683af76e
3
+ metadata.gz: 663b805a46f6c7bf28678bcc50b2ffae37d3337b3025710a75c0782a5d7c8182
4
+ data.tar.gz: 41a280754bfa72b41626e44176ef7cf0c983cc27a504aedf049759df005498b1
5
5
  SHA512:
6
- metadata.gz: ce2508c012b1bf512bd51c7d2d67f1feacb6935e78d73577e0769cb2dd4664b12eaa6fbf58b57f3027f6d46b30aa684fde9cfda15ced02b24eaf004488be6a18
7
- data.tar.gz: 1282ae16eed2abaecb7f352c9030e5d6ef1417c55c4c24b4c5e4860214a3e01fa2cbeed81a9aea506e43b57e62373f53f2f669e4d3e46b2db02bc43064ab9140
6
+ metadata.gz: 88be3ae2e41ce4d46cbb5c79dc66e9bfe7d9041d63619b17dc27dc7977384679435df13f0e234701033eca5f829f9d4e7321b9b08ad8e9b6fdfdf0fa5d64c03c
7
+ data.tar.gz: a0ea620a03a983a0ad22319c4a22727c316ced09711bd8565a716d8ebcf4c523bc827e957b347c0b19886d487f7529d305b425f63e1e0ffa4b3b7d8f1822e406
data/README.md CHANGED
@@ -189,7 +189,7 @@ must not be shared between threads or Ractors. With the VM and native backends,
189
189
  the registry compiles and shares its bytecode before this transition. The native
190
190
  backend also prepares shared native instruction tables for all four combinations
191
191
  of `content` and `format`; `validator_for` does not recompile them in each Ractor.
192
- Native regex search caches and VM fallback evaluation state belong to each
192
+ Native regex search caches and Ruby runtime helper state belong to each
193
193
  validator. Preparing these tables adds time and memory to `make_shareable`.
194
194
 
195
195
  ### Meta-schema validation
@@ -255,13 +255,15 @@ applicator trials do not consume the cap. Boolean checks ignore the error cap
255
255
  and use the ordinary evaluator when no timeout is set.
256
256
 
257
257
  The timeout uses a monotonic elapsed-time deadline, including diagnostic
258
- rendering and native-to-VM fallback. It checks at entry, before returning and
259
- every 256 checkpoints in evaluation, container scans and structural traversal.
258
+ rendering and native runtime helper calls and retries. It checks at entry,
259
+ before returning and every 256 checkpoints in evaluation, container scans and
260
+ structural traversal.
260
261
  Ruby string/content operations also check before and after expensive calls.
261
262
  Zero seconds stops even a trivial call. Expiry raises `LimitExceeded` with
262
263
  `limit == :timeout`; `maximum` and `attempted` are configured and elapsed seconds.
263
264
  Native returns an exhaustion status and releases Rust resources before Ruby
264
- raises. A limit hit is terminal and does not trigger fallback.
265
+ raises. A limit hit is terminal. Native validation does not fall back to VM
266
+ execution, with or without invocation limits.
265
267
 
266
268
  This implementation never uses Ruby `Timeout`, timer threads, signals or
267
269
  asynchronous exception injection. It is cooperative: one regexp search, scalar
@@ -286,9 +288,28 @@ scans use per-item evaluation so successful scans can poll.
286
288
  `Schemurai.backend`, `SchemaRegistry#backend`, and `Validator#backend` expose
287
289
  the selected backend. Pass `backend: :ruby` to force the Ruby oracle or
288
290
  `backend: :vm` to ahead-of-time compile schemas for the validator virtual machine.
289
- Pass `backend: :native` to use the experimental Rust VM extension. Building the
290
- native extension requires a C toolchain, Ruby development headers, and Rust
291
- 1.93 or newer. If cargo is absent, gem installation skips the optional native
291
+ Pass `backend: :native` to use the experimental Rust VM extension. Releases
292
+ include precompiled gems on RubyGems.org for CRuby 4.0 on these platforms:
293
+
294
+ | OS | CPU | libc | Gem platform |
295
+ | --- | --- | --- | --- |
296
+ | Linux | x64 | glibc 2.36+ | `x86_64-linux-gnu` |
297
+ | Linux | arm64 | glibc 2.36+ | `aarch64-linux-gnu` |
298
+ | Linux | x64 | musl (Alpine 3.23+) | `x86_64-linux-musl` |
299
+ | Linux | arm64 | musl (Alpine 3.23+) | `aarch64-linux-musl` |
300
+ | macOS 14+ | x64 | — | `x86_64-darwin` |
301
+ | macOS 14+ | arm64 | — | `arm64-darwin` |
302
+
303
+ RubyGems/Bundler selects the matching platform gem during normal installation;
304
+ these gems need no C compiler, Rust, or Ruby development headers. Each platform
305
+ gem bundles its supported Ruby minor ABIs and restricts `required_ruby_version`
306
+ to that range. Ruby patch releases share the same binary. To build from source,
307
+ use `gem install schemurai --platform ruby` or Bundler's `force_ruby_platform`.
308
+ See [native gem releases](docs/native-gem-releases.md) for the build matrix.
309
+
310
+ Building the native extension from source requires a C toolchain, Ruby
311
+ development headers, and Rust 1.93 or newer. If cargo is absent, installation of
312
+ the source gem skips the optional native
292
313
  extension and Ruby/VM remain available; explicitly selecting `:native` then
293
314
  raises `LoadError`. Native execution borrows Ruby values directly; its current coverage and
294
315
  remaining VM delegation are documented below.
@@ -11,6 +11,12 @@ dependencies = [
11
11
  "memchr",
12
12
  ]
13
13
 
14
+ [[package]]
15
+ name = "autocfg"
16
+ version = "1.5.1"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
19
+
14
20
  [[package]]
15
21
  name = "base64-simd"
16
22
  version = "0.8.0"
@@ -51,6 +57,55 @@ version = "2.8.3"
51
57
  source = "registry+https://github.com/rust-lang/crates.io-index"
52
58
  checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
53
59
 
60
+ [[package]]
61
+ name = "num-bigint"
62
+ version = "0.4.8"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"
65
+ dependencies = [
66
+ "num-integer",
67
+ "num-traits",
68
+ ]
69
+
70
+ [[package]]
71
+ name = "num-bigint"
72
+ version = "0.5.1"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "93e7820bc0a80a0238e650327316f929ba18d5be054b647490a3a6a339f3e7c0"
75
+ dependencies = [
76
+ "num-integer",
77
+ "num-traits",
78
+ ]
79
+
80
+ [[package]]
81
+ name = "num-integer"
82
+ version = "0.1.47"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
85
+ dependencies = [
86
+ "num-traits",
87
+ ]
88
+
89
+ [[package]]
90
+ name = "num-rational"
91
+ version = "0.4.2"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
94
+ dependencies = [
95
+ "num-bigint 0.4.8",
96
+ "num-integer",
97
+ "num-traits",
98
+ ]
99
+
100
+ [[package]]
101
+ name = "num-traits"
102
+ version = "0.2.19"
103
+ source = "registry+https://github.com/rust-lang/crates.io-index"
104
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
105
+ dependencies = [
106
+ "autocfg",
107
+ ]
108
+
54
109
  [[package]]
55
110
  name = "outref"
56
111
  version = "0.5.2"
@@ -82,11 +137,14 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
82
137
 
83
138
  [[package]]
84
139
  name = "schemurai-native"
85
- version = "3.0.1"
140
+ version = "3.1.0"
86
141
  dependencies = [
87
142
  "base64-simd",
88
143
  "base64-turbo",
89
144
  "memchr",
145
+ "num-bigint 0.5.1",
146
+ "num-rational",
147
+ "num-traits",
90
148
  "regex-automata",
91
149
  "regex-syntax",
92
150
  "ryu",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "schemurai-native"
3
- version = "3.0.1"
3
+ version = "3.1.0"
4
4
  edition = "2024"
5
5
  rust-version = "1.93"
6
6
  publish = false
@@ -9,6 +9,9 @@ publish = false
9
9
  base64-simd = "0.8.0"
10
10
  base64-turbo = "0.5.0"
11
11
  memchr = "2.8.3"
12
+ num-bigint = "0.5.1"
13
+ num-rational = { version = "0.4.2", default-features = false, features = ["std"] }
14
+ num-traits = "0.2.19"
12
15
  regex-automata = "0.4.18"
13
16
  regex-syntax = "0.8.11"
14
17
  ryu = "1.0.23"
@@ -2,6 +2,10 @@
2
2
 
3
3
  require "mkmf"
4
4
 
5
+ # Platform gems resolve Ruby symbols from the running interpreter so the same
6
+ # binary also works with Rubies built without a shared libruby.
7
+ $LIBRUBYARG = "" unless enable_config("link-ruby", true) # rubocop:disable Style/GlobalVars -- mkmf build configuration.
8
+
5
9
  unless find_executable("cargo")
6
10
  warn "cargo was not found; skipping the optional native backend (Ruby and VM remain available)"
7
11
  File.write("Makefile", dummy_makefile(".").join)
@@ -57,7 +61,7 @@ File.open("Makefile", "a") do |file|
57
61
 
58
62
  glue.o: $(srcdir)/protocol.h $(srcdir)/protocol.def
59
63
 
60
- $(srcdir)/target/release/libschemurai_native.a: $(srcdir)/Cargo.toml $(srcdir)/Cargo.lock $(srcdir)/build.rs $(srcdir)/protocol.def $(wildcard $(srcdir)/src/*.rs)
64
+ $(srcdir)/target/release/libschemurai_native.a: $(srcdir)/Cargo.toml $(srcdir)/Cargo.lock $(srcdir)/build.rs $(srcdir)/protocol.def $(wildcard $(srcdir)/src/*.rs $(srcdir)/src/*/*.rs)
61
65
  \tcargo build --manifest-path $(srcdir)/Cargo.toml --release --locked
62
66
  MAKE
63
67
  end