yeptris 0.6.64.0-riscv64-linux-gnu

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 (164) hide show
  1. checksums.yaml +7 -0
  2. data/README.adoc +150 -0
  3. data/ext/build_windows_native.rb +60 -0
  4. data/ext/libyeptris/extconf.rb +57 -0
  5. data/ext/yeptris_native/cbor_ruby.c +198 -0
  6. data/ext/yeptris_native/extconf.rb +99 -0
  7. data/ext/yeptris_native/json_ruby.c +414 -0
  8. data/ext/yeptris_native/version.h +29 -0
  9. data/ext/yeptris_native/yeptris_native.c +507 -0
  10. data/lib/yeptris/3.3/native.so +0 -0
  11. data/lib/yeptris/cbor.rb +169 -0
  12. data/lib/yeptris/document.rb +319 -0
  13. data/lib/yeptris/ffi.rb +572 -0
  14. data/lib/yeptris/json/descriptor.rb +266 -0
  15. data/lib/yeptris/json.rb +502 -0
  16. data/lib/yeptris/materializer.rb +389 -0
  17. data/lib/yeptris/node.rb +482 -0
  18. data/lib/yeptris/psych/class_loader.rb +24 -0
  19. data/lib/yeptris/psych/coder_shim.rb +55 -0
  20. data/lib/yeptris/psych/drop_in.rb +63 -0
  21. data/lib/yeptris/psych/encodable.rb +14 -0
  22. data/lib/yeptris/psych/handler.rb +95 -0
  23. data/lib/yeptris/psych/parser.rb +114 -0
  24. data/lib/yeptris/psych/scalar_scanner.rb +149 -0
  25. data/lib/yeptris/psych/tree_builder.rb +119 -0
  26. data/lib/yeptris/psych/visitors.rb +670 -0
  27. data/lib/yeptris/psych.rb +796 -0
  28. data/lib/yeptris/schema.rb +253 -0
  29. data/lib/yeptris/validation.rb +320 -0
  30. data/lib/yeptris/valueml.rb +477 -0
  31. data/lib/yeptris/yaml/descriptor.rb +56 -0
  32. data/lib/yeptris/yaml.rb +668 -0
  33. data/lib/yeptris.rb +130 -0
  34. data/libyeptris.so +0 -0
  35. data/vendor/libyeptris/CMakeLists.txt +280 -0
  36. data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
  37. data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
  38. data/vendor/libyeptris/src/CMakeLists.txt +183 -0
  39. data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
  40. data/vendor/libyeptris/src/include/yeptris/cbor.h +174 -0
  41. data/vendor/libyeptris/src/include/yeptris/dom.h +196 -0
  42. data/vendor/libyeptris/src/include/yeptris/emit.h +128 -0
  43. data/vendor/libyeptris/src/include/yeptris/error.h +42 -0
  44. data/vendor/libyeptris/src/include/yeptris/events.h +171 -0
  45. data/vendor/libyeptris/src/include/yeptris/json.h +57 -0
  46. data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
  47. data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
  48. data/vendor/libyeptris/src/include/yeptris/marshal.h +75 -0
  49. data/vendor/libyeptris/src/include/yeptris/parse.h +121 -0
  50. data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
  51. data/vendor/libyeptris/src/include/yeptris/resolve.h +81 -0
  52. data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
  53. data/vendor/libyeptris/src/include/yeptris/tape.h +128 -0
  54. data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
  55. data/vendor/libyeptris/src/include/yeptris/validate.h +401 -0
  56. data/vendor/libyeptris/src/include/yeptris/values.h +108 -0
  57. data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
  58. data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
  59. data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
  60. data/vendor/libyeptris/src/include/yeptris.h +24 -0
  61. data/vendor/libyeptris/src/yeptris/build.c +393 -0
  62. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +35 -0
  63. data/vendor/libyeptris/src/yeptris/cbor/decode.c +1054 -0
  64. data/vendor/libyeptris/src/yeptris/cbor/encode.c +836 -0
  65. data/vendor/libyeptris/src/yeptris/cbor/encode_priv.h +32 -0
  66. data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +982 -0
  67. data/vendor/libyeptris/src/yeptris/cbor/sink.h +36 -0
  68. data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
  69. data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
  70. data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
  71. data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
  72. data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
  73. data/vendor/libyeptris/src/yeptris/common/error.h +81 -0
  74. data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
  75. data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
  76. data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
  77. data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
  78. data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
  79. data/vendor/libyeptris/src/yeptris/common/simd_text.h +342 -0
  80. data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +672 -0
  81. data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +793 -0
  82. data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +324 -0
  83. data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
  84. data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
  85. data/vendor/libyeptris/src/yeptris/doc.h +86 -0
  86. data/vendor/libyeptris/src/yeptris/dom/dom.c +1312 -0
  87. data/vendor/libyeptris/src/yeptris/dom/dom.h +332 -0
  88. data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
  89. data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
  90. data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
  91. data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
  92. data/vendor/libyeptris/src/yeptris/dom/ytape.c +2323 -0
  93. data/vendor/libyeptris/src/yeptris/dom/ytape.h +96 -0
  94. data/vendor/libyeptris/src/yeptris/emit/emit.c +670 -0
  95. data/vendor/libyeptris/src/yeptris/emit/float/api.h +43 -0
  96. data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
  97. data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
  98. data/vendor/libyeptris/src/yeptris/emit/float/fpconv.c +428 -0
  99. data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
  100. data/vendor/libyeptris/src/yeptris/emit/style.c +21 -0
  101. data/vendor/libyeptris/src/yeptris/emit/style.h +32 -0
  102. data/vendor/libyeptris/src/yeptris/emit/writer.c +1951 -0
  103. data/vendor/libyeptris/src/yeptris/emit/writer.h +111 -0
  104. data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
  105. data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
  106. data/vendor/libyeptris/src/yeptris/encoding/transcode.c +157 -0
  107. data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
  108. data/vendor/libyeptris/src/yeptris/events/capture.c +166 -0
  109. data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
  110. data/vendor/libyeptris/src/yeptris/events/iterparse.c +298 -0
  111. data/vendor/libyeptris/src/yeptris/events/pull.c +117 -0
  112. data/vendor/libyeptris/src/yeptris/events/push.c +151 -0
  113. data/vendor/libyeptris/src/yeptris/events/recorder.c +144 -0
  114. data/vendor/libyeptris/src/yeptris/events/values.c +630 -0
  115. data/vendor/libyeptris/src/yeptris/events/values_priv.h +53 -0
  116. data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
  117. data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
  118. data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
  119. data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
  120. data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
  121. data/vendor/libyeptris/src/yeptris/marshal.c +988 -0
  122. data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
  123. data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
  124. data/vendor/libyeptris/src/yeptris/memory/arena.c +150 -0
  125. data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
  126. data/vendor/libyeptris/src/yeptris/memory/pool.c +133 -0
  127. data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
  128. data/vendor/libyeptris/src/yeptris/parse/engine.c +6528 -0
  129. data/vendor/libyeptris/src/yeptris/parse/engine.h +96 -0
  130. data/vendor/libyeptris/src/yeptris/parse/events.h +137 -0
  131. data/vendor/libyeptris/src/yeptris/parse/numbers.c +374 -0
  132. data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
  133. data/vendor/libyeptris/src/yeptris/parse/scalars.c +435 -0
  134. data/vendor/libyeptris/src/yeptris/parse/scalars.h +87 -0
  135. data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +358 -0
  136. data/vendor/libyeptris/src/yeptris/parse.c +1074 -0
  137. data/vendor/libyeptris/src/yeptris/plan.c +824 -0
  138. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +339 -0
  139. data/vendor/libyeptris/src/yeptris/resolve/core12.c +153 -0
  140. data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
  141. data/vendor/libyeptris/src/yeptris/resolve/json12.c +109 -0
  142. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +103 -0
  143. data/vendor/libyeptris/src/yeptris/resolve/tags.c +250 -0
  144. data/vendor/libyeptris/src/yeptris/scan/json.c +839 -0
  145. data/vendor/libyeptris/src/yeptris/scan/json.h +116 -0
  146. data/vendor/libyeptris/src/yeptris/scan/scan.c +862 -0
  147. data/vendor/libyeptris/src/yeptris/scan/scan.h +177 -0
  148. data/vendor/libyeptris/src/yeptris/schema.c +309 -0
  149. data/vendor/libyeptris/src/yeptris/tape.c +2375 -0
  150. data/vendor/libyeptris/src/yeptris/tape_in.h +39 -0
  151. data/vendor/libyeptris/src/yeptris/validate/compile.c +306 -0
  152. data/vendor/libyeptris/src/yeptris/validate/internal.h +347 -0
  153. data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1922 -0
  154. data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
  155. data/vendor/libyeptris/src/yeptris/validate/regexp.c +1600 -0
  156. data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
  157. data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
  158. data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
  159. data/vendor/libyeptris/src/yeptris/validate/validate.c +1043 -0
  160. data/vendor/libyeptris/src/yeptris/version.c +7 -0
  161. data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
  162. data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
  163. data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
  164. metadata +221 -0
@@ -0,0 +1,347 @@
1
+ /* validate/internal.h — the validation face's shared internals (#882).
2
+ *
3
+ * Private to src/yeptris/validate/: the report shape, the diagnostic
4
+ * emitter (path capture + line/col resolution), and the JSON-pointer
5
+ * scratch path. The two walks (validate.c's schema family and
6
+ * jsonschema.c's keyword subset) share only this — MECE keeps the
7
+ * checks themselves in their own TUs.
8
+ */
9
+ #ifndef YEP_VALIDATE_INTERNAL_H
10
+ #define YEP_VALIDATE_INTERNAL_H
11
+
12
+ #include <stdarg.h>
13
+ #include <stddef.h>
14
+ #include <stdint.h>
15
+
16
+ #include <yeptris/validate.h>
17
+
18
+ #include "../dom/dom.h"
19
+
20
+ #ifdef __cplusplus
21
+ extern "C" {
22
+ #endif
23
+
24
+ /* The report cap: a hostile document can carry O(nodes) violations, so
25
+ * the walk stops here and the LIMIT sentinel replaces the last slot. */
26
+ #define YEP_VALIDATE_MAX_DIAGS 256
27
+
28
+ struct yeptris_validate_report {
29
+ yeptris_diagnostic* diags;
30
+ uint32_t count;
31
+ int truncated;
32
+ };
33
+
34
+ typedef struct yep_vctx {
35
+ const yep_dom* dom;
36
+ yeptris_validate_report* rep;
37
+ /* line/col resolution over the node bytes (lazy: built on the
38
+ * first positioned diagnostic; valid documents never pay) */
39
+ const char* input;
40
+ size_t input_len;
41
+ uint32_t* line_off; /* byte offset of every line start */
42
+ uint32_t line_cnt, line_cap;
43
+ /* JSON-pointer path under construction (DFS scratch) */
44
+ char* path;
45
+ size_t path_len, path_cap;
46
+ int depth; /* the walk's nesting guard (never exceeds the DOM's) */
47
+ int oom; /* an allocation failed: stop diagnosing */
48
+ /* JSON Schema trial suppression (anyOf/oneOf/not probes): emits
49
+ * inside a probe never reach the report and never touch
50
+ * fail_mark — the probe's own validity is ITS trial_fail delta
51
+ * (zero delta = held), the enclosing application's is its
52
+ * fail_mark delta */
53
+ int suppress;
54
+ /* the walks' invalid-application counters: every emit increments
55
+ * exactly one of them (suppressed -> trial_fail, otherwise
56
+ * fail_mark), so an application's validity is one comparison (the
57
+ * unevaluated* annotation model reads fail_mark) */
58
+ int fail_mark;
59
+ int trial_fail;
60
+ int ref_depth; /* consecutive $ref/$dynamicRef expansions */
61
+ /* the event route's staging hook (#902): when set, composed
62
+ * diagnostics join the OPEN mapping's stage (the flush replays
63
+ * [own tag][duplicates][pair content] so report order stays the
64
+ * DOM walk's); the cap counts the walk position (rep count +
65
+ * staged). NULL on the DOM route — the report path, unchanged. */
66
+ void (*stage_put)(void* stage, const yeptris_diagnostic* d);
67
+ void* stage;
68
+ size_t staged;
69
+ /* the tag-driven registry (#906 slice 4): NULL = no bindings —
70
+ * the DOM route only (the event route keeps its lanes). */
71
+ const yeptris_schema_registry* reg;
72
+ } yep_vctx;
73
+
74
+ /* Offset of a node's first positioned byte (the value span of the node
75
+ * itself, or of its first scalar leaf for collections; UINT32_MAX when
76
+ * everything reachable lives in the arena — line/col unknown). */
77
+ uint32_t yep_validate_node_off(const yep_dom* d, uint32_t id);
78
+
79
+ /* ---- the fact cores (shared by the DOM walk and the event route) -------
80
+ *
81
+ * The family checks read five facts per node: kind (yep_dom_kind),
82
+ * explicit-tag presence, the resolved tag id, the plainness law
83
+ * (PLAIN style or the implicit flag), and the value bytes. The DOM
84
+ * walk extracts them from yep_dnode; the event route (#902) extracts
85
+ * the same five from the engine's events — both call THESE cores, so
86
+ * a verdict change lands once and both routes move together. `off` is
87
+ * the caller's position fact (the DOM's node_off law / the event
88
+ * route's borrowed-view law); UINT32_MAX = unpositioned (line/col 0).
89
+ * A zero-length value decodes to {NULL, 0} (the yep_dom_view law). */
90
+
91
+ /* The scalar tag law: explicit tag wins, then the resolver verdict for
92
+ * plain/implicit scalars, then str for quoted/block styles. */
93
+ uint8_t yep_validate_tag_of(uint8_t tag_id, int has_tag, int plainish);
94
+
95
+ /* Explicit-tag consistency (both families). */
96
+ struct yep_resolver;
97
+ void yep_check_tag_facts(yep_vctx* c, int kind, int has_tag, uint8_t tag_id, yep_view value,
98
+ uint32_t off, const struct yep_resolver* fam, int json_family);
99
+
100
+ /* json12: a plain scalar must match a JSON production; explicit
101
+ * non-JSON tags rejected. */
102
+ void yep_check_json_scalar_facts(yep_vctx* c, int has_tag, uint8_t tag_id, int plainish,
103
+ yep_view value, uint32_t off);
104
+
105
+ /* json12: a SCALAR mapping key's checks (the caller resolves aliases
106
+ * and non-scalar kinds first — the DOM wrapper keeps that recursion). */
107
+ void yep_check_json_key_facts(yep_vctx* c, int has_tag, uint8_t tag_id, int plainish,
108
+ yep_view value, uint32_t off);
109
+
110
+ /* ---- the canonical digest law (spec 3.2.1.3) --------------------------- */
111
+
112
+ /* The 64-bit fold primitive behind every canonical fingerprint. */
113
+ uint64_t yep_validate_hash_mix(uint64_t h, uint64_t v);
114
+
115
+ /* Seed constants of the canonical fold (validate.c's DOM hash and the
116
+ * event route's streaming fold must agree bit for bit). */
117
+ #define YEP_VAL_DIGEST_SEQ_SEED 0x5EED51ULL /* sequences: ordered fold */
118
+ #define YEP_VAL_DIGEST_MAP_SEED 0x5EED4A9ULL /* mappings: XOR of pairs */
119
+ #define YEP_VAL_DIGEST_PAIR_SEED 0x51D1ULL /* one (key, value) pair */
120
+ #define YEP_VAL_DIGEST_ALIAS 0xA11AULL /* unbound alias fallback */
121
+ #define YEP_VAL_DIGEST_SCALAR 0x5CA1AULL /* scalar base (tag added) */
122
+
123
+ /* The scalar arm of the canonical hash: base + tag, the numeric VALUE
124
+ * for int/float (the double bits), the raw bytes otherwise. */
125
+ uint64_t yep_validate_scalar_digest(uint8_t tag, yep_view v);
126
+
127
+ /* Emits one diagnostic at the current path. line/col resolve from
128
+ * `off` through the lazy line index; 0/0 when unknown. Detail is
129
+ * printf-composed into the bounded slot. Never fails the caller: the
130
+ * report cap turns the last slot into the LIMIT sentinel. */
131
+ void yep_validate_emit(yep_vctx* c, int code, uint32_t off, const char* detail_fmt, ...);
132
+
133
+ /* The report-path writer (the cap law's one home): appends a RESOLVED
134
+ * diagnostic, or turns the last slot into the LIMIT sentinel once the
135
+ * report is full. The event route's flush replays its staged
136
+ * diagnostics through this — the compose time (and therefore the path
137
+ * and position) stays the walk's. */
138
+ void yep_validate_report_put(yep_vctx* c, const yeptris_diagnostic* d);
139
+
140
+ /* JSON-pointer path scratch: push an escaped segment / a decimal
141
+ * index, pop to a mark. 0 ok, -1 OOM (ctx.oom set; the walk unwinds). */
142
+ int yep_validate_path_push(yep_vctx* c, const char* seg, size_t seg_len);
143
+ int yep_validate_path_push_index(yep_vctx* c, uint32_t idx);
144
+ void yep_validate_path_pop(yep_vctx* c, size_t mark);
145
+
146
+ /* The stream face's document attribution (#885 item 4): a validated
147
+ * stream is addressed as an array of documents — when it holds MORE
148
+ * THAN ONE document, every diagnostic path is prefixed with the
149
+ * document's index segment, so diagnostics name their document ("/1/k"
150
+ * is key k of document 1; the line/col stay input-absolute). Streams
151
+ * with a single document keep the bare instance pointers (the
152
+ * JSON-Schema-Test-Suite's paths and every single-doc pin are
153
+ * unchanged). Call before a document's walk and pop the returned mark
154
+ * after it; OOM sets ctx.oom and the walk unwinds. */
155
+ size_t yep_validate_doc_prefix(yep_vctx* c, int qualified, uint32_t index);
156
+
157
+ /* The bounded ECMA-regex subset behind `pattern` (jsonschema.c):
158
+ * literals, '.', classes, groups, alternation, the greedy/lazy
159
+ * quantifiers, anchors, \d\w\s\D\W\S\b\B, \xHH, \cX and the
160
+ * \p{Letter}/\p{digit} property escapes. Classes match WHOLE UTF-8
161
+ * code points (the named classes carry range tables: ASCII \d/\w,
162
+ * Unicode \s, code-point complements, generated Unicode properties);
163
+ * literals match byte-wise. A Thompson NFA over per-thread positions —
164
+ * O(len * m), no backtracking blowup, no recursion over the subject.
165
+ * Patterns over the program budget are invalid. 1 match, 0 no match,
166
+ * -1 invalid pattern. */
167
+ int yep_re_search(const char* pat, uint32_t pat_len, const char* s, uint32_t s_len);
168
+
169
+ /* The retained-program cache behind the compiled schema (#885 item 3):
170
+ * pattern source -> compiled NFA, populated at compile time, immutable
171
+ * afterwards (read-only sharing, the document law). A miss — a NULL
172
+ * cache included — compiles fresh with yep_re_search's exact verdicts;
173
+ * cache_add returns 1 stored, 0 not retained (invalid pattern, empty,
174
+ * table full — misses recompile), -1 allocation failure (loud). */
175
+ typedef struct yep_re_cache yep_re_cache;
176
+ yep_re_cache* yep_re_cache_new(void);
177
+ void yep_re_cache_free(yep_re_cache* t);
178
+ int yep_re_cache_add(yep_re_cache* t, const char* pat, uint32_t plen);
179
+ int yep_re_cache_search(const yep_re_cache* t, const char* pat, uint32_t plen, const char* s,
180
+ uint32_t s_len);
181
+
182
+ /* Canonical scalar tag of a DOM node (explicit tag, then the parse
183
+ * resolver's plain verdict, then str): the value model both walks
184
+ * compare under. */
185
+ uint8_t yep_validate_scalar_tag(const yep_dnode* n);
186
+
187
+ /* Canonical-form hash and equality over DOM subtrees (spec 3.2.1.3:
188
+ * same tag + canonical form; numbers numerically within a tag). The
189
+ * equality may cross documents — the schema's enum/const live in a
190
+ * different DOM than the instance. Depth-bounded. */
191
+ uint64_t yep_validate_node_hash(const yep_dom* d, uint32_t id, int depth);
192
+ int yep_validate_node_equal(const yep_dom* da, uint32_t a, const yep_dom* db, uint32_t b,
193
+ int depth);
194
+
195
+ /* ---- the schema identifier map (resources.c) ----------------------------- */
196
+
197
+ /* Bounded identifier tables: an identifier past a cap (or a URI over
198
+ * the length cap) is not registered — the reference then fails to
199
+ * resolve at validation (DIAG_REF), exactly like any other unknown
200
+ * target. Nothing loops, nothing guesses. */
201
+ #define YEP_JS_MAX_RESOURCES 1024
202
+ #define YEP_JS_MAX_ANCHORS 1024
203
+ #define YEP_JS_MAX_REFSITES 8192
204
+ #define YEP_JS_URI_MAX 512
205
+ #define YEP_JS_MAX_SCOPE 256 /* the runtime dynamic-scope stack */
206
+
207
+ /* One schema RESOURCE: a canonical (fragment-free) URI naming the
208
+ * schema object that established it with "$id" — pointer fragments
209
+ * walk from that node. The document root is resource 0 (the empty
210
+ * base "" when the schema has no "$id"). */
211
+ typedef struct {
212
+ char* uri;
213
+ uint32_t root;
214
+ } js_resource;
215
+
216
+ /* A plain-name fragment: canonical URI + '#' + name -> the node.
217
+ * `dynamic` distinguishes "$dynamicAnchor" (the $dynamicRef
218
+ * extension points) from "$anchor". `res` is the owning resource
219
+ * index (anchors belong to the resource of their nearest "$id"). */
220
+ typedef struct {
221
+ char* key;
222
+ uint32_t node;
223
+ uint32_t res;
224
+ uint8_t dynamic;
225
+ } js_anchor;
226
+
227
+ /* A "$ref"/"$dynamicRef" site: the canonical base URI it resolves
228
+ * against, and that base resource's root (where fragment-only
229
+ * pointers start walking). */
230
+ typedef struct {
231
+ uint32_t site;
232
+ char* base;
233
+ uint32_t base_root;
234
+ } js_refsite;
235
+
236
+ /* The compiled schema's identifier map (built once by the crawl at
237
+ * compile time, read-only afterwards — the document law). Everything
238
+ * it owns dies with yep_js_resources_free. */
239
+ typedef struct {
240
+ js_resource* res;
241
+ uint32_t res_n;
242
+ js_anchor* anc;
243
+ uint32_t anc_n;
244
+ js_refsite* site;
245
+ uint32_t site_n;
246
+ uint32_t* rindex; /* node id -> owning resource index (UINT32_MAX unvisited) */
247
+ uint32_t rindex_n;
248
+ } js_resources;
249
+
250
+ /* The constructor: one bounded DFS over the schema DOM collecting
251
+ * every $id/$anchor/$dynamicAnchor and $ref/$dynamicRef site. NULL on
252
+ * allocation failure. */
253
+ js_resources* yep_js_resources_crawl(const yep_dom* d, uint32_t root);
254
+ void yep_js_resources_free(js_resources* r);
255
+
256
+ /* Lookups (linear over the bounded tables): resource by canonical
257
+ * URI; anchor by key (URI + '#' + name); a resource's DYNAMIC anchor
258
+ * by plain name (the dynamic-scope search's per-resource probe); a
259
+ * ref site's base. Each returns 1 found, 0 absent. */
260
+ int js_res_find(const js_resources* r, const char* uri, uint32_t* idx_out);
261
+ int js_anchor_find(const js_resources* r, const char* key, size_t key_len, uint32_t* node_out,
262
+ uint8_t* dyn_out);
263
+ int js_anchor_dynamic_in_res(const js_resources* r, uint32_t res_idx, const char* name,
264
+ size_t name_len, uint32_t* node_out);
265
+ int js_refsite_find(const js_resources* r, uint32_t site_node, const char** base,
266
+ uint32_t* base_root);
267
+
268
+ /* URI-reference resolution (RFC 3986 section 5.2, the exercised
269
+ * subset: schemes, authorities, path merge with dot-segment removal,
270
+ * query carry). Produces the canonical fragment-free form. 0 ok, -1
271
+ * overlong (out holds ""). */
272
+ int js_uri_resolve(const char* base, const char* ref, size_t ref_len, char* out, size_t cap);
273
+
274
+ /* jsonschema.c's driver: applies the schema tree (its own DOM) to
275
+ * every instance document root, emitting into `rep`. `cache` is the
276
+ * compiled schema's retained pattern programs (NULL: none — the
277
+ * one-shot face). `res` is the compiled schema's identifier map (the
278
+ * resources/anchors/ref-site bases the reference machinery resolves
279
+ * through; NULL: none — every reference beyond a bare "#/..." pointer
280
+ * stays unresolvable). Returns 0, -1 on OOM. */
281
+ int yep_jsonschema_run(const yep_dom* schema_dom, uint32_t schema_root, const yep_dom* instance_dom,
282
+ const uint32_t* doc_roots, uint32_t doc_count, yeptris_validate_report* rep,
283
+ const yep_re_cache* cache, const js_resources* res);
284
+
285
+ /* The report constructor (validate.c owns the report machinery): a
286
+ * fresh empty report, NULL on allocation failure. */
287
+ yeptris_validate_report* yep_validate_report_new(void);
288
+
289
+ /* compile.c's seam (#885 item 3): the compiled-schema constructor with
290
+ * an explicit status — the one-shot face preserves its exact observable
291
+ * statuses through it. NULL on failure with *st = YEPTRIS_ERROR_ARG
292
+ * (NULL bytes with length, or bytes that hold no document; the thread
293
+ * error channel carries the message), the failed parse's status, or
294
+ * YEPTRIS_ERROR_MEMORY. */
295
+ struct yeptris_schema;
296
+ yeptris_schema* yep_schema_compile_st(const char* bytes, size_t n, YeptrisStatus* st);
297
+
298
+ /* The validation-family selector shared by both routes (#902): CORE_12
299
+ * and JSON_12 resolve to their resolvers (json_family set for the
300
+ * strict lane); every other schema is a parse-compat resolver, not a
301
+ * family — 0 with the thread error channel set, exactly like the DOM
302
+ * face's ARG rejection. */
303
+ int yep_validate_schema_family(YeptrisSchema schema, const struct yep_resolver** fam,
304
+ int* json_family);
305
+
306
+ /* ---- the tag-driven schema hook (#906 slice 4) --------------------------- */
307
+
308
+ /* The compiled schema's read-only evaluation view: everything the
309
+ * keyword walk reads, borrowed from the handle (the REGISTRY LAW
310
+ * applies — the handle must outlive every view taken from it). */
311
+ typedef struct {
312
+ const yep_dom* dom; /* the schema's retained tree */
313
+ uint32_t sroot; /* its document-0 root */
314
+ const yep_re_cache* cache; /* retained pattern programs */
315
+ const js_resources* res; /* the identifier map */
316
+ } yep_schema_view;
317
+
318
+ /* compile.c: fills *out from the handle. NULL handle fills zeros. */
319
+ void yep_schema_view_of(const yeptris_schema* s, yep_schema_view* out);
320
+
321
+ /* jsonschema.c: applies the bound schema's root to ONE instance
322
+ * subtree. `inst` is the CALLER'S walk context (the DOM route's
323
+ * yep_vctx) — its path prefix (the tag site), report, line index and
324
+ * guards are shared, so the subtree's misses land at the tag site's
325
+ * path + the schema's instance pointers with the offending node's
326
+ * position, and the cap law holds across the whole report. The
327
+ * context's scratch pointers (path buffer, line index) may have been
328
+ * reallocated on return — the caller frees them as before. Returns 0,
329
+ * -1 on OOM (ctx.oom set; the walk unwinds). */
330
+ int yep_jsonschema_apply_subtree(const yep_dom* schema_dom, uint32_t schema_root, yep_vctx* inst,
331
+ uint32_t inst_root, const yep_re_cache* cache,
332
+ const js_resources* res);
333
+
334
+ /* ---- the structured output face (#906 slice 5) ---------------------------
335
+ *
336
+ * output.c: the report -> JSON transform (the published BASIC shape;
337
+ * the byte contract lives on the public header). The keyword names
338
+ * behind the code-derived keywordLocation pointers — the one table
339
+ * (the output SSOT): a code without a keyword row writes the root
340
+ * pointer "". */
341
+ const char* yep_validate_output_keyword(uint32_t code);
342
+
343
+ #ifdef __cplusplus
344
+ }
345
+ #endif
346
+
347
+ #endif /* YEP_VALIDATE_INTERNAL_H */