kibi-core 0.15.2 → 0.17.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-core",
3
- "version": "0.15.2",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "description": "Core Prolog modules and RDF graph logic for Kibi",
6
6
  "type": "module",
package/src/checks.pl CHANGED
@@ -41,6 +41,7 @@
41
41
  check_rule_safety/1,
42
42
  check_rule_verifiability/1,
43
43
  check_semantic_completeness/1,
44
+ check_related_requirement_unmodeled/1,
44
45
  check_req_status_vocabulary/1,
45
46
  check_entity_id_style/1,
46
47
  check_domain_redundancy/1,
@@ -114,6 +115,7 @@ check_all(ViolationsDict) :-
114
115
  check_rule_safety(RuleSafety),
115
116
  check_rule_verifiability(RuleVerifiability),
116
117
  check_semantic_completeness(SemanticCompleteness),
118
+ check_related_requirement_unmodeled(RelatedRequirementUnmodeled),
117
119
  check_req_status_vocabulary(ReqStatusVocabulary),
118
120
  check_proof_contract_symbols(ProofContractSymbols),
119
121
  check_entity_id_style(EntityIdStyle),
@@ -148,6 +150,7 @@ check_all(ViolationsDict) :-
148
150
  rule_safety: RuleSafety,
149
151
  rule_verifiability: RuleVerifiability,
150
152
  semantic_completeness: SemanticCompleteness,
153
+ related_requirement_unmodeled: RelatedRequirementUnmodeled,
151
154
  req_status_vocabulary: ReqStatusVocabulary,
152
155
  proof_contract_symbols: ProofContractSymbols,
153
156
  entity_id_style: EntityIdStyle,
@@ -3332,6 +3335,89 @@ inventory_entry_status(Entry, Status) :-
3332
3335
  inventory_entry_status(Entry, Status) :-
3333
3336
  is_list(Entry), memberchk(status=Raw, Entry), normalize_term_atom(Raw, Status).
3334
3337
 
3338
+ %% check_related_requirement_unmodeled(-Violations)
3339
+ % implements REQ-check-related-requirement-unmodeled
3340
+ % domain-contradictions compares grounded facts only. A current requirement
3341
+ % whose proposition ledger still carries `missing` entries contributes no
3342
+ % facts, so when it relates_to a current requirement that is modeled (strict
3343
+ % subject/property facts or ground predicate facts) its claims are never
3344
+ % compared with that requirement: it can describe behavior the modeled one
3345
+ % forbids and `kb_check` stays clean. The relates_to edge says the author knew
3346
+ % the two overlap, so the gap is blocking: model the missing propositions
3347
+ % against the same subject keys or predicates, or supersede the older
3348
+ % requirement. Requirements without a ledger stay in the strict-readiness
3349
+ % migration lane and are not reported here.
3350
+ check_related_requirement_unmodeled(Violations) :-
3351
+ findall(Violation, related_requirement_unmodeled_violation(Violation), Raw),
3352
+ sort(Raw, Violations).
3353
+
3354
+ related_requirement_unmodeled_violation(violation(
3355
+ 'related-requirement-unmodeled',
3356
+ ReqId,
3357
+ Description,
3358
+ Suggestion,
3359
+ Source
3360
+ )) :-
3361
+ kb:current_req(ReqId),
3362
+ requirement_missing_proposition_count(ReqId, MissingCount),
3363
+ MissingCount > 0,
3364
+ related_current_requirement(ReqId, OtherId),
3365
+ modeled_requirement_summary(OtherId, Summary),
3366
+ format(
3367
+ string(Description),
3368
+ "Requirement ~w leaves ~w proposition(s) unmodeled (status missing) while it relates_to ~w, which models ~w; domain-contradictions compares grounded facts only, so these claims are never checked against ~w",
3369
+ [ReqId, MissingCount, OtherId, Summary, OtherId]
3370
+ ),
3371
+ format(
3372
+ string(Suggestion),
3373
+ "Model the missing propositions of ~w against ~w (a subject fact via constrains and property_value facts via requires_property on the same subject_key, or ground predicate facts via requires_predicate), or record that ~w supersedes ~w if it replaces that requirement",
3374
+ [ReqId, Summary, ReqId, OtherId]
3375
+ ),
3376
+ violation_source(ReqId, req, Source).
3377
+
3378
+ requirement_missing_proposition_count(ReqId, Count) :-
3379
+ kb_entity(ReqId, req, Props),
3380
+ memberchk(semantic_inventory=RawInventory, Props),
3381
+ inventory_entries(RawInventory, Entries),
3382
+ aggregate_all(
3383
+ count,
3384
+ ( member(Entry, Entries), inventory_entry_status(Entry, missing) ),
3385
+ Count
3386
+ ).
3387
+
3388
+ related_current_requirement(ReqId, OtherId) :-
3389
+ ( kb_relationship(relates_to, ReqId, OtherId)
3390
+ ; kb_relationship(relates_to, OtherId, ReqId)
3391
+ ),
3392
+ OtherId \== ReqId,
3393
+ kb:current_req(OtherId).
3394
+
3395
+ %% modeled_requirement_summary(+ReqId, -Summary)
3396
+ % Comma-separated list of the subject.property keys the requirement constrains
3397
+ % through contradiction-ready strict facts and the canonical keys of the ground
3398
+ % predicate facts it requires. Fails when the requirement models nothing.
3399
+ modeled_requirement_summary(ReqId, Summary) :-
3400
+ setof(Key, modeled_requirement_key(ReqId, Key), Keys),
3401
+ atomic_list_concat(Keys, ', ', Summary).
3402
+
3403
+ modeled_requirement_key(ReqId, Key) :-
3404
+ kb:effective_req_property_fact(
3405
+ ReqId, SubjectKey, _FactId, PropertyKey,
3406
+ _Operator, _ValueType, _Value, _Unit, _Scope, _Polarity, _ValidFrom, _ValidTo
3407
+ ),
3408
+ normalize_term_atom(SubjectKey, SubjectAtom),
3409
+ normalize_term_atom(PropertyKey, PropertyAtom),
3410
+ format(atom(Key), "~w.~w", [SubjectAtom, PropertyAtom]).
3411
+ modeled_requirement_key(ReqId, Key) :-
3412
+ kb_relationship(requires_predicate, ReqId, FactId),
3413
+ kb_entity(FactId, fact, Props),
3414
+ predicate_verifiability_fact_kind(Props, predicate),
3415
+ ( memberchk(canonical_key=RawKey, Props)
3416
+ -> normalize_term_atom(RawKey, Key)
3417
+ ; memberchk(predicate_name=RawName, Props),
3418
+ normalize_term_atom(RawName, Key)
3419
+ ).
3420
+
3335
3421
  strict_readiness_has_fact_link(ReqId) :-
3336
3422
  kb_relationship(constrains, ReqId, FactId),
3337
3423
  kb_entity(FactId, fact, _),
@@ -3427,6 +3513,7 @@ check_selected_dispatch(Rules, _{
3427
3513
  rule_safety: RuleSafety,
3428
3514
  rule_verifiability: RuleVerifiability,
3429
3515
  semantic_completeness: SemanticCompleteness,
3516
+ related_requirement_unmodeled: RelatedRequirementUnmodeled,
3430
3517
  req_status_vocabulary: ReqStatusVocabulary,
3431
3518
  proof_contract_symbols: ProofContractSymbols,
3432
3519
  entity_id_style: EntityIdStyle,
@@ -3461,6 +3548,7 @@ check_selected_dispatch(Rules, _{
3461
3548
  selected_rule(Rules, 'rule-safety', check_rule_safety, RuleSafety),
3462
3549
  selected_rule(Rules, 'rule-verifiability', check_rule_verifiability, RuleVerifiability),
3463
3550
  selected_rule(Rules, 'semantic-completeness', check_semantic_completeness, SemanticCompleteness),
3551
+ selected_rule(Rules, 'related-requirement-unmodeled', check_related_requirement_unmodeled, RelatedRequirementUnmodeled),
3464
3552
  selected_rule(Rules, 'req-status-vocabulary', check_req_status_vocabulary, ReqStatusVocabulary),
3465
3553
  selected_rule(Rules, 'proof-contract-symbols', check_proof_contract_symbols, ProofContractSymbols),
3466
3554
  selected_rule(Rules, 'entity-id-style', check_entity_id_style, EntityIdStyle),
@@ -40,6 +40,7 @@ known_rule('strict-req-fact-pairing').
40
40
  known_rule('predicate-verifiability').
41
41
  known_rule('strict-readiness').
42
42
  known_rule('semantic-completeness').
43
+ known_rule('related-requirement-unmodeled').
43
44
  known_rule('proof-contract-symbols').
44
45
  known_rule('entity-id-style').
45
46
  known_rule('domain-redundancy').
@@ -84,6 +85,7 @@ rule_enforcement_class('strict-req-fact-pairing', advisory).
84
85
  rule_enforcement_class('predicate-verifiability', advisory).
85
86
  rule_enforcement_class('strict-readiness', migration).
86
87
  rule_enforcement_class('semantic-completeness', migration).
88
+ rule_enforcement_class('related-requirement-unmodeled', canonical).
87
89
  rule_enforcement_class('proof-contract-symbols', advisory).
88
90
  rule_enforcement_class('entity-id-style', advisory).
89
91
  rule_enforcement_class('domain-redundancy', advisory).
@@ -128,6 +130,7 @@ rule_implementation('strict-req-fact-pairing', prolog).
128
130
  rule_implementation('predicate-verifiability', prolog).
129
131
  rule_implementation('strict-readiness', prolog).
130
132
  rule_implementation('semantic-completeness', prolog).
133
+ rule_implementation('related-requirement-unmodeled', prolog).
131
134
  rule_implementation('proof-contract-symbols', prolog).
132
135
  rule_implementation('entity-id-style', prolog).
133
136
  rule_implementation('domain-redundancy', prolog).
@@ -169,6 +172,7 @@ rule_predicate('strict-req-fact-pairing', check_strict_req_fact_pairing).
169
172
  rule_predicate('predicate-verifiability', check_predicate_verifiability).
170
173
  rule_predicate('strict-readiness', check_strict_readiness).
171
174
  rule_predicate('semantic-completeness', check_semantic_completeness).
175
+ rule_predicate('related-requirement-unmodeled', check_related_requirement_unmodeled).
172
176
  rule_predicate('proof-contract-symbols', check_proof_contract_symbols).
173
177
  rule_predicate('entity-id-style', check_entity_id_style).
174
178
  rule_predicate('domain-redundancy', check_domain_redundancy).
@@ -203,6 +207,7 @@ rule_predicate_arity('strict-req-fact-pairing', 1).
203
207
  rule_predicate_arity('predicate-verifiability', 1).
204
208
  rule_predicate_arity('strict-readiness', 1).
205
209
  rule_predicate_arity('semantic-completeness', 1).
210
+ rule_predicate_arity('related-requirement-unmodeled', 1).
206
211
  rule_predicate_arity('proof-contract-symbols', 1).
207
212
  rule_predicate_arity('entity-id-style', 1).
208
213
  rule_predicate_arity('domain-redundancy', 1).
@@ -240,6 +245,7 @@ rule_description('strict-req-fact-pairing', 'Detect requirements with incomplete
240
245
  rule_description('predicate-verifiability', 'Detect requires_predicate links that do not target ground fact_kind: predicate facts').
241
246
  rule_description('strict-readiness', 'Report strict contradiction-readiness levels for requirements that are still prose-only or otherwise not contradiction-ready').
242
247
  rule_description('semantic-completeness', 'Every inventoried assertive proposition is modeled or explicitly classified').
248
+ rule_description('related-requirement-unmodeled', 'A current requirement with unresolved (missing) propositions that relates_to a current requirement modeled with strict property or ground predicate facts; its claims are never compared by domain-contradictions until they are modeled against the same subject or predicates, or it supersedes that requirement').
243
249
  rule_description('proof-contract-symbols', 'Detect unresolved required_proofs.symbol_id values, type-shape required proofs, and proof_bindings.source_file disagreement with the named symbol sourceFile').
244
250
  rule_description('entity-id-style', 'Entity IDs name the governed behavior and match their filename stem; new purely numeric IDs are reported at creation boundaries').
245
251
  rule_description('domain-redundancy', 'Two current requirements must not ground the identical logical term or share a ground fact unless linked by supersedes or restates').