kibi-core 0.15.0 → 0.15.2

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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # kibi-core
2
+
3
+ The Prolog knowledge-base core of [Kibi](https://looted.github.io/kibi/): the entity and relationship schema, validation rules, inference, contradiction and proof checks that `kibi-cli` and `kibi-mcp` run against a repository's `.kb/` directory.
4
+
5
+ This package ships Prolog sources only (`src/kb.pl` is the entry module). You do not call it directly; install it with the CLI and MCP server:
6
+
7
+ ```bash
8
+ npm install --save-dev kibi-core kibi-cli kibi-mcp
9
+ ```
10
+
11
+ The [entity schema](https://looted.github.io/kibi/reference/entity-schema.html) and [inference rules](https://looted.github.io/kibi/reference/inference-rules.html) references describe what it encodes.
12
+
13
+ ## Links
14
+
15
+ - [Documentation](https://looted.github.io/kibi/)
16
+ - [Source](https://github.com/Looted/kibi)
17
+ - [Issues](https://github.com/Looted/kibi/issues)
18
+
19
+ ## License
20
+
21
+ AGPL-3.0-or-later
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-core",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "private": false,
5
5
  "description": "Core Prolog modules and RDF graph logic for Kibi",
6
6
  "type": "module",
@@ -8,14 +8,16 @@
8
8
  "node": ">=18"
9
9
  },
10
10
  "main": "./src/kb.pl",
11
- "files": [
12
- "src/**/*.pl",
13
- "schema/**/*.pl"
14
- ],
11
+ "files": ["src/**/*.pl", "schema/**/*.pl"],
15
12
  "license": "AGPL-3.0-or-later",
16
13
  "author": "Piotr Franczyk",
14
+ "homepage": "https://looted.github.io/kibi/",
17
15
  "repository": {
18
16
  "type": "git",
19
- "url": "https://github.com/Looted/kibi.git"
17
+ "url": "https://github.com/Looted/kibi.git",
18
+ "directory": "packages/core"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/Looted/kibi/issues"
20
22
  }
21
23
  }
@@ -225,15 +225,27 @@ valid_strict_polarity_in_props(Props) :-
225
225
  valid_predicate_polarity_in_props(Props) :-
226
226
  ( memberchk(polarity=P, Props) -> valid_predicate_polarity(P) ; true ).
227
227
 
228
- % claim_key and claim_text form one auditable provenance pair.
228
+ % claim_key and claim_text form one auditable provenance pair. An observation
229
+ % or meta fact is a non-grounding review note: it may quote the claim it is
230
+ % about in claim_text without claiming that claim's key.
229
231
  valid_claim_provenance(Props) :-
230
232
  ( memberchk(claim_key=Key, Props)
231
233
  -> memberchk(claim_text=Text, Props),
232
234
  nonempty_claim_value(Key),
233
235
  nonempty_claim_value(Text)
234
- ; \+ memberchk(claim_text=_, Props)
236
+ ; memberchk(claim_text=Text, Props)
237
+ -> review_note_fact(Props),
238
+ nonempty_claim_value(Text)
239
+ ; true
235
240
  ).
236
241
 
242
+ review_note_fact(Props) :-
243
+ memberchk(fact_kind=RawKind, Props),
244
+ ( atom(RawKind) -> Kind = RawKind
245
+ ; string(RawKind) -> atom_string(Kind, RawKind)
246
+ ),
247
+ memberchk(Kind, [observation, meta]).
248
+
237
249
  nonempty_claim_value(Value) :- string(Value), Value \= "", !.
238
250
  nonempty_claim_value(Value) :- atom(Value), Value \= '', !.
239
251
 
package/src/kb.pl CHANGED
@@ -26,6 +26,7 @@
26
26
  kb_query_entities/8,
27
27
  kb_search_entities/6,
28
28
  kb_list_search_candidates/5,
29
+ kb_list_search_candidates/6,
29
30
  kb_entity_ids/1,
30
31
  kb_rebuild_indexes/0,
31
32
  kb_entity/3,
@@ -1816,14 +1817,22 @@ kb_search_entities(TypeFilter, Query, Limit, Offset, Rows, Count) :-
1816
1817
  % candidate rows, ordered by id. Semantic discovery uses it when no lexical
1817
1818
  % token can pre-filter the candidate set.
1818
1819
  kb_list_search_candidates(TypeFilter, Limit, Offset, Rows, Count) :-
1820
+ kb_list_search_candidates(TypeFilter, none, Limit, Offset, Rows, Count).
1821
+
1822
+ %% kb_list_search_candidates(+Type, +Source, +Limit, +Offset, -Rows, -Count)
1823
+ % As kb_list_search_candidates/5, optionally restricted to entities whose
1824
+ % indexed source contains Source (the kb_query_entities/8 source filter).
1825
+ % Source-located search uses it so candidates stay projected rows instead of
1826
+ % complete entities.
1827
+ % implements REQ-mcp-search-discovery, REQ-kibi-intent-aware-source-discovery
1828
+ kb_list_search_candidates(TypeFilter, SourceFilter, Limit, Offset, Rows, Count) :-
1819
1829
  integer(Limit),
1820
1830
  integer(Offset),
1821
1831
  Limit >= 0,
1822
1832
  Offset >= 0,
1823
1833
  kb_ensure_indexes,
1824
1834
  findall(Id,
1825
- ( kb_index_entity(Id, _),
1826
- (TypeFilter == none -> true ; kb_index_type(TypeFilter, Id)) ),
1835
+ indexed_entity_match(TypeFilter, none, [], SourceFilter, Id),
1827
1836
  RawIds),
1828
1837
  sort(RawIds, Ids),
1829
1838
  length(Ids, Count),
@@ -55,6 +55,8 @@ known_rule('symbol-owner-superseded').
55
55
  known_rule('adr-unlinked').
56
56
  known_rule('adr-proposed').
57
57
  known_rule('predicate-schema-conformance').
58
+ known_rule('entity-context-missing').
59
+ known_rule('entity-context-acknowledged').
58
60
 
59
61
  rule_enforcement_class('must-priority-coverage', canonical).
60
62
  rule_enforcement_class('symbol-coverage', canonical).
@@ -97,6 +99,8 @@ rule_enforcement_class('symbol-owner-superseded', advisory).
97
99
  rule_enforcement_class('adr-unlinked', advisory).
98
100
  rule_enforcement_class('adr-proposed', advisory).
99
101
  rule_enforcement_class('predicate-schema-conformance', advisory).
102
+ rule_enforcement_class('entity-context-missing', canonical).
103
+ rule_enforcement_class('entity-context-acknowledged', advisory).
100
104
 
101
105
  rule_implementation('must-priority-coverage', prolog).
102
106
  rule_implementation('symbol-coverage', prolog).
@@ -139,6 +143,8 @@ rule_implementation('symbol-owner-superseded', prolog).
139
143
  rule_implementation('adr-unlinked', prolog).
140
144
  rule_implementation('adr-proposed', prolog).
141
145
  rule_implementation('predicate-schema-conformance', typescript).
146
+ rule_implementation('entity-context-missing', typescript).
147
+ rule_implementation('entity-context-acknowledged', typescript).
142
148
 
143
149
  rule_predicate('must-priority-coverage', check_must_priority_coverage).
144
150
  rule_predicate('symbol-coverage', check_symbol_coverage).
@@ -249,3 +255,5 @@ rule_description('symbol-owner-superseded', 'Advisory: a symbol whose every impl
249
255
  rule_description('adr-unlinked', 'Advisory: an accepted ADR that no requirement or other ADR is linked with (relates_to, supersedes or any typed edge, in either direction)').
250
256
  rule_description('adr-proposed', 'Informational: an ADR that is still proposed and not superseded, so nobody accepted or withdrew the decision').
251
257
  rule_description('predicate-schema-conformance', 'Predicate facts match a predicate_schema (project-local, or the built-in catalog in the default namespace) and use its declared argument constants').
258
+ rule_description('entity-context-missing', 'A current requirement, scenario, test, ADR or observation/meta fact must carry body context: at least 12 words of prose (requirements: under a Context, Rationale, Why, Background, Source, Notes or Evidence heading) that do not restate the title or semantic_text; entities tagged review:context-missing are acknowledged legacy and exempt').
259
+ rule_description('entity-context-acknowledged', 'Informational: how many current entities carry the review:context-missing tag, so the legacy context backlog stays visible; one summary finding per check').