kibi-core 0.21.1 → 0.22.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.21.1",
3
+ "version": "0.22.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
@@ -9,6 +9,7 @@
9
9
  check_selected_json/2, % Returns only selected rule violations as JSON
10
10
  check_must_priority_coverage/1, % Returns list of must-priority violations
11
11
  check_symbol_coverage/1, % Returns list of uncovered symbols
12
+ check_changed_symbol_coverage/2, % symbol-coverage restricted to a staged change set
12
13
  check_symbol_traceability/2, % Returns list of symbols lacking requirement traceability (ReqAdr option)
13
14
  check_proof_contract_symbols/1, % Returns unresolved or unexpected required_proofs symbol issues
14
15
  check_no_dangling_refs/1, % Returns list of dangling ref violations
@@ -198,6 +199,18 @@ check_symbol_coverage(Violations) :-
198
199
  sort(SymbolIds0, SymbolIds),
199
200
  maplist(symbol_coverage_violation, SymbolIds, Violations).
200
201
 
202
+ %% check_changed_symbol_coverage(+ExtraSymbols, -Violations)
203
+ % The symbol-coverage rule for the staged gate: the same violations
204
+ % check_symbol_coverage/1 reports, restricted to the changed symbols
205
+ % (kb:changed_symbol/1 overlay facts plus ExtraSymbols).
206
+ % implements REQ-014
207
+ check_changed_symbol_coverage(ExtraSymbols, Violations) :-
208
+ findall(SymbolId,
209
+ changed_symbol_no_req_coverage(ExtraSymbols, SymbolId),
210
+ SymbolIds0),
211
+ sort(SymbolIds0, SymbolIds),
212
+ maplist(symbol_coverage_violation, SymbolIds, Violations).
213
+
201
214
  symbol_coverage_violation(SymbolId, violation(
202
215
  'symbol-coverage',
203
216
  SymbolId,
package/src/kb.pl CHANGED
@@ -61,6 +61,7 @@
61
61
  adr_chain/2,
62
62
  deprecated_no_successor/1,
63
63
  symbol_no_req_coverage/2,
64
+ changed_symbol_no_req_coverage/2,
64
65
  predicate_schema/6,
65
66
  predicate_schema_keys/4,
66
67
  predicate_fact/5,
@@ -3327,6 +3328,23 @@ changed_symbol_missing_req(Symbol, MinLinks, Count) :-
3327
3328
  length(UniqueReqs, Count),
3328
3329
  Count < MinLinks.
3329
3330
 
3331
+ %% changed_symbol_no_req_coverage(+ExtraSymbols, -Symbol)
3332
+ % The full-check symbol-coverage rule restricted to a staged change set: the
3333
+ % overlay changed_symbol/1 facts plus ExtraSymbols (symbols whose staged
3334
+ % manifest entry changed). It reuses symbol_no_req_coverage/2, so the staged
3335
+ % gate and `kibi check` judge coverage identically: a direct req->test edge
3336
+ % counts only while the requirement has no scenario.
3337
+ % implements REQ-014
3338
+ changed_symbol_no_req_coverage(ExtraSymbols, Symbol) :-
3339
+ findall(Candidate,
3340
+ ( changed_symbol(Candidate)
3341
+ ; member(Candidate, ExtraSymbols)
3342
+ ),
3343
+ Candidates0),
3344
+ sort(Candidates0, Candidates),
3345
+ member(Symbol, Candidates),
3346
+ symbol_no_req_coverage(Symbol, _).
3347
+
3330
3348
  %% changed_symbol_violation(+Symbol, +MinLinks, -Count, -File, -Line, -Col, -Name)
3331
3349
  % Full violation record for a changed symbol missing requirements.
3332
3350
  changed_symbol_violation(Symbol, MinLinks, Count, File, Line, Col, Name) :-
@@ -17,6 +17,7 @@
17
17
  known_rule('must-priority-coverage').
18
18
  known_rule('symbol-coverage').
19
19
  known_rule('symbol-traceability').
20
+ known_rule('symbol-granularity').
20
21
  known_rule('no-dangling-refs').
21
22
  known_rule('source-relationship-parity').
22
23
  known_rule('branch-store-not-compiled').
@@ -69,6 +70,7 @@ known_rule('policy-markers').
69
70
  rule_enforcement_class('must-priority-coverage', canonical).
70
71
  rule_enforcement_class('symbol-coverage', canonical).
71
72
  rule_enforcement_class('symbol-traceability', canonical).
73
+ rule_enforcement_class('symbol-granularity', canonical).
72
74
  rule_enforcement_class('no-dangling-refs', canonical).
73
75
  rule_enforcement_class('source-relationship-parity', canonical).
74
76
  rule_enforcement_class('branch-store-not-compiled', canonical).
@@ -121,6 +123,7 @@ rule_enforcement_class('policy-markers', canonical).
121
123
  rule_implementation('must-priority-coverage', prolog).
122
124
  rule_implementation('symbol-coverage', prolog).
123
125
  rule_implementation('symbol-traceability', prolog).
126
+ rule_implementation('symbol-granularity', typescript).
124
127
  rule_implementation('no-dangling-refs', prolog).
125
128
  rule_implementation('source-relationship-parity', typescript).
126
129
  rule_implementation('branch-store-not-compiled', typescript).
@@ -243,6 +246,7 @@ rule_predicate_arity('adr-proposed', 1).
243
246
  rule_description('must-priority-coverage', 'Every must-priority requirement must have a scenario and a test').
244
247
  rule_description('symbol-coverage', 'Production symbols need qualifying coverage via covered_by plus a canonical requirement/scenario test path').
245
248
  rule_description('symbol-traceability', 'Production symbols must directly implement requirements for ownership; covered_by is coverage only and executable_for is test identity only').
249
+ rule_description('symbol-granularity', 'A symbol with traceability relationships must not link its source file coarsely while narrower behavioral symbols are available, unless it carries an allowed granularity_reason; the staged gate\'s symbol_granularity_violation evaluated KB-wide').
246
250
  rule_description('no-dangling-refs', 'All relationship targets must exist in the KB').
247
251
  rule_description('source-relationship-parity', 'Authored Markdown and relationship-shard edges must exactly match the compiled KB').
248
252
  rule_description('branch-store-not-compiled', 'The current branch\'s KB store must be compiled from the authored .kb/ sources; a missing or empty store is reported once, naming kibi sync, instead of every store-backed rule reading an empty KB').