structured-context 0.12.0 → 0.13.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 (94) hide show
  1. package/README.md +29 -216
  2. package/dist/api.d.ts +17 -17
  3. package/dist/api.js +12 -12
  4. package/dist/commands/docs.js +1 -0
  5. package/dist/commands/providers.d.ts +4 -0
  6. package/dist/commands/providers.js +52 -0
  7. package/dist/commands/schemas.js +21 -2
  8. package/dist/commands/validate-file.d.ts +3 -0
  9. package/dist/commands/validate-file.js +17 -2
  10. package/dist/commands/validate.d.ts +4 -0
  11. package/dist/commands/validate.js +42 -3
  12. package/dist/config.d.ts +7 -0
  13. package/dist/config.js +26 -3
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +59 -18
  16. package/dist/judge/context.d.ts +20 -0
  17. package/dist/judge/context.js +105 -0
  18. package/dist/judge/factory.d.ts +44 -0
  19. package/dist/judge/factory.js +148 -0
  20. package/dist/judge/index.d.ts +13 -0
  21. package/dist/judge/index.js +8 -0
  22. package/dist/judge/judge-node.d.ts +27 -0
  23. package/dist/judge/judge-node.js +122 -0
  24. package/dist/judge/prompt.d.ts +10 -0
  25. package/dist/judge/prompt.js +92 -0
  26. package/dist/judge/provider/anthropic.d.ts +17 -0
  27. package/dist/judge/provider/anthropic.js +43 -0
  28. package/dist/judge/provider/fake.d.ts +26 -0
  29. package/dist/judge/provider/fake.js +56 -0
  30. package/dist/judge/provider/jev.d.ts +37 -0
  31. package/dist/judge/provider/jev.js +169 -0
  32. package/dist/judge/provider/openai-decisions.d.ts +21 -0
  33. package/dist/judge/provider/openai-decisions.js +84 -0
  34. package/dist/judge/provider/openai.d.ts +20 -0
  35. package/dist/judge/provider/openai.js +53 -0
  36. package/dist/judge/provider/per-rule.d.ts +10 -0
  37. package/dist/judge/provider/per-rule.js +18 -0
  38. package/dist/judge/trim.d.ts +27 -0
  39. package/dist/judge/trim.js +62 -0
  40. package/dist/judge/types.d.ts +92 -0
  41. package/dist/judge/types.js +9 -0
  42. package/dist/judge/verdicts.d.ts +24 -0
  43. package/dist/judge/verdicts.js +82 -0
  44. package/dist/load-space-graph.d.ts +3 -3
  45. package/dist/load-space-graph.js +4 -4
  46. package/dist/plugins/loader.js +1 -1
  47. package/dist/plugins/markdown/parse-embedded.d.ts +2 -0
  48. package/dist/plugins/markdown/parse-embedded.js +161 -24
  49. package/dist/plugins/markdown/read-space.js +4 -9
  50. package/dist/plugins/markdown/render-directory.js +5 -5
  51. package/dist/plugins/markdown/template-sync.js +3 -4
  52. package/dist/plugins/markdown/util.d.ts +26 -5
  53. package/dist/plugins/markdown/util.js +56 -15
  54. package/dist/render/render.d.ts +1 -1
  55. package/dist/render/render.js +1 -1
  56. package/dist/schema/evaluate-rule.d.ts +33 -2
  57. package/dist/schema/evaluate-rule.js +58 -4
  58. package/dist/schema/gating.d.ts +69 -0
  59. package/dist/schema/gating.js +253 -0
  60. package/dist/schema/metadata-contract.d.ts +625 -12
  61. package/dist/schema/metadata-contract.js +110 -4
  62. package/dist/schema/rule-filter.d.ts +12 -0
  63. package/dist/schema/rule-filter.js +46 -0
  64. package/dist/schema/rule-severity.d.ts +13 -0
  65. package/dist/schema/rule-severity.js +33 -0
  66. package/dist/schema/schema.js +31 -1
  67. package/dist/schema/validate-rules.d.ts +17 -8
  68. package/dist/schema/validate-rules.js +91 -48
  69. package/dist/schemas/_knowledge_wiki.json +4 -4
  70. package/dist/schemas/_okf.json +172 -0
  71. package/dist/schemas/_ost_strict.json +15 -6
  72. package/dist/schemas/_sctx_base.json +1 -1
  73. package/dist/schemas/generated/0.13.0/_structured_context_schema_meta.json +400 -0
  74. package/dist/schemas/generated/latest/_structured_context_schema_meta.json +177 -6
  75. package/dist/schemas/okf.json +8 -0
  76. package/dist/space-context.d.ts +2 -2
  77. package/dist/space-context.js +3 -3
  78. package/dist/space-graph.d.ts +1 -1
  79. package/dist/testing.d.ts +1 -1
  80. package/dist/types.d.ts +11 -4
  81. package/dist/validate.d.ts +59 -9
  82. package/dist/validate.js +225 -120
  83. package/docs/concepts.md +52 -6
  84. package/docs/config.md +70 -1
  85. package/docs/rules.md +140 -49
  86. package/docs/schemas.md +43 -18
  87. package/package.json +6 -5
  88. package/schemas/_knowledge_wiki.json +4 -4
  89. package/schemas/_okf.json +172 -0
  90. package/schemas/_ost_strict.json +15 -6
  91. package/schemas/_sctx_base.json +1 -1
  92. package/schemas/generated/0.13.0/_structured_context_schema_meta.json +400 -0
  93. package/schemas/generated/latest/_structured_context_schema_meta.json +177 -6
  94. package/schemas/okf.json +8 -0
@@ -94,6 +94,81 @@ declare const HIERARCHY_LEVEL_SCHEMA: {
94
94
  readonly required: readonly ["type"];
95
95
  readonly additionalProperties: false;
96
96
  };
97
+ /** The verdicts the evaluation reserves besides a rule's own; a verdict map may set a severity for them. */
98
+ export declare const RESERVED_VERDICTS: readonly ["missing-context"];
99
+ /** Related-node kinds a semantic rule's `scope` can add: main-hierarchy edges only. `branch` is ancestors plus descendants. */
100
+ export declare const SEMANTIC_SCOPES: readonly ["parent", "siblings", "children", "ancestors", "descendants", "branch"];
101
+ /** The semantic part of a rule: a model evaluates the node against a rubric and returns a verdict. */
102
+ declare const SEMANTIC_SCHEMA: {
103
+ readonly type: "object";
104
+ readonly properties: {
105
+ /** What the model judges the node against. Falls back to the rule's `description`. */
106
+ readonly rubric: {
107
+ readonly type: "string";
108
+ readonly minLength: 1;
109
+ };
110
+ /**
111
+ * The closed set of verdicts the model may return. Each is a description (what the verdict means, for the
112
+ * model) or `{ description, guidance }`, where `guidance` is shown to the user when it fires.
113
+ * Defaults to `pass`/`fail`.
114
+ */
115
+ readonly verdicts: {
116
+ readonly type: "object";
117
+ readonly additionalProperties: {
118
+ readonly oneOf: readonly [{
119
+ readonly type: "string";
120
+ readonly minLength: 1;
121
+ }, {
122
+ readonly type: "object";
123
+ readonly properties: {
124
+ readonly description: {
125
+ readonly type: "string";
126
+ readonly minLength: 1;
127
+ };
128
+ readonly guidance: {
129
+ readonly type: "string";
130
+ readonly minLength: 1;
131
+ };
132
+ };
133
+ readonly required: readonly ["description"];
134
+ readonly additionalProperties: false;
135
+ }];
136
+ };
137
+ readonly minProperties: 2;
138
+ };
139
+ /**
140
+ * Severity per verdict in effect (declared, default or reserved). A verdict mapped to `ignore` is judged but
141
+ * not reported, and a verdict left out passes. Required with `verdicts`; with the default verdicts, `fail`
142
+ * takes the rule's own `severity` instead.
143
+ */
144
+ readonly severity: {
145
+ readonly type: "object";
146
+ readonly additionalProperties: {
147
+ readonly enum: readonly ["error", "warning", "info", "ignore"];
148
+ };
149
+ readonly minProperties: 1;
150
+ };
151
+ /**
152
+ * Related nodes, along main-hierarchy edges, sent with the evaluated node. Additive; left out or empty means
153
+ * the evaluated node alone.
154
+ */
155
+ readonly scope: {
156
+ readonly type: "array";
157
+ readonly items: {
158
+ readonly enum: readonly ["parent", "siblings", "children", "ancestors", "descendants", "branch"];
159
+ };
160
+ readonly uniqueItems: true;
161
+ };
162
+ /**
163
+ * Which node bodies are sent: `nodeOnly` (the evaluated node's), `fullScope` (it and every related node's),
164
+ * or `true` for `fullScope`. Left out: no bodies.
165
+ */
166
+ readonly includeContent: {
167
+ readonly enum: readonly ["nodeOnly", "fullScope", true];
168
+ };
169
+ };
170
+ readonly additionalProperties: false;
171
+ };
97
172
  declare const RULE_SCHEMA: {
98
173
  readonly type: "object";
99
174
  readonly properties: {
@@ -104,6 +179,9 @@ declare const RULE_SCHEMA: {
104
179
  readonly category: {
105
180
  readonly enum: readonly ["validation", "coherence", "workflow", "best-practice"];
106
181
  };
182
+ /**
183
+ * Severity of a failed `expression` and of the default `fail` verdict. Defaults from the category.
184
+ */
107
185
  readonly severity: {
108
186
  readonly enum: readonly ["error", "warning", "info"];
109
187
  };
@@ -111,23 +189,199 @@ declare const RULE_SCHEMA: {
111
189
  readonly type: "string";
112
190
  readonly minLength: 1;
113
191
  };
114
- readonly check: {
192
+ /** JSONata test a node must pass. When the rule also has `semantic`, a failing node is reported without being evaluated by the model. */
193
+ readonly expression: {
194
+ readonly type: "string";
195
+ readonly minLength: 1;
196
+ };
197
+ /** Optional JSONata applicability condition, evaluated per node before the rule runs. The rule applies only when it returns true. */
198
+ readonly when: {
115
199
  readonly type: "string";
116
200
  readonly minLength: 1;
117
201
  };
202
+ /** A model evaluates the node against a rubric. `{}` takes every default; `true` means the same. */
203
+ readonly semantic: {
204
+ readonly oneOf: readonly [{
205
+ readonly const: true;
206
+ }, {
207
+ readonly type: "object";
208
+ readonly properties: {
209
+ /** What the model judges the node against. Falls back to the rule's `description`. */
210
+ readonly rubric: {
211
+ readonly type: "string";
212
+ readonly minLength: 1;
213
+ };
214
+ /**
215
+ * The closed set of verdicts the model may return. Each is a description (what the verdict means, for the
216
+ * model) or `{ description, guidance }`, where `guidance` is shown to the user when it fires.
217
+ * Defaults to `pass`/`fail`.
218
+ */
219
+ readonly verdicts: {
220
+ readonly type: "object";
221
+ readonly additionalProperties: {
222
+ readonly oneOf: readonly [{
223
+ readonly type: "string";
224
+ readonly minLength: 1;
225
+ }, {
226
+ readonly type: "object";
227
+ readonly properties: {
228
+ readonly description: {
229
+ readonly type: "string";
230
+ readonly minLength: 1;
231
+ };
232
+ readonly guidance: {
233
+ readonly type: "string";
234
+ readonly minLength: 1;
235
+ };
236
+ };
237
+ readonly required: readonly ["description"];
238
+ readonly additionalProperties: false;
239
+ }];
240
+ };
241
+ readonly minProperties: 2;
242
+ };
243
+ /**
244
+ * Severity per verdict in effect (declared, default or reserved). A verdict mapped to `ignore` is judged but
245
+ * not reported, and a verdict left out passes. Required with `verdicts`; with the default verdicts, `fail`
246
+ * takes the rule's own `severity` instead.
247
+ */
248
+ readonly severity: {
249
+ readonly type: "object";
250
+ readonly additionalProperties: {
251
+ readonly enum: readonly ["error", "warning", "info", "ignore"];
252
+ };
253
+ readonly minProperties: 1;
254
+ };
255
+ /**
256
+ * Related nodes, along main-hierarchy edges, sent with the evaluated node. Additive; left out or empty means
257
+ * the evaluated node alone.
258
+ */
259
+ readonly scope: {
260
+ readonly type: "array";
261
+ readonly items: {
262
+ readonly enum: readonly ["parent", "siblings", "children", "ancestors", "descendants", "branch"];
263
+ };
264
+ readonly uniqueItems: true;
265
+ };
266
+ /**
267
+ * Which node bodies are sent: `nodeOnly` (the evaluated node's), `fullScope` (it and every related node's),
268
+ * or `true` for `fullScope`. Left out: no bodies.
269
+ */
270
+ readonly includeContent: {
271
+ readonly enum: readonly ["nodeOnly", "fullScope", true];
272
+ };
273
+ };
274
+ readonly additionalProperties: false;
275
+ }];
276
+ };
118
277
  readonly type: {
119
278
  readonly type: "string";
120
279
  readonly minLength: 1;
121
280
  };
122
- readonly scope: {
123
- readonly enum: readonly ["global"];
281
+ /** Run once for the whole space instead of once per node. */
282
+ readonly global: {
283
+ readonly type: "boolean";
124
284
  };
125
285
  readonly override: {
126
286
  readonly type: "boolean";
127
287
  };
288
+ /** Whether a failure of this rule gates (suppresses) downstream rules on the node's hierarchy subtree. Defaults to true when the failure's severity is `error`. */
289
+ readonly gatesDescendants: {
290
+ readonly type: "boolean";
291
+ };
128
292
  };
129
- readonly required: readonly ["id", "category", "description", "check"];
293
+ readonly required: readonly ["id", "category", "description"];
130
294
  readonly additionalProperties: false;
295
+ readonly allOf: readonly [{
296
+ readonly anyOf: readonly [{
297
+ readonly required: readonly ["expression"];
298
+ }, {
299
+ readonly required: readonly ["semantic"];
300
+ }];
301
+ }, {
302
+ readonly if: {
303
+ readonly required: readonly ["global"];
304
+ readonly properties: {
305
+ readonly global: {
306
+ readonly const: true;
307
+ };
308
+ };
309
+ };
310
+ readonly then: {
311
+ readonly not: {
312
+ readonly anyOf: readonly [{
313
+ readonly required: readonly ["when"];
314
+ }, {
315
+ readonly required: readonly ["type"];
316
+ }, {
317
+ readonly required: readonly ["semantic"];
318
+ }];
319
+ };
320
+ };
321
+ }, {
322
+ readonly if: {
323
+ readonly required: readonly ["semantic"];
324
+ readonly properties: {
325
+ readonly semantic: {
326
+ readonly type: "object";
327
+ readonly required: readonly ["verdicts"];
328
+ };
329
+ };
330
+ };
331
+ readonly then: {
332
+ readonly properties: {
333
+ readonly semantic: {
334
+ readonly type: "object";
335
+ readonly required: readonly ["severity"];
336
+ };
337
+ };
338
+ };
339
+ }, {
340
+ readonly if: {
341
+ readonly required: readonly ["semantic"];
342
+ readonly properties: {
343
+ readonly semantic: {
344
+ readonly type: "object";
345
+ readonly not: {
346
+ readonly required: readonly ["verdicts"];
347
+ };
348
+ };
349
+ };
350
+ };
351
+ readonly then: {
352
+ readonly properties: {
353
+ readonly semantic: {
354
+ readonly type: "object";
355
+ readonly properties: {
356
+ readonly severity: {
357
+ readonly type: "object";
358
+ readonly not: {
359
+ readonly required: readonly ["fail"];
360
+ };
361
+ };
362
+ };
363
+ };
364
+ };
365
+ };
366
+ }, {
367
+ readonly if: {
368
+ readonly required: readonly ["semantic"];
369
+ readonly properties: {
370
+ readonly semantic: {
371
+ readonly type: "object";
372
+ readonly required: readonly ["verdicts"];
373
+ };
374
+ };
375
+ readonly not: {
376
+ readonly required: readonly ["expression"];
377
+ };
378
+ };
379
+ readonly then: {
380
+ readonly not: {
381
+ readonly required: readonly ["severity"];
382
+ };
383
+ };
384
+ }];
131
385
  };
132
386
  declare const REF_SCHEMA: {
133
387
  readonly type: "object";
@@ -435,6 +689,9 @@ export declare const METADATA_SCHEMA: {
435
689
  readonly category: {
436
690
  readonly enum: readonly ["validation", "coherence", "workflow", "best-practice"];
437
691
  };
692
+ /**
693
+ * Severity of a failed `expression` and of the default `fail` verdict. Defaults from the category.
694
+ */
438
695
  readonly severity: {
439
696
  readonly enum: readonly ["error", "warning", "info"];
440
697
  };
@@ -442,23 +699,199 @@ export declare const METADATA_SCHEMA: {
442
699
  readonly type: "string";
443
700
  readonly minLength: 1;
444
701
  };
445
- readonly check: {
702
+ /** JSONata test a node must pass. When the rule also has `semantic`, a failing node is reported without being evaluated by the model. */
703
+ readonly expression: {
446
704
  readonly type: "string";
447
705
  readonly minLength: 1;
448
706
  };
707
+ /** Optional JSONata applicability condition, evaluated per node before the rule runs. The rule applies only when it returns true. */
708
+ readonly when: {
709
+ readonly type: "string";
710
+ readonly minLength: 1;
711
+ };
712
+ /** A model evaluates the node against a rubric. `{}` takes every default; `true` means the same. */
713
+ readonly semantic: {
714
+ readonly oneOf: readonly [{
715
+ readonly const: true;
716
+ }, {
717
+ readonly type: "object";
718
+ readonly properties: {
719
+ /** What the model judges the node against. Falls back to the rule's `description`. */
720
+ readonly rubric: {
721
+ readonly type: "string";
722
+ readonly minLength: 1;
723
+ };
724
+ /**
725
+ * The closed set of verdicts the model may return. Each is a description (what the verdict means, for the
726
+ * model) or `{ description, guidance }`, where `guidance` is shown to the user when it fires.
727
+ * Defaults to `pass`/`fail`.
728
+ */
729
+ readonly verdicts: {
730
+ readonly type: "object";
731
+ readonly additionalProperties: {
732
+ readonly oneOf: readonly [{
733
+ readonly type: "string";
734
+ readonly minLength: 1;
735
+ }, {
736
+ readonly type: "object";
737
+ readonly properties: {
738
+ readonly description: {
739
+ readonly type: "string";
740
+ readonly minLength: 1;
741
+ };
742
+ readonly guidance: {
743
+ readonly type: "string";
744
+ readonly minLength: 1;
745
+ };
746
+ };
747
+ readonly required: readonly ["description"];
748
+ readonly additionalProperties: false;
749
+ }];
750
+ };
751
+ readonly minProperties: 2;
752
+ };
753
+ /**
754
+ * Severity per verdict in effect (declared, default or reserved). A verdict mapped to `ignore` is judged but
755
+ * not reported, and a verdict left out passes. Required with `verdicts`; with the default verdicts, `fail`
756
+ * takes the rule's own `severity` instead.
757
+ */
758
+ readonly severity: {
759
+ readonly type: "object";
760
+ readonly additionalProperties: {
761
+ readonly enum: readonly ["error", "warning", "info", "ignore"];
762
+ };
763
+ readonly minProperties: 1;
764
+ };
765
+ /**
766
+ * Related nodes, along main-hierarchy edges, sent with the evaluated node. Additive; left out or empty means
767
+ * the evaluated node alone.
768
+ */
769
+ readonly scope: {
770
+ readonly type: "array";
771
+ readonly items: {
772
+ readonly enum: readonly ["parent", "siblings", "children", "ancestors", "descendants", "branch"];
773
+ };
774
+ readonly uniqueItems: true;
775
+ };
776
+ /**
777
+ * Which node bodies are sent: `nodeOnly` (the evaluated node's), `fullScope` (it and every related node's),
778
+ * or `true` for `fullScope`. Left out: no bodies.
779
+ */
780
+ readonly includeContent: {
781
+ readonly enum: readonly ["nodeOnly", "fullScope", true];
782
+ };
783
+ };
784
+ readonly additionalProperties: false;
785
+ }];
786
+ };
449
787
  readonly type: {
450
788
  readonly type: "string";
451
789
  readonly minLength: 1;
452
790
  };
453
- readonly scope: {
454
- readonly enum: readonly ["global"];
791
+ /** Run once for the whole space instead of once per node. */
792
+ readonly global: {
793
+ readonly type: "boolean";
455
794
  };
456
795
  readonly override: {
457
796
  readonly type: "boolean";
458
797
  };
798
+ /** Whether a failure of this rule gates (suppresses) downstream rules on the node's hierarchy subtree. Defaults to true when the failure's severity is `error`. */
799
+ readonly gatesDescendants: {
800
+ readonly type: "boolean";
801
+ };
459
802
  };
460
- readonly required: readonly ["id", "category", "description", "check"];
803
+ readonly required: readonly ["id", "category", "description"];
461
804
  readonly additionalProperties: false;
805
+ readonly allOf: readonly [{
806
+ readonly anyOf: readonly [{
807
+ readonly required: readonly ["expression"];
808
+ }, {
809
+ readonly required: readonly ["semantic"];
810
+ }];
811
+ }, {
812
+ readonly if: {
813
+ readonly required: readonly ["global"];
814
+ readonly properties: {
815
+ readonly global: {
816
+ readonly const: true;
817
+ };
818
+ };
819
+ };
820
+ readonly then: {
821
+ readonly not: {
822
+ readonly anyOf: readonly [{
823
+ readonly required: readonly ["when"];
824
+ }, {
825
+ readonly required: readonly ["type"];
826
+ }, {
827
+ readonly required: readonly ["semantic"];
828
+ }];
829
+ };
830
+ };
831
+ }, {
832
+ readonly if: {
833
+ readonly required: readonly ["semantic"];
834
+ readonly properties: {
835
+ readonly semantic: {
836
+ readonly type: "object";
837
+ readonly required: readonly ["verdicts"];
838
+ };
839
+ };
840
+ };
841
+ readonly then: {
842
+ readonly properties: {
843
+ readonly semantic: {
844
+ readonly type: "object";
845
+ readonly required: readonly ["severity"];
846
+ };
847
+ };
848
+ };
849
+ }, {
850
+ readonly if: {
851
+ readonly required: readonly ["semantic"];
852
+ readonly properties: {
853
+ readonly semantic: {
854
+ readonly type: "object";
855
+ readonly not: {
856
+ readonly required: readonly ["verdicts"];
857
+ };
858
+ };
859
+ };
860
+ };
861
+ readonly then: {
862
+ readonly properties: {
863
+ readonly semantic: {
864
+ readonly type: "object";
865
+ readonly properties: {
866
+ readonly severity: {
867
+ readonly type: "object";
868
+ readonly not: {
869
+ readonly required: readonly ["fail"];
870
+ };
871
+ };
872
+ };
873
+ };
874
+ };
875
+ };
876
+ }, {
877
+ readonly if: {
878
+ readonly required: readonly ["semantic"];
879
+ readonly properties: {
880
+ readonly semantic: {
881
+ readonly type: "object";
882
+ readonly required: readonly ["verdicts"];
883
+ };
884
+ };
885
+ readonly not: {
886
+ readonly required: readonly ["expression"];
887
+ };
888
+ };
889
+ readonly then: {
890
+ readonly not: {
891
+ readonly required: readonly ["severity"];
892
+ };
893
+ };
894
+ }];
462
895
  };
463
896
  };
464
897
  };
@@ -652,6 +1085,9 @@ export declare function buildDialectMetaSchema(id: string): {
652
1085
  readonly category: {
653
1086
  readonly enum: readonly ["validation", "coherence", "workflow", "best-practice"];
654
1087
  };
1088
+ /**
1089
+ * Severity of a failed `expression` and of the default `fail` verdict. Defaults from the category.
1090
+ */
655
1091
  readonly severity: {
656
1092
  readonly enum: readonly ["error", "warning", "info"];
657
1093
  };
@@ -659,23 +1095,199 @@ export declare function buildDialectMetaSchema(id: string): {
659
1095
  readonly type: "string";
660
1096
  readonly minLength: 1;
661
1097
  };
662
- readonly check: {
1098
+ /** JSONata test a node must pass. When the rule also has `semantic`, a failing node is reported without being evaluated by the model. */
1099
+ readonly expression: {
663
1100
  readonly type: "string";
664
1101
  readonly minLength: 1;
665
1102
  };
1103
+ /** Optional JSONata applicability condition, evaluated per node before the rule runs. The rule applies only when it returns true. */
1104
+ readonly when: {
1105
+ readonly type: "string";
1106
+ readonly minLength: 1;
1107
+ };
1108
+ /** A model evaluates the node against a rubric. `{}` takes every default; `true` means the same. */
1109
+ readonly semantic: {
1110
+ readonly oneOf: readonly [{
1111
+ readonly const: true;
1112
+ }, {
1113
+ readonly type: "object";
1114
+ readonly properties: {
1115
+ /** What the model judges the node against. Falls back to the rule's `description`. */
1116
+ readonly rubric: {
1117
+ readonly type: "string";
1118
+ readonly minLength: 1;
1119
+ };
1120
+ /**
1121
+ * The closed set of verdicts the model may return. Each is a description (what the verdict means, for the
1122
+ * model) or `{ description, guidance }`, where `guidance` is shown to the user when it fires.
1123
+ * Defaults to `pass`/`fail`.
1124
+ */
1125
+ readonly verdicts: {
1126
+ readonly type: "object";
1127
+ readonly additionalProperties: {
1128
+ readonly oneOf: readonly [{
1129
+ readonly type: "string";
1130
+ readonly minLength: 1;
1131
+ }, {
1132
+ readonly type: "object";
1133
+ readonly properties: {
1134
+ readonly description: {
1135
+ readonly type: "string";
1136
+ readonly minLength: 1;
1137
+ };
1138
+ readonly guidance: {
1139
+ readonly type: "string";
1140
+ readonly minLength: 1;
1141
+ };
1142
+ };
1143
+ readonly required: readonly ["description"];
1144
+ readonly additionalProperties: false;
1145
+ }];
1146
+ };
1147
+ readonly minProperties: 2;
1148
+ };
1149
+ /**
1150
+ * Severity per verdict in effect (declared, default or reserved). A verdict mapped to `ignore` is judged but
1151
+ * not reported, and a verdict left out passes. Required with `verdicts`; with the default verdicts, `fail`
1152
+ * takes the rule's own `severity` instead.
1153
+ */
1154
+ readonly severity: {
1155
+ readonly type: "object";
1156
+ readonly additionalProperties: {
1157
+ readonly enum: readonly ["error", "warning", "info", "ignore"];
1158
+ };
1159
+ readonly minProperties: 1;
1160
+ };
1161
+ /**
1162
+ * Related nodes, along main-hierarchy edges, sent with the evaluated node. Additive; left out or empty means
1163
+ * the evaluated node alone.
1164
+ */
1165
+ readonly scope: {
1166
+ readonly type: "array";
1167
+ readonly items: {
1168
+ readonly enum: readonly ["parent", "siblings", "children", "ancestors", "descendants", "branch"];
1169
+ };
1170
+ readonly uniqueItems: true;
1171
+ };
1172
+ /**
1173
+ * Which node bodies are sent: `nodeOnly` (the evaluated node's), `fullScope` (it and every related node's),
1174
+ * or `true` for `fullScope`. Left out: no bodies.
1175
+ */
1176
+ readonly includeContent: {
1177
+ readonly enum: readonly ["nodeOnly", "fullScope", true];
1178
+ };
1179
+ };
1180
+ readonly additionalProperties: false;
1181
+ }];
1182
+ };
666
1183
  readonly type: {
667
1184
  readonly type: "string";
668
1185
  readonly minLength: 1;
669
1186
  };
670
- readonly scope: {
671
- readonly enum: readonly ["global"];
1187
+ /** Run once for the whole space instead of once per node. */
1188
+ readonly global: {
1189
+ readonly type: "boolean";
672
1190
  };
673
1191
  readonly override: {
674
1192
  readonly type: "boolean";
675
1193
  };
1194
+ /** Whether a failure of this rule gates (suppresses) downstream rules on the node's hierarchy subtree. Defaults to true when the failure's severity is `error`. */
1195
+ readonly gatesDescendants: {
1196
+ readonly type: "boolean";
1197
+ };
676
1198
  };
677
- readonly required: readonly ["id", "category", "description", "check"];
1199
+ readonly required: readonly ["id", "category", "description"];
678
1200
  readonly additionalProperties: false;
1201
+ readonly allOf: readonly [{
1202
+ readonly anyOf: readonly [{
1203
+ readonly required: readonly ["expression"];
1204
+ }, {
1205
+ readonly required: readonly ["semantic"];
1206
+ }];
1207
+ }, {
1208
+ readonly if: {
1209
+ readonly required: readonly ["global"];
1210
+ readonly properties: {
1211
+ readonly global: {
1212
+ readonly const: true;
1213
+ };
1214
+ };
1215
+ };
1216
+ readonly then: {
1217
+ readonly not: {
1218
+ readonly anyOf: readonly [{
1219
+ readonly required: readonly ["when"];
1220
+ }, {
1221
+ readonly required: readonly ["type"];
1222
+ }, {
1223
+ readonly required: readonly ["semantic"];
1224
+ }];
1225
+ };
1226
+ };
1227
+ }, {
1228
+ readonly if: {
1229
+ readonly required: readonly ["semantic"];
1230
+ readonly properties: {
1231
+ readonly semantic: {
1232
+ readonly type: "object";
1233
+ readonly required: readonly ["verdicts"];
1234
+ };
1235
+ };
1236
+ };
1237
+ readonly then: {
1238
+ readonly properties: {
1239
+ readonly semantic: {
1240
+ readonly type: "object";
1241
+ readonly required: readonly ["severity"];
1242
+ };
1243
+ };
1244
+ };
1245
+ }, {
1246
+ readonly if: {
1247
+ readonly required: readonly ["semantic"];
1248
+ readonly properties: {
1249
+ readonly semantic: {
1250
+ readonly type: "object";
1251
+ readonly not: {
1252
+ readonly required: readonly ["verdicts"];
1253
+ };
1254
+ };
1255
+ };
1256
+ };
1257
+ readonly then: {
1258
+ readonly properties: {
1259
+ readonly semantic: {
1260
+ readonly type: "object";
1261
+ readonly properties: {
1262
+ readonly severity: {
1263
+ readonly type: "object";
1264
+ readonly not: {
1265
+ readonly required: readonly ["fail"];
1266
+ };
1267
+ };
1268
+ };
1269
+ };
1270
+ };
1271
+ };
1272
+ }, {
1273
+ readonly if: {
1274
+ readonly required: readonly ["semantic"];
1275
+ readonly properties: {
1276
+ readonly semantic: {
1277
+ readonly type: "object";
1278
+ readonly required: readonly ["verdicts"];
1279
+ };
1280
+ };
1281
+ readonly not: {
1282
+ readonly required: readonly ["expression"];
1283
+ };
1284
+ };
1285
+ readonly then: {
1286
+ readonly not: {
1287
+ readonly required: readonly ["severity"];
1288
+ };
1289
+ };
1290
+ }];
679
1291
  };
680
1292
  };
681
1293
  };
@@ -690,5 +1302,6 @@ export type MetadataContractRelationship = FromSchema<typeof RELATIONSHIP_SCHEMA
690
1302
  export type SharedEdgeFields = FromSchema<typeof EDGE_SCHEMA>;
691
1303
  export type SharedEmbeddingFields = FromSchema<typeof EMBEDDING_SCHEMA>;
692
1304
  export type Rule = FromSchema<typeof RULE_SCHEMA>;
1305
+ export type RuleSemantic = FromSchema<typeof SEMANTIC_SCHEMA>;
693
1306
  export type MetadataRef = FromSchema<typeof REF_SCHEMA>;
694
1307
  export {};