kibi-core 0.7.1 → 0.9.1
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.
- package/package.json +1 -1
- package/schema/entities.pl +28 -0
- package/schema/relationships.pl +2 -0
- package/schema/validation.pl +41 -32
- package/src/checks.pl +410 -19
- package/src/discovery.pl +88 -18
- package/src/kb.pl +256 -19
- package/src/logic_ir.pl +629 -0
- package/src/requirement_proof.pl +837 -0
package/package.json
CHANGED
package/schema/entities.pl
CHANGED
|
@@ -29,7 +29,13 @@ entity_property(_, severity, atom).
|
|
|
29
29
|
entity_property(_, links, list).
|
|
30
30
|
entity_property(_, text_ref, uri).
|
|
31
31
|
entity_property(_, sourceFile, uri).
|
|
32
|
+
entity_property(req, semantic_text, string).
|
|
32
33
|
entity_property(req, logic_claims, list).
|
|
34
|
+
entity_property(req, semantic_clauses, list).
|
|
35
|
+
entity_property(req, semantic_inventory_version, string).
|
|
36
|
+
entity_property(req, semantic_source_field, string).
|
|
37
|
+
entity_property(req, semantic_source_hash, string).
|
|
38
|
+
entity_property(req, semantic_inventory, list_or_json).
|
|
33
39
|
|
|
34
40
|
% Typed fact fields - only valid for fact entities
|
|
35
41
|
entity_property(fact, fact_kind, atom).
|
|
@@ -59,14 +65,29 @@ entity_property(fact, argument_descriptions, list).
|
|
|
59
65
|
entity_property(fact, aliases, list).
|
|
60
66
|
entity_property(fact, examples, list).
|
|
61
67
|
entity_property(fact, predicate_args, list).
|
|
68
|
+
entity_property(fact, rule_ir, string).
|
|
69
|
+
entity_property(fact, rule_hash, string).
|
|
70
|
+
% Rule schema references are JSON strings at the public boundary, but the
|
|
71
|
+
% Prolog peer represents entity identifiers as atoms. Accept both forms so
|
|
72
|
+
% decoded rule facts validate without losing the typed reference.
|
|
73
|
+
entity_property(fact, rule_schema_id, atom_or_string).
|
|
74
|
+
entity_property(fact, rule_name, string).
|
|
75
|
+
entity_property(fact, semantic_key, string).
|
|
76
|
+
entity_property(fact, claim_span_start, integer).
|
|
77
|
+
entity_property(fact, claim_span_end, integer).
|
|
62
78
|
|
|
63
79
|
% Typed symbol metadata fields - only valid for symbol entities
|
|
64
80
|
entity_property(symbol, symbol_role, atom).
|
|
65
81
|
entity_property(symbol, granularity_reason, atom).
|
|
82
|
+
entity_property(symbol, sourceLine, integer).
|
|
83
|
+
entity_property(symbol, sourceColumn, integer).
|
|
84
|
+
entity_property(symbol, sourceEndLine, integer).
|
|
85
|
+
entity_property(symbol, sourceEndColumn, integer).
|
|
66
86
|
|
|
67
87
|
% Typed test verification fields - only valid for test entities
|
|
68
88
|
entity_property(test, verification_scope, atom).
|
|
69
89
|
entity_property(test, verification_perspective, atom).
|
|
90
|
+
entity_property(test, verification_receipts, string).
|
|
70
91
|
|
|
71
92
|
% Required properties for all entity types
|
|
72
93
|
required_property(Type, id) :- entity_type(Type).
|
|
@@ -83,9 +104,16 @@ optional_property(Type, priority) :- entity_type(Type).
|
|
|
83
104
|
optional_property(Type, severity) :- entity_type(Type).
|
|
84
105
|
optional_property(Type, links) :- entity_type(Type).
|
|
85
106
|
optional_property(Type, text_ref) :- entity_type(Type).
|
|
107
|
+
optional_property(req, semantic_text).
|
|
86
108
|
optional_property(req, logic_claims).
|
|
109
|
+
optional_property(req, semantic_clauses).
|
|
110
|
+
optional_property(req, semantic_inventory_version).
|
|
111
|
+
optional_property(req, semantic_source_field).
|
|
112
|
+
optional_property(req, semantic_source_hash).
|
|
113
|
+
optional_property(req, semantic_inventory).
|
|
87
114
|
optional_property(test, verification_scope).
|
|
88
115
|
optional_property(test, verification_perspective).
|
|
116
|
+
optional_property(test, verification_receipts).
|
|
89
117
|
|
|
90
118
|
% Documentation helpers
|
|
91
119
|
% list all entity types
|
package/schema/relationships.pl
CHANGED
|
@@ -19,6 +19,7 @@ relationship_type(supersedes).
|
|
|
19
19
|
relationship_type(constrains).
|
|
20
20
|
relationship_type(requires_property).
|
|
21
21
|
relationship_type(requires_predicate).
|
|
22
|
+
relationship_type(requires_rule).
|
|
22
23
|
|
|
23
24
|
% valid_relationship(RelType, FromType, ToType).
|
|
24
25
|
valid_relationship(depends_on, req, req).
|
|
@@ -40,6 +41,7 @@ valid_relationship(consumes, symbol, event).
|
|
|
40
41
|
valid_relationship(constrains, req, fact).
|
|
41
42
|
valid_relationship(requires_property, req, fact).
|
|
42
43
|
valid_relationship(requires_predicate, req, fact).
|
|
44
|
+
valid_relationship(requires_rule, req, fact).
|
|
43
45
|
|
|
44
46
|
%% supersedes(+NewAdrId, +OldAdrId)
|
|
45
47
|
%% NewAdrId is the decision that replaces OldAdrId.
|
package/schema/validation.pl
CHANGED
|
@@ -42,8 +42,10 @@ validate_property_type(Type, Prop, Value) :-
|
|
|
42
42
|
% check_kind(Kind, Value) succeeds if Value matches Kind
|
|
43
43
|
check_kind(atom, V) :- atom(V).
|
|
44
44
|
check_kind(string, V) :- string(V).
|
|
45
|
+
check_kind(atom_or_string, V) :- atom(V) ; string(V).
|
|
45
46
|
check_kind(datetime, V) :- string(V). % accept ISO strings for now
|
|
46
47
|
check_kind(list, V) :- is_list(V).
|
|
48
|
+
check_kind(list_or_json, V) :- is_list(V) ; string(V) ; atom(V).
|
|
47
49
|
check_kind(uri, V) :- string(V).
|
|
48
50
|
check_kind(integer, V) :- integer(V).
|
|
49
51
|
check_kind(number, V) :- number(V).
|
|
@@ -106,16 +108,24 @@ is_fact_only_field(argument_descriptions).
|
|
|
106
108
|
is_fact_only_field(aliases).
|
|
107
109
|
is_fact_only_field(examples).
|
|
108
110
|
is_fact_only_field(predicate_args).
|
|
111
|
+
is_fact_only_field(rule_ir).
|
|
112
|
+
is_fact_only_field(rule_hash).
|
|
113
|
+
is_fact_only_field(rule_schema_id).
|
|
114
|
+
is_fact_only_field(rule_name).
|
|
115
|
+
is_fact_only_field(semantic_key).
|
|
116
|
+
is_fact_only_field(claim_span_start).
|
|
117
|
+
is_fact_only_field(claim_span_end).
|
|
109
118
|
|
|
110
119
|
% is_test_only_field(+Key) - true if Key is a test-specific field
|
|
111
120
|
is_test_only_field(verification_scope).
|
|
112
121
|
is_test_only_field(verification_perspective).
|
|
122
|
+
is_test_only_field(verification_receipts).
|
|
113
123
|
|
|
114
124
|
% validate_fact_shape(+Kind, +Props)
|
|
115
125
|
validate_fact_shape(subject, Props) :-
|
|
116
126
|
memberchk(subject_key=_Val, Props),
|
|
117
127
|
valid_optional_fact_enums(Props),
|
|
118
|
-
valid_strict_polarity_in_props(Props)
|
|
128
|
+
valid_strict_polarity_in_props(Props), !.
|
|
119
129
|
validate_fact_shape(property_value, Props) :-
|
|
120
130
|
memberchk(subject_key=_Subject, Props),
|
|
121
131
|
memberchk(property_key=_Property, Props),
|
|
@@ -126,14 +136,14 @@ validate_fact_shape(property_value, Props) :-
|
|
|
126
136
|
exactly_one_value_field(Props),
|
|
127
137
|
value_type_matches_field(VT, Props),
|
|
128
138
|
valid_optional_fact_enums(Props),
|
|
129
|
-
valid_strict_polarity_in_props(Props)
|
|
139
|
+
valid_strict_polarity_in_props(Props), !.
|
|
130
140
|
validate_fact_shape(observation, Props) :-
|
|
131
141
|
valid_optional_fact_enums(Props),
|
|
132
|
-
valid_polarity_in_props(Props)
|
|
142
|
+
valid_polarity_in_props(Props), !.
|
|
133
143
|
validate_fact_shape(meta, Props) :-
|
|
134
144
|
% Meta facts are allowed but don't require full strict property tuple yet
|
|
135
145
|
valid_optional_fact_enums(Props),
|
|
136
|
-
valid_polarity_in_props(Props)
|
|
146
|
+
valid_polarity_in_props(Props), !.
|
|
137
147
|
validate_fact_shape(predicate_schema, Props) :-
|
|
138
148
|
memberchk(predicate_name=_Name, Props),
|
|
139
149
|
memberchk(predicate_arity=Arity, Props),
|
|
@@ -143,32 +153,39 @@ validate_fact_shape(predicate_schema, Props) :-
|
|
|
143
153
|
same_length(ArgumentNames, ArgumentTypes),
|
|
144
154
|
length(ArgumentNames, Arity),
|
|
145
155
|
valid_optional_fact_enums(Props),
|
|
146
|
-
valid_polarity_in_props(Props)
|
|
156
|
+
valid_polarity_in_props(Props), !.
|
|
147
157
|
validate_fact_shape(predicate, Props) :-
|
|
148
158
|
memberchk(predicate_name=_Name, Props),
|
|
149
159
|
memberchk(predicate_args=Args, Props),
|
|
150
160
|
Args \= [],
|
|
151
161
|
memberchk(canonical_key=_CanonicalKey, Props),
|
|
152
162
|
valid_optional_fact_enums(Props),
|
|
153
|
-
valid_predicate_polarity_in_props(Props)
|
|
163
|
+
valid_predicate_polarity_in_props(Props), !.
|
|
164
|
+
validate_fact_shape(rule_schema, Props) :-
|
|
165
|
+
memberchk(rule_name=_Name, Props),
|
|
166
|
+
memberchk(argument_names=ArgumentNames, Props),
|
|
167
|
+
memberchk(argument_types=ArgumentTypes, Props),
|
|
168
|
+
same_length(ArgumentNames, ArgumentTypes),
|
|
169
|
+
valid_optional_fact_enums(Props),
|
|
170
|
+
valid_polarity_in_props(Props), !.
|
|
171
|
+
validate_fact_shape(rule, Props) :-
|
|
172
|
+
memberchk(rule_ir=RuleIr, Props),
|
|
173
|
+
nonempty_claim_value(RuleIr),
|
|
174
|
+
memberchk(rule_hash=_Hash, Props),
|
|
175
|
+
memberchk(rule_schema_id=_SchemaId, Props),
|
|
176
|
+
memberchk(semantic_key=_SemanticKey, Props),
|
|
177
|
+
valid_optional_fact_enums(Props),
|
|
178
|
+
valid_polarity_in_props(Props), !.
|
|
154
179
|
validate_fact_shape(Kind, _Props) :-
|
|
155
180
|
% Unknown fact_kind values fail validation
|
|
156
|
-
\+ memberchk(Kind, [subject, property_value, observation, meta, predicate_schema, predicate]),
|
|
181
|
+
\+ memberchk(Kind, [subject, property_value, observation, meta, predicate_schema, predicate, rule_schema, rule]),
|
|
157
182
|
fail.
|
|
158
183
|
|
|
159
184
|
% valid_operator(+Op)
|
|
160
|
-
valid_operator(eq)
|
|
161
|
-
valid_operator(neq).
|
|
162
|
-
valid_operator(lt).
|
|
163
|
-
valid_operator(lte).
|
|
164
|
-
valid_operator(gt).
|
|
165
|
-
valid_operator(gte).
|
|
185
|
+
valid_operator(Op) :- memberchk(Op, [eq, neq, lt, lte, gt, gte]), !.
|
|
166
186
|
|
|
167
187
|
% valid_value_type(+VT)
|
|
168
|
-
valid_value_type(string)
|
|
169
|
-
valid_value_type(int).
|
|
170
|
-
valid_value_type(number).
|
|
171
|
-
valid_value_type(bool).
|
|
188
|
+
valid_value_type(ValueType) :- memberchk(ValueType, [string, int, number, bool]), !.
|
|
172
189
|
|
|
173
190
|
% valid_polarity_in_props(+Props)
|
|
174
191
|
% Validates polarity if present; succeeds if no polarity in props
|
|
@@ -190,8 +207,8 @@ valid_claim_provenance(Props) :-
|
|
|
190
207
|
; \+ memberchk(claim_text=_, Props)
|
|
191
208
|
).
|
|
192
209
|
|
|
193
|
-
nonempty_claim_value(Value) :- string(Value), Value \= ""
|
|
194
|
-
nonempty_claim_value(Value) :- atom(Value), Value \= ''
|
|
210
|
+
nonempty_claim_value(Value) :- string(Value), Value \= "", !.
|
|
211
|
+
nonempty_claim_value(Value) :- atom(Value), Value \= '', !.
|
|
195
212
|
|
|
196
213
|
% valid_optional_fact_enums(+Props)
|
|
197
214
|
% Validates enum-typed fact fields whenever they are present
|
|
@@ -206,25 +223,17 @@ valid_optional_test_enums(Props) :-
|
|
|
206
223
|
( memberchk(verification_perspective=Perspective, Props) -> valid_verification_perspective(Perspective) ; true ).
|
|
207
224
|
|
|
208
225
|
% valid_polarity(+P)
|
|
209
|
-
valid_polarity(require)
|
|
210
|
-
valid_polarity(forbid).
|
|
211
|
-
valid_polarity(assert).
|
|
212
|
-
valid_polarity(deny).
|
|
226
|
+
valid_polarity(Polarity) :- memberchk(Polarity, [require, forbid, assert, deny]), !.
|
|
213
227
|
|
|
214
|
-
valid_strict_polarity(require)
|
|
215
|
-
valid_strict_polarity(forbid).
|
|
228
|
+
valid_strict_polarity(Polarity) :- memberchk(Polarity, [require, forbid]), !.
|
|
216
229
|
|
|
217
|
-
valid_predicate_polarity(assert)
|
|
218
|
-
valid_predicate_polarity(deny).
|
|
230
|
+
valid_predicate_polarity(Polarity) :- memberchk(Polarity, [assert, deny]), !.
|
|
219
231
|
|
|
220
232
|
% valid_verification_scope(+Scope)
|
|
221
|
-
valid_verification_scope(unit)
|
|
222
|
-
valid_verification_scope(integration).
|
|
223
|
-
valid_verification_scope(end_to_end).
|
|
233
|
+
valid_verification_scope(Scope) :- memberchk(Scope, [unit, integration, end_to_end]), !.
|
|
224
234
|
|
|
225
235
|
% valid_verification_perspective(+Perspective)
|
|
226
|
-
valid_verification_perspective(internal)
|
|
227
|
-
valid_verification_perspective(consumer).
|
|
236
|
+
valid_verification_perspective(Perspective) :- memberchk(Perspective, [internal, consumer]), !.
|
|
228
237
|
|
|
229
238
|
% exactly_one_value_field(+Props)
|
|
230
239
|
exactly_one_value_field(Props) :-
|