json-model-compiler 2.0.59__tar.gz → 2.0.61__tar.gz

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 (132) hide show
  1. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/.gitignore +1 -1
  2. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/BACKLOG.md +10 -4
  3. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/Makefile +13 -14
  4. {json_model_compiler-2.0.59/json_model_compiler.egg-info → json_model_compiler-2.0.61}/PKG-INFO +1 -1
  5. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/VERSION.md +39 -0
  6. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/bench.sh +11 -0
  7. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/analyze.py +132 -87
  8. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/clang.py +4 -4
  9. json_model_compiler-2.0.61/json_model/data/VERSION +1 -0
  10. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/jmc.pod +4 -0
  11. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/irep.py +113 -8
  12. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/javascript.py +53 -10
  13. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/mtypes.py +6 -0
  14. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/optim.py +5 -5
  15. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/c/json-model.c +62 -42
  16. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/c/json-model.h +1 -0
  17. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/c/main.c +18 -4
  18. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/script.py +33 -17
  19. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/submodel.py +1 -1
  20. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/utils.py +1 -1
  21. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/xstatic.py +9 -5
  22. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61/json_model_compiler.egg-info}/PKG-INFO +1 -1
  23. json_model_compiler-2.0.59/json_model/data/VERSION +0 -1
  24. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/.github/workflows/docs.yml +0 -0
  25. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/.github/workflows/sanity.yml +0 -0
  26. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/.gitmodules +0 -0
  27. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/API.md +0 -0
  28. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/BENCH.md +0 -0
  29. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/DESIGN.md +0 -0
  30. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/DEV.md +0 -0
  31. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/DOC.md +0 -0
  32. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/HOWTO.md +0 -0
  33. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/INTEGRATION.md +0 -0
  34. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/MANIFEST.in +0 -0
  35. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/PUBS.md +0 -0
  36. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/README.md +0 -0
  37. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/SPEC.md +0 -0
  38. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/TUTO.md +0 -0
  39. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/about.sh +0 -0
  40. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/README.md +0 -0
  41. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/__init__.py +0 -0
  42. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/convert.py +0 -0
  43. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/clang_entry.c +0 -0
  44. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/clang_free.c +0 -0
  45. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/clang_init.c +0 -0
  46. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/clang_pcre2_fun.c +0 -0
  47. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/clang_re2_fun.c +0 -0
  48. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/java_free.java +0 -0
  49. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/java_init.java +0 -0
  50. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/javascript_exe.js +0 -0
  51. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/javascript_foot.js +0 -0
  52. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/javascript_free.js +0 -0
  53. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/javascript_head.js +0 -0
  54. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/javascript_init.js +0 -0
  55. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/javascript_main.js +0 -0
  56. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/perl_entry.pl +0 -0
  57. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/perl_exe.pl +0 -0
  58. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/perl_free.pl +0 -0
  59. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/perl_init.pl +0 -0
  60. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/perl_main.pl +0 -0
  61. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/perl_pkg.pl +0 -0
  62. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/plpgsql_entry.sql +0 -0
  63. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/python_entry.py +0 -0
  64. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/python_exe.py +0 -0
  65. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/python_free.py +0 -0
  66. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/python_init.py +0 -0
  67. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/data/python_main.py +0 -0
  68. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/export.py +0 -0
  69. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/java.py +0 -0
  70. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/language.py +0 -0
  71. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/model.py +0 -0
  72. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/objops.py +0 -0
  73. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/perl.py +0 -0
  74. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/plpgsql.py +0 -0
  75. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/predefs.py +0 -0
  76. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/python.py +0 -0
  77. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/recurse.py +0 -0
  78. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/regex.py +0 -0
  79. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/resolver.py +0 -0
  80. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/Makefile +0 -0
  81. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/__init__.py +0 -0
  82. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/c/Makefile +0 -0
  83. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/.gitignore +0 -0
  84. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/Makefile +0 -0
  85. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/README.md +0 -0
  86. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/env.sh +0 -0
  87. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Checker.java +0 -0
  88. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/GSON.java +0 -0
  89. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/JSON.java +0 -0
  90. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/JSONP.java +0 -0
  91. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Jackson.java +0 -0
  92. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Main.java +0 -0
  93. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
  94. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Path.java +0 -0
  95. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Report.java +0 -0
  96. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/json_model/Runtime.java +0 -0
  97. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/java/pom.xml +0 -0
  98. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/js/README.md +0 -0
  99. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/js/index.js +0 -0
  100. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/js/main.js +0 -0
  101. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/js/package.json +0 -0
  102. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/.gitignore +0 -0
  103. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/Changes +0 -0
  104. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/LICENSE +0 -0
  105. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/MANIFEST +0 -0
  106. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/Makefile.PL +0 -0
  107. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/README +0 -0
  108. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/env.sh +0 -0
  109. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/ignore.txt +0 -0
  110. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
  111. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/00-load.t +0 -0
  112. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/manifest.t +0 -0
  113. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/pod-coverage.t +0 -0
  114. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/t/pod.t +0 -0
  115. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/pl/xt/boilerplate.t +0 -0
  116. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/sql/META.json +0 -0
  117. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/sql/Makefile +0 -0
  118. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/sql/json_model--2.0.sql +0 -0
  119. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/sql/json_model.control +0 -0
  120. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/support.py +0 -0
  121. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/runtime/types.py +0 -0
  122. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/ts_export.py +0 -0
  123. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model/url_cache.py +0 -0
  124. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/SOURCES.txt +0 -0
  125. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/dependency_links.txt +0 -0
  126. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/entry_points.txt +0 -0
  127. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/not-zip-safe +0 -0
  128. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/requires.txt +0 -0
  129. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/json_model_compiler.egg-info/top_level.txt +0 -0
  130. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/package.json +0 -0
  131. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/pyproject.toml +0 -0
  132. {json_model_compiler-2.0.59 → json_model_compiler-2.0.61}/setup.cfg +0 -0
@@ -11,7 +11,7 @@ package-lock.json
11
11
  node_modules/
12
12
  *.values.csv
13
13
  jmc.1
14
- site/MODELS.md
14
+ site/models.json
15
15
  site/JMC.md
16
16
  site/ABOUT.md
17
17
  site/BENCH.md
@@ -2,10 +2,18 @@
2
2
 
3
3
  ## Current Tasks
4
4
 
5
+ - [ ] bench: submit `negatives.jsonl` to jsb for sanity checks
6
+ - [ ] bench: better count should ignore bads
7
+ - [ ] bench: handle case failures for radar (wip, ajv handling)
8
+ - [ ] bench: collect error runs?
9
+ - [ ] bench: add corvus reference?
10
+ - [ ] bench: add stddev performance computation
11
+ - [ ] bench: improve resilience to bad overhead estimation
12
+ - [ ] bench: add case names to generated radar
13
+ - [ ] bench: collect JSON parse times for comparison with validation times
5
14
  - [ ] export: generate a [katydid](https://katydid.github.io/) expression, for a compatible subset
6
15
  - [ ] pr: add _known limitations_ stuff
7
16
  - [ ] front: merge many internal options to trigrams
8
- - [ ] bench: case failures handling needs some fixing
9
17
  - [ ] tests: check more bad urls (eg bad %-escape)
10
18
  - [ ] tests: check pydantic generated classes
11
19
  - [ ] static: use combined type test and value extraction when available?
@@ -22,11 +30,9 @@
22
30
  - [ ] perf: drop and/or merge identical results when comparing
23
31
  - [ ] backend: check `mv-34/mu` test case which may require some utf normalization
24
32
  - [ ] runtime: count graphemes instead of characters? for Java, see `java.text.BreakIterator`
25
- - [ ] bench: add stddev performance computation
26
- - [ ] bench: improve resilience to bad overhead estimation
27
- - [ ] bench: collect JSON parse times for comparison with validation times
28
33
  - [ ] pr: better document optimizations, eg add compiler optimization page
29
34
  - [ ] static: improve startswith pattern recognition `/^xyz.*/`
35
+ - [ ] js: implement cset as an or-expression
30
36
  - [ ] c-backend: factor out str extraction in or-list in more cases
31
37
  - [ ] c-backend: improve unique with hash using int set?
32
38
  - [ ] c-backend: improve str hash?
@@ -67,7 +67,7 @@ clean.js:
67
67
 
68
68
  .PHONY: clean.site
69
69
  clean.site:
70
- $(RM) site/MODELS.md site/JMC.md site/ABOUT.md site/BENCH.md .about.md
70
+ $(RM) site/models.json site/JMC.md site/ABOUT.md site/BENCH.md .about.md
71
71
  $(RM) -r _site
72
72
 
73
73
  .PHONY: clean.py
@@ -140,17 +140,16 @@ check.sanity: venv/.dev
140
140
  #
141
141
  # Docsify Web Site: https://json-model.org/
142
142
  #
143
- site/MODELS.md: Makefile models/
143
+ site/models.json: $(wildcard models/*.model.json)
144
144
  {
145
- echo "# JSON Model Examples"
146
- echo
147
- for model in models/*.model.json ; do
148
- title=$$(jq -r '."#"' < $$model | sed 's/\s*.JSON_MODEL.*//')
149
- doc=$$(jq -r '."#.doc"' < $$model)
150
- if [ "$$doc" = "null" ] ; then doc="" ; else doc=" – $$doc" ; fi
151
- echo "- [$$title]($$model ':ignore')$$doc"
145
+ first=1
146
+ echo "["
147
+ for model in $^ ; do
148
+ [ "$$first" ] && first= || echo ","
149
+ jq "{title: .\"#\", doc: .\"#.doc\", model: \"$${model}\"}" $${model}
152
150
  done
153
- } > $@
151
+ echo "]"
152
+ } | jq 'map(if .doc == null then del(.doc) else . end)' > $@
154
153
 
155
154
  # pod2markdown: libpod-markdown-perl
156
155
  site/JMC.md: json_model/data/jmc.pod
@@ -160,7 +159,7 @@ site/BENCH.md: ./bench.sh
160
159
  ./$< > $@
161
160
 
162
161
  # generate twice to include the about page in the counts
163
- site/ABOUT.md: ./about.sh site/JMC.md site/MODELS.md site/BENCH.md
162
+ site/ABOUT.md: ./about.sh site/JMC.md site/BENCH.md
164
163
  ./$< > $@
165
164
  ./$< > .about.md
166
165
  mv .about.md $@
@@ -171,6 +170,9 @@ jmc.1: json_model/data/jmc.pod dev
171
170
  year=$$(date +%Y)
172
171
  pod2man $< | sed "s/^\.TH JMC 1.*/.TH JMC 1 $$year \"v$$version\" \"User Documentation\"/" > $@
173
172
 
173
+ .PHONY: build.site
174
+ build.site: site/models.json site/JMC.md site/ABOUT.md site/BENCH.md
175
+
174
176
  _site: build.site
175
177
  cp -rL site _site
176
178
  find _site -type d -print | xargs chmod a+rx
@@ -187,9 +189,6 @@ www: build.site
187
189
  # SITE and SITEPATH are out of the git repository
188
190
  -include local.mk
189
191
 
190
- .PHONY: build.site
191
- build.site: site/MODELS.md site/JMC.md site/ABOUT.md site/BENCH.md
192
-
193
192
  .PHONY: publish.site
194
193
  publish.site: build.site
195
194
  # NOTE --delete: no, keep old benchmark pages archive on the site for now
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_model_compiler
3
- Version: 2.0.59
3
+ Version: 2.0.61
4
4
  Summary: JSON Model Tools
5
5
  Author: Fabien Coelho, Claire Yannou-Medrala
6
6
  License-Expression: CC0-1.0
@@ -1,5 +1,44 @@
1
1
  # JSON Model Compiler Versions
2
2
 
3
+ ## 2.0.61 on 2026-09-18
4
+
5
+ - ir: ensure that a nope is kept when optimizing sequences
6
+ - front: allow to accept all-caps definitions with `--no-caps`
7
+
8
+ ## 2.0.60 on 2026-09-15
9
+
10
+ - pr: jm site added to [awesome docsify](https://github.com/docsifyjs/awesome-docsify/commit/3950ece64978f41294463e1a2b12e809c65a6379)
11
+ - bench: show rounded minutes run time
12
+ - clang: remove useless empty line from string constant set functions
13
+ - bench: use uc for external tools, report in italic
14
+ - bench: show versions of used languages, not all
15
+ - bench: radar data with added speed property
16
+ - model: improve internal doc for some example models
17
+ - model: simplify JSTS model with `$SEMVER`
18
+ - pr: generate model examples pages from json
19
+ - bench: add ajv cli docker and wrapper
20
+ - bench: add ajv external reference
21
+ - js: add option for more direct/simpler code
22
+ - js: set default to use simpler code
23
+ - analyze: check static typing on constrained nodes
24
+ - analyze: display model rejections reasons as a warning
25
+ - bench: handle case failures when reporting
26
+ - model: improve jm meta model
27
+ - c-backend: stricter regex check active by default
28
+ - bench: keep initial schema when testing
29
+ - jsb: patch test values to avoid border or invalid cases
30
+ - optim: fix type check rejections
31
+ - bench: various report generation fixes
32
+ - optim: fix partial eval over simplification (yet another bool/int issue)
33
+ - bench: add missing model conversion time for some tools, ensure display order
34
+ - bench: make cron job also check for jsb changes
35
+ - bench: improve summary description depending on displayed data
36
+ - check: model validation rejects all-caps definitions
37
+ - tests: improve default load balancing with `--maxschedchunk=3`
38
+ - pr: remove older artifacts
39
+ - bench: always display the result success section
40
+ - pr: list at most 10 latests artifacts on bench page
41
+
3
42
  ## 2.0.59 on 2026-08-28
4
43
 
5
44
  - bench: fix standard cron runs
@@ -3,8 +3,10 @@
3
3
  # generate BENCH.md page with links to available benchmarks
4
4
  #
5
5
 
6
+ MAX=10
6
7
  PYPI="https://pypi.org/project"
7
8
 
9
+ # extract version from file
8
10
  get_version()
9
11
  {
10
12
  local what=$1 file=$2
@@ -14,9 +16,15 @@ get_version()
14
16
  echo $line
15
17
  }
16
18
 
19
+ # up to artifact list
17
20
  sed -ne '1,/BENCHES/p' < BENCH.md | grep -v '^BENCHES$'
18
21
 
22
+ # list max 10 latest artifacts
23
+ nartifacts=0
24
+
19
25
  for artifact in $(ls site/benchmarks/*.md | sort -r) ; do
26
+ let nartifacts+=1
27
+
20
28
  link=${artifact#site/}
21
29
  name=${link#benchmarks/}
22
30
  name=${name%.md}
@@ -31,6 +39,9 @@ for artifact in $(ls site/benchmarks/*.md | sort -r) ; do
31
39
  echo " [JSU $jsu]($PYPI/json-schema-utils/$jsu/) and "
32
40
  echo " [SBC $sbc](https://github.com/sourcemeta/jsonschema/releases/tag/v$sbc), "
33
41
  echo " $message."
42
+
43
+ [ $nartifacts -eq $MAX ] && break
34
44
  done
35
45
 
46
+ # after artifact list
36
47
  sed -ne '/BENCHES/,$p' < BENCH.md | grep -v '^BENCHES$'
@@ -3,13 +3,15 @@
3
3
  #
4
4
  import functools
5
5
  import re
6
+ import json
6
7
 
7
- from .mtypes import UnknownModel, ModelPath, ModelType, ModelFilter, ModelObject, ModelArray
8
+ from .mtypes import UnknownModel, ModelPath, ModelType, ModelFilter, ModelObject, ModelArray, NullType, TopType
8
9
  from .utils import log, is_regex, is_a_simple_object
9
10
  from .predefs import CONST_RE, STR_MODEL_PREDEFS, BOOL_MODEL_PREDEFS, INT_MODEL_PREDEFS, FLOAT_MODEL_PREDEFS
10
11
  from .recurse import recModel, allFlt, noRwt
11
12
  from .model import JsonModel
12
13
  from .runtime import ConstSet
14
+ from .runtime.support import _path as json_path
13
15
 
14
16
  # JsonModel = typing.NewType("JsonModel", None)
15
17
  type Constants = bool|int|float|str|list[int|float|str]
@@ -46,25 +48,6 @@ def references(jm: JsonModel) -> dict[str, set[int]]:
46
48
 
47
49
  return contains
48
50
 
49
- # def reachable(self):
50
- # """Build reachable defs."""
51
- #
52
- # # should consider **all** loaded models!?
53
- # contains = self.references()
54
- # reached = copy.deepcopy(contains)
55
- #
56
- # # simplistic transitive closure computation
57
- # changed = True
58
- # while changed:
59
- # changed = False
60
- # for ref, refs in reached.items():
61
- # for r in refs:
62
- # if r in reached and not reached[r].issubset(refs):
63
- # changed = True
64
- # refs.update(reached[r])
65
- #
66
- # return reached
67
-
68
51
  def check(jm: JsonModel, assertion: ModelFilter, what: str = "?", short: bool = False) -> bool:
69
52
  """Check an arbitrary local assertion on a model."""
70
53
 
@@ -82,24 +65,36 @@ def check(jm: JsonModel, assertion: ModelFilter, what: str = "?", short: bool =
82
65
  return okay
83
66
 
84
67
  # FIXME must tell why it is unhappy!
85
- def valid(jm: JsonModel, path: ModelPath = [], root: bool = True, extend: bool = False) -> bool:
68
+ def valid(jm: JsonModel,
69
+ path: ModelPath = [],
70
+ root: bool = True, # expect a root model (start recursion)
71
+ extend: bool = False, # allow model extensions (.mo, .in)
72
+ caps: bool = True, # all-caps defs are rejected
73
+ ) -> bool:
86
74
  """Check JSON Model structural (and slightly more) validity."""
87
75
 
88
76
  is_valid = True
89
77
 
90
78
  # allowed keywords
91
- AB_KW = {"@", "!", "=", "!=", "<", "<=", ">=", ">", "#", "$", "%", "~"}
79
+ ROOT_KW = {"$", "%", "~"}
80
+ DIV_KW = {"@", "#"}
81
+ CMP_KW = {"<", "<=", ">", ">="}
82
+ NEQ_KW = {"=", "!="}
83
+ ARR_KW = {"!"}
84
+ OP_KW = {"@", "|", "&", "^", "+"}
85
+
92
86
  if extend: # multiple-of: number, contains: model
93
- AB_KW.add(".mo")
94
- AB_KW.add(".in")
87
+ CMP_KW |= {".mo"}
88
+ ARR_KW |= {".in"}
95
89
 
96
- # numerical keywords
97
- NUM_AB_KW = {"=", "!=", "<", "<=", ">", ">="}
98
- if extend:
99
- NUM_AB_KW.add(".mo")
90
+ NUM_KW = NEQ_KW | CMP_KW
91
+ ANY_KW = DIV_KW | NUM_KW | ARR_KW
92
+ if root:
93
+ ANY_KW |= ROOT_KW
100
94
 
101
95
  def finiteRef(model: str) -> bool:
102
96
  ref, recref, recid, ljm = model, [], [], jm
97
+ smodel = json.dumps(model)
103
98
  while isinstance(ref, str) and jm._isRef(ref) and ref not in recref:
104
99
  ljm = ljm.resolveRef(ref, path + recref)
105
100
  recref.append(ref)
@@ -107,99 +102,130 @@ def valid(jm: JsonModel, path: ModelPath = [], root: bool = True, extend: bool =
107
102
  ref = ljm._model
108
103
  finite = not jm._isRef(ref) or ref == "$#" # Hmmm…
109
104
  if not finite:
110
- log.debug(f"infinite recursion on {model}: {recref} ({recid})")
105
+ log.debug(f"infinite recursion on {smodel}: {recref} ({recid})")
111
106
  return finite
112
107
 
113
108
  def validFlt(model: ModelType, path: ModelPath) -> bool:
114
- nonlocal is_valid
109
+ spath, smodel = json_path(path), json.dumps(model)
115
110
  match model:
116
111
  case None:
117
112
  pass
118
113
  case bool():
119
- is_valid &= model
114
+ assert model, f"boolean model must be true at {spath}"
120
115
  case int():
121
- is_valid &= model in (-1, 0, 1)
116
+ assert model in (-1, 0, 1), f"int model values at {spath}"
122
117
  case float():
123
- is_valid &= model in (-1.0, 0.0, 1.0)
118
+ assert model in (-1.0, 0.0, 1.0), f"float model values at {spath}"
124
119
  case str():
125
- if model == "":
120
+ if model == "" or model[0] == "_":
126
121
  pass
127
122
  elif model[0] == "=":
128
- is_valid &= re.match(CONST_RE, model) is not None
123
+ assert re.match(CONST_RE, model) is not None, f"constant model {smodel} at {spath}"
129
124
  elif model[0] == "/":
130
- try:
131
- pattern, ropts = model[1:].rsplit("/", 1)
132
- is_valid &= (ropts == "" or ropts.isalpha()) and is_regex(pattern)
133
- except Exception:
134
- is_valid = False
125
+ assert "/" in model[1:], f"regex model {smodel} has closing marker at {spath}"
126
+ pattern, ropts = model[1:].rsplit("/", 1)
127
+ assert (ropts == "" or ropts.isalpha()) and is_regex(pattern), f"regex model {smodel} at {spath}"
135
128
  elif model[0] == "$":
136
129
  # reject predef extensions
137
130
  if not extend and model.startswith("$__EXTENSION_"):
138
- is_valid = False
139
- else: # TODO more checks
131
+ assert False, f"model extensions are enabled at {spath}"
132
+ else: # TODO more checks?
140
133
  pass
141
134
  case list():
142
135
  pass
143
136
  case dict():
137
+ assert len(model.keys() & OP_KW) <= 1, f"no operator mix at {spath}"
144
138
  if "#" in model:
145
- is_valid &= isinstance(model["#"], str)
139
+ assert isinstance(model["#"], str), f"model object comment is a string at {spath}"
146
140
  if "@" in model:
147
141
  if "!" in model:
148
- is_valid &= isinstance(model["!"], bool)
149
- for op in NUM_AB_KW:
150
- if op in model:
151
- is_valid &= isinstance(model[op], (int, float, str))
152
- for k in model.keys():
153
- is_valid &= k in AB_KW
142
+ assert isinstance(model["!"], bool), f"unique (!) is a boolean at {spath}"
143
+ if ".mo" in model:
144
+ assert isinstance(model[".mo"], (int, float)), f"multiple-of extension is a number at {spath}"
145
+ # @ and comparison consistency
146
+ aro_type = ultimate_type(jm, model["@"])
147
+ if aro_type in (int, float):
148
+ assert all(isinstance(model[op], (int, float)) for op in NUM_KW & model.keys()), \
149
+ f"number model has number constraints at {spath}"
150
+ elif aro_type is str:
151
+ assert all(isinstance(model[op], (int, str)) for op in NUM_KW & model.keys()), \
152
+ f"string model has number or string constraints at {spath}"
153
+ elif aro_type in (list, dict):
154
+ assert all(isinstance(model[op], int) for op in NUM_KW & model.keys()), \
155
+ f"array or object model has integer constraints at {spath}"
156
+ elif aro_type is bool:
157
+ assert len(model.keys() & CMP_KW) == 0, f"boolean model has no comparison constraints at {spath}"
158
+ assert all(isinstance(model[op], bool) for op in NEQ_KW & model.keys()), \
159
+ f"boolean model has boolean eq/neq constraints at {spath}"
160
+ elif aro_type is NullType:
161
+ assert len(model.keys() & CMP_KW) == 0, f"null model has no comparison constraints at {spath}"
162
+ assert all(isinstance(model[op], NullType) for op in NEQ_KW & model.keys()), \
163
+ f"null model has null eq/neq constraints at {spath}"
164
+ elif aro_type is TopType:
165
+ assert len(model.keys() & (NUM_KW | ARR_KW)) == 0, \
166
+ f"multi typed model has no constraints at {spath}"
167
+ elif aro_type is None:
168
+ assert len(model.keys() & (NUM_KW | ARR_KW)) == 0, \
169
+ f"no type model has no constraints at {spath}"
170
+ else:
171
+ assert False, f"unexpected model type {aro_type} at {spath}"
172
+ # only comments
173
+ assert all(prop.startswith("#") for prop in model.keys() - ANY_KW), \
174
+ f"miscellaneous keywords are comments at {spath}"
175
+ # lattice consistency
176
+ if model.keys() & ARR_KW:
177
+ assert aro_type is list, f"array model for array constraints at {spath}"
154
178
  elif "|" in model:
155
- is_valid &= isinstance(model["|"], list)
156
- # no other keys in recurse
179
+ assert isinstance(model["|"], list), f"or model is an array at {spath}"
157
180
  elif "^" in model:
158
- is_valid &= isinstance(model["^"], list)
159
- # no other keys in recurse
181
+ assert isinstance(model["^"], list), f"xor model is an array at {spath}"
160
182
  elif "&" in model:
161
- is_valid &= isinstance(model["&"], list)
162
- # no other keys in recurse
183
+ assert isinstance(model["&"], list), f"and model is an array at {spath}"
163
184
  elif "+" in model:
164
- is_valid &= isinstance(model["+"], list)
165
- # no other keys in recurse
185
+ assert isinstance(model["+"], list), f"merge model is an array at {spath}"
166
186
  else: # check object
167
- props = set() # property name collisions
187
+ props = set() # check property name collisions
168
188
  for p, m in model.items():
169
189
  if p == "#":
170
190
  continue
171
- is_valid &= isinstance(p, str)
191
+ assert isinstance(p, str), f"property name {p} is a string at {spath}"
172
192
  if p and p[0] not in ("$", "/"):
173
193
  name = p[1:] if p[0] in ("?", "_", "!") else p
174
- is_valid &= name not in props
194
+ assert name not in props, f"no property name collison at {spath}"
175
195
  props.add(name)
176
196
  # more checks on p if p[0] == "$"
177
197
  case _:
178
- is_valid = False
198
+ assert False, f"unexpected model base type at {spath}"
179
199
  return True
180
200
 
181
- if is_valid and jm._defs:
201
+ try:
182
202
  for name, jmr in jm._defs.items():
183
- is_valid &= finiteRef("$" + name)
184
-
185
- if is_valid:
186
- try:
187
- check(jm, validFlt, "JSON Model Structural Validity")
188
- except AssertionError as e:
189
- log.error(e, exc_info=jm._debug > 0)
190
- is_valid = False
191
- if jm._debug:
192
- raise
193
-
194
- # TODO also check other instances?!
203
+ if caps:
204
+ assert not re.search(r"^[A-Z_][A-Z_0-9]*$", name), \
205
+ f"all caps reserved for predefs at ${name}"
206
+ assert finiteRef("$" + name), f"finite recursion on ${name}"
207
+ check(jm, validFlt, "JSON Model Structural Validity")
208
+ is_valid = True
209
+ except AssertionError as e:
210
+ is_valid = False
211
+ if jm._debug > 0:
212
+ log.error(e, exc_info=True)
213
+ else:
214
+ log.warning(e)
215
+ if jm._debug:
216
+ raise
195
217
 
196
218
  return is_valid
197
219
 
220
+ #
221
+ # ULTIMATE TYPE
222
+ #
198
223
 
199
224
  # ultimate type of predefs
200
225
  _UTYPE = {
201
- "$ANY": None, "$NONE": None,
202
- "$NULL": type(None),
226
+ "$ANY": TopType,
227
+ "$NULL": NullType,
228
+ "$NONE": None, # bottom for infeasible
203
229
  }
204
230
 
205
231
  for predef in BOOL_MODEL_PREDEFS:
@@ -212,18 +238,23 @@ for predef in STR_MODEL_PREDEFS:
212
238
  _UTYPE[predef] = str
213
239
 
214
240
  def _ultimate_type(jm: JsonModel, model: ModelType, names: set[str]) -> type|None:
241
+ if model is None:
242
+ return NullType
215
243
  match model:
216
244
  case str():
217
245
  if model == "" or model[0] not in ("$", "="):
246
+ # cover strings, regex...
218
247
  return type(model)
219
248
  elif model[0] == "=": # constants
220
- return (type(None) if model == "=null" else
221
- bool if model in ("=true", "=false") else
222
- float if "." in model else
223
- int)
224
- elif model in _UTYPE:
249
+ return (
250
+ NullType if model == "=null" else
251
+ bool if model in ("=true", "=false") else
252
+ float if "." in model else
253
+ int
254
+ )
255
+ elif model in _UTYPE: # predefs
225
256
  return _UTYPE[model]
226
- else: # "$..."
257
+ else: # reference "$..."
227
258
  # stop detected recursion
228
259
  if model in names:
229
260
  return None
@@ -237,26 +268,40 @@ def _ultimate_type(jm: JsonModel, model: ModelType, names: set[str]) -> type|Non
237
268
  types = set(_ultimate_type(jm, m, names) for m in models)
238
269
  if len(types) == 1:
239
270
  return types.pop()
240
- else:
271
+ elif len(types) == 0: # |() == $NONE
241
272
  return None
273
+ else:
274
+ return TopType
242
275
  elif "^" in model:
243
276
  assert isinstance(models := model["^"], list)
244
277
  types = set(_ultimate_type(jm, m, names) for m in models)
245
278
  if len(types) == 1:
246
279
  return types.pop()
247
- else:
280
+ elif len(types) == 0:
248
281
  return None
282
+ else:
283
+ return TopType
249
284
  elif "&" in model:
250
285
  assert isinstance(models := model["&"], list)
251
286
  types = set(_ultimate_type(jm, m, names) for m in models)
252
287
  if len(types) == 1:
253
288
  return types.pop()
254
- else:
255
- # possibly not feasible
289
+ elif None in types:
256
290
  return None
291
+ elif len(types) == 0: # &() == $ANY
292
+ return TopType
293
+ else:
294
+ otypes = types - {TopType}
295
+ return (
296
+ None if len(otypes) > 1 else
297
+ otypes.pop() if len(otypes) == 1 else
298
+ TopType
299
+ )
300
+ elif "+" in model:
301
+ return dict
257
302
  else:
258
303
  return type(model) # dict
259
- case _: # None, bool, int, float, list
304
+ case _: # bool, int, float, list
260
305
  return type(model)
261
306
 
262
307
  def ultimate_type(jm: JsonModel, model: ModelType) -> type|None:
@@ -852,8 +852,8 @@ class CLangJansson(Language):
852
852
  elif nparts == 2:
853
853
  first, second = min(part_code.keys()), max(part_code.keys())
854
854
  return (f"({self.num_cmp(var, '<=', first, True, True)}) "
855
- f"? (\n {part_code[first]} ) "
856
- f": (\n {part_code[second]} )")
855
+ f"? (\n {part_code[first]}\n ) "
856
+ f": (\n {part_code[second]}\n )")
857
857
  else:
858
858
  limit = list(sorted(part_code.keys()))[nparts // 2 - 1]
859
859
  _ex = self._part_expr
@@ -879,8 +879,8 @@ class CLangJansson(Language):
879
879
  hash_size, partitions = 0, {0: names}
880
880
 
881
881
  part_code = {
882
- p: " || ".join(
883
- (_str_cmp("s", json.dumps(s), self._byte_order, True) + f" // {self.esc(s)}\n")
882
+ p: "\n || ".join(
883
+ (_str_cmp("s", json.dumps(s), self._byte_order, True) + f" // {self.esc(s)}")
884
884
  for s in sorted(strs, key=lambda s: (len(s), s)))
885
885
  for p, strs in partitions.items()
886
886
  }
@@ -0,0 +1 @@
1
+ 2.0.61
@@ -104,6 +104,10 @@ Accept JSON with objects containing duplicated properties.
104
104
 
105
105
  Allow some extensions to help with JSU back-end implementation.
106
106
 
107
+ =item B<--caps> or B<--no-caps>
108
+
109
+ Reject (the default) or accept all-caps definitions.
110
+
107
111
  =item B<--from-ir>/B<-fir>
108
112
 
109
113
  Read a JSON intermediate representation, as generated with C<-C -F json>, instead of a