kibi-cli 0.16.1 → 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.
Files changed (117) hide show
  1. package/dist/commands/check.d.ts.map +1 -1
  2. package/dist/commands/check.js +1 -1
  3. package/dist/commands/sync/manifest.d.ts +12 -1
  4. package/dist/commands/sync/manifest.d.ts.map +1 -1
  5. package/dist/commands/sync/manifest.js +22 -5
  6. package/dist/commands/sync/persistence.d.ts.map +1 -1
  7. package/dist/commands/sync/persistence.js +18 -1
  8. package/dist/extractors/markdown.d.ts +9 -1
  9. package/dist/extractors/markdown.d.ts.map +1 -1
  10. package/dist/extractors/markdown.js +12 -0
  11. package/dist/logic/ir.d.ts +112 -0
  12. package/dist/logic/ir.d.ts.map +1 -0
  13. package/dist/logic/ir.js +729 -0
  14. package/dist/operations/modeling/logic-modeling.d.ts +22 -0
  15. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -0
  16. package/dist/operations/modeling/logic-modeling.js +111 -0
  17. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  18. package/dist/operations/modeling/model-requirement.js +56 -0
  19. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  20. package/dist/operations/modeling/predicate-applyplan.js +15 -2
  21. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
  22. package/dist/operations/modeling/predicate-inference.js +17 -2
  23. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  24. package/dist/operations/modeling/predicate-loader.js +6 -0
  25. package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
  26. package/dist/operations/modeling/predicate-ranker.js +40 -2
  27. package/dist/operations/modeling/predicate-types.d.ts +3 -0
  28. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  29. package/dist/operations/modeling/requirement-types.d.ts +12 -0
  30. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  31. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  32. package/dist/operations/mutation/relationships.js +8 -0
  33. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  34. package/dist/operations/mutation/serialization.js +3 -0
  35. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  36. package/dist/operations/mutation/strict-fact.js +68 -3
  37. package/dist/operations/semantic-advisor/analysis-receipt.d.ts +2 -2
  38. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  39. package/dist/operations/semantic-advisor/analysis-receipt.js +23 -15
  40. package/dist/operations/semantic-advisor/analyze-prose.d.ts +1 -1
  41. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  42. package/dist/operations/semantic-advisor/analyze-prose.js +435 -13
  43. package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -1
  44. package/dist/operations/semantic-advisor/observation-plan.js +15 -3
  45. package/dist/operations/semantic-advisor/shared.d.ts +1 -0
  46. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  47. package/dist/operations/semantic-advisor/shared.js +1 -1
  48. package/dist/operations/semantic-advisor/types.d.ts +61 -1
  49. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  50. package/dist/prolog/codec.d.ts.map +1 -1
  51. package/dist/prolog/codec.js +11 -1
  52. package/dist/prolog.d.ts.map +1 -1
  53. package/dist/prolog.js +7 -2
  54. package/dist/public/operations/catalog.d.ts +85 -6
  55. package/dist/public/operations/catalog.d.ts.map +1 -1
  56. package/dist/public/operations/index.d.ts +1 -0
  57. package/dist/public/operations/index.d.ts.map +1 -1
  58. package/dist/public/operations/index.js +1 -0
  59. package/dist/public/operations/specs/check.d.ts +2 -2
  60. package/dist/public/operations/specs/check.d.ts.map +1 -1
  61. package/dist/public/operations/specs/check.js +4 -1
  62. package/dist/public/operations/specs/modeling.d.ts +16 -0
  63. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  64. package/dist/public/operations/specs/modeling.js +16 -0
  65. package/dist/public/operations/specs/mutation-schemas.d.ts +37 -2
  66. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  67. package/dist/public/operations/specs/mutation-schemas.js +27 -0
  68. package/dist/public/operations/specs/semantic.d.ts +30 -2
  69. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  70. package/dist/public/operations/specs/semantic.js +34 -2
  71. package/dist/public/operations/specs/upsert.d.ts +37 -2
  72. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  73. package/dist/public/schemas/entity.d.ts.map +1 -1
  74. package/dist/public/schemas/entity.js +290 -0
  75. package/dist/public/schemas/relationship.d.ts.map +1 -1
  76. package/dist/public/schemas/relationship.js +1 -0
  77. package/dist/public/skills/kibi-usage/SKILL.md +35 -9
  78. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +11 -1
  79. package/dist/public/skills/kibi-usage/resources/logic-ir.md +43 -0
  80. package/dist/public/skills/kibi-usage/resources/operation-access.md +19 -19
  81. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
  82. package/dist/public/skills/kibi-usage/resources/workflows.md +21 -6
  83. package/dist/public/symbol-granularity.d.ts +9 -0
  84. package/dist/public/symbol-granularity.d.ts.map +1 -1
  85. package/dist/public/symbol-granularity.js +16 -0
  86. package/dist/schemas/entity.schema.json +306 -3
  87. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  88. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  89. package/dist/traceability/staged-diagnostics.js +17 -10
  90. package/dist/traceability/staged-impact-contract.js +1 -1
  91. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  92. package/dist/traceability/staged-symbols-manifest.js +28 -10
  93. package/dist/traceability/temp-kb.d.ts.map +1 -1
  94. package/dist/traceability/temp-kb.js +13 -0
  95. package/dist/types/relationships.d.ts +1 -1
  96. package/dist/types/relationships.d.ts.map +1 -1
  97. package/dist/utils/rule-registry.d.ts.map +1 -1
  98. package/dist/utils/rule-registry.js +18 -0
  99. package/dist/utils/schema-version.d.ts +1 -1
  100. package/dist/utils/schema-version.js +1 -1
  101. package/package.json +6 -2
  102. package/src/public/operations/index.ts +1 -0
  103. package/src/public/operations/specs/check.ts +4 -1
  104. package/src/public/operations/specs/modeling.ts +20 -0
  105. package/src/public/operations/specs/mutation-schemas.ts +30 -0
  106. package/src/public/operations/specs/semantic.ts +41 -2
  107. package/src/public/schemas/entity.ts +297 -1
  108. package/src/public/schemas/relationship.ts +1 -0
  109. package/src/public/skills/kibi-usage/SKILL.md +35 -9
  110. package/src/public/skills/kibi-usage/resources/fact-lanes.md +11 -1
  111. package/src/public/skills/kibi-usage/resources/logic-ir.md +43 -0
  112. package/src/public/skills/kibi-usage/resources/operation-access.md +19 -19
  113. package/src/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
  114. package/src/public/skills/kibi-usage/resources/workflows.md +21 -6
  115. package/src/public/symbol-granularity.ts +25 -0
  116. package/src/schemas/entity.schema.json +306 -3
  117. package/src/schemas/relationship.schema.json +1 -0
@@ -2,6 +2,209 @@
2
2
  "$id": "entity.schema.json",
3
3
  "title": "Entity",
4
4
  "type": "object",
5
+ "$defs": {
6
+ "logicTerm": {
7
+ "oneOf": [
8
+ {
9
+ "type": "object",
10
+ "required": ["kind", "name", "type"],
11
+ "properties": {
12
+ "kind": { "const": "var" },
13
+ "name": { "type": "string", "pattern": "^[A-Z][A-Za-z0-9_]*$" },
14
+ "type": { "type": "string", "pattern": "^[a-z][a-z0-9_:.\\/-]*$" }
15
+ },
16
+ "additionalProperties": false
17
+ },
18
+ {
19
+ "type": "object",
20
+ "required": ["kind", "value"],
21
+ "properties": {
22
+ "kind": { "const": "const" },
23
+ "value": { "type": "string", "minLength": 1 },
24
+ "type": { "type": "string", "pattern": "^[a-z][a-z0-9_:.\\/-]*$" }
25
+ },
26
+ "additionalProperties": false
27
+ },
28
+ {
29
+ "type": "object",
30
+ "required": ["kind", "value"],
31
+ "properties": {
32
+ "kind": { "const": "number" },
33
+ "value": { "type": "number" },
34
+ "unit": { "type": "string", "pattern": "^[a-z][a-z0-9_:.\\/-]*$" }
35
+ },
36
+ "additionalProperties": false
37
+ },
38
+ {
39
+ "type": "object",
40
+ "required": ["kind", "value", "unit"],
41
+ "properties": {
42
+ "kind": { "const": "duration" },
43
+ "value": { "type": "number", "minimum": 0 },
44
+ "unit": {
45
+ "type": "string",
46
+ "enum": ["ms", "s", "m", "h", "d", "w"]
47
+ }
48
+ },
49
+ "additionalProperties": false
50
+ },
51
+ {
52
+ "type": "object",
53
+ "required": ["kind", "value"],
54
+ "properties": {
55
+ "kind": { "const": "timestamp" },
56
+ "value": { "type": "string" }
57
+ },
58
+ "additionalProperties": false
59
+ },
60
+ {
61
+ "type": "object",
62
+ "required": ["kind", "start", "end"],
63
+ "properties": {
64
+ "kind": { "const": "interval" },
65
+ "start": { "type": "string" },
66
+ "end": { "type": "string" }
67
+ },
68
+ "additionalProperties": false
69
+ }
70
+ ]
71
+ },
72
+ "logicAtom": {
73
+ "type": "object",
74
+ "required": ["kind", "name", "args"],
75
+ "properties": {
76
+ "kind": { "const": "atom" },
77
+ "namespace": { "type": "string", "pattern": "^[a-z][a-z0-9_:.\\/-]*$" },
78
+ "name": { "type": "string", "pattern": "^[a-z][a-z0-9_:.\\/-]*$" },
79
+ "args": {
80
+ "type": "array",
81
+ "maxItems": 8,
82
+ "items": { "$ref": "#/$defs/logicTerm" }
83
+ },
84
+ "polarity": { "enum": ["positive", "negative"] },
85
+ "closedWorld": { "type": "boolean" }
86
+ },
87
+ "additionalProperties": false
88
+ },
89
+ "logicExpression": {
90
+ "oneOf": [
91
+ { "$ref": "#/$defs/logicAtom" },
92
+ {
93
+ "type": "object",
94
+ "required": ["kind", "items"],
95
+ "properties": {
96
+ "kind": { "enum": ["all", "any"] },
97
+ "items": {
98
+ "type": "array",
99
+ "minItems": 1,
100
+ "maxItems": 32,
101
+ "items": { "$ref": "#/$defs/logicExpression" }
102
+ }
103
+ },
104
+ "additionalProperties": false
105
+ },
106
+ {
107
+ "type": "object",
108
+ "required": ["kind", "item"],
109
+ "properties": {
110
+ "kind": { "const": "not" },
111
+ "item": { "$ref": "#/$defs/logicAtom" }
112
+ },
113
+ "additionalProperties": false
114
+ },
115
+ {
116
+ "type": "object",
117
+ "required": ["kind", "operator", "left", "right"],
118
+ "properties": {
119
+ "kind": { "const": "compare" },
120
+ "operator": { "enum": ["eq", "neq", "lt", "lte", "gt", "gte"] },
121
+ "left": { "$ref": "#/$defs/logicTerm" },
122
+ "right": { "$ref": "#/$defs/logicTerm" }
123
+ },
124
+ "additionalProperties": false
125
+ },
126
+ {
127
+ "type": "object",
128
+ "required": ["kind", "atom", "operator", "value"],
129
+ "properties": {
130
+ "kind": { "const": "count" },
131
+ "atom": { "$ref": "#/$defs/logicAtom" },
132
+ "operator": { "enum": ["eq", "neq", "lt", "lte", "gt", "gte"] },
133
+ "value": { "type": "integer", "minimum": 0 }
134
+ },
135
+ "additionalProperties": false
136
+ },
137
+ {
138
+ "type": "object",
139
+ "required": ["kind", "relation", "left", "right"],
140
+ "properties": {
141
+ "kind": { "const": "temporal" },
142
+ "relation": {
143
+ "enum": [
144
+ "before",
145
+ "after",
146
+ "during",
147
+ "overlaps",
148
+ "starts",
149
+ "finishes"
150
+ ]
151
+ },
152
+ "left": { "$ref": "#/$defs/logicTerm" },
153
+ "right": { "$ref": "#/$defs/logicTerm" }
154
+ },
155
+ "additionalProperties": false
156
+ }
157
+ ]
158
+ },
159
+ "logicRule": {
160
+ "type": "object",
161
+ "required": ["version", "kind", "modality"],
162
+ "properties": {
163
+ "version": { "const": "kibi.logic.v1" },
164
+ "kind": { "enum": ["atom", "rule", "constraint"] },
165
+ "modality": {
166
+ "enum": ["assert", "deny", "oblige", "permit", "forbid"]
167
+ },
168
+ "head": { "$ref": "#/$defs/logicAtom" },
169
+ "body": { "$ref": "#/$defs/logicExpression" },
170
+ "variables": {
171
+ "type": "array",
172
+ "maxItems": 32,
173
+ "items": {
174
+ "type": "object",
175
+ "required": ["name", "type"],
176
+ "properties": {
177
+ "name": { "type": "string", "pattern": "^[A-Z][A-Za-z0-9_]*$" },
178
+ "type": {
179
+ "type": "string",
180
+ "pattern": "^[a-z][a-z0-9_:.\\/-]*$"
181
+ },
182
+ "quantifier": { "enum": ["forall", "exists"] }
183
+ },
184
+ "additionalProperties": false
185
+ }
186
+ },
187
+ "exceptions": {
188
+ "type": "array",
189
+ "maxItems": 16,
190
+ "items": { "$ref": "#/$defs/logicExpression" }
191
+ },
192
+ "scope": {
193
+ "type": "object",
194
+ "properties": {
195
+ "authority": { "type": "string" },
196
+ "name": { "type": "string" },
197
+ "tags": { "type": "array", "items": { "type": "string" } }
198
+ },
199
+ "additionalProperties": false
200
+ },
201
+ "validFrom": { "type": "string" },
202
+ "validTo": { "type": "string" },
203
+ "ruleSchemaId": { "type": "string", "minLength": 1 }
204
+ },
205
+ "additionalProperties": false
206
+ }
207
+ },
5
208
  "properties": {
6
209
  "id": { "type": "string" },
7
210
  "title": { "type": "string" },
@@ -44,6 +247,53 @@
44
247
  "uniqueItems": true,
45
248
  "items": { "type": "string", "pattern": "^CLAIM-[A-F0-9]{16}$" }
46
249
  },
250
+ "semantic_inventory": {
251
+ "type": "array",
252
+ "items": {
253
+ "type": "object",
254
+ "required": ["claim_key", "claim_text", "role", "status", "span"],
255
+ "properties": {
256
+ "claim_key": { "type": "string", "pattern": "^CLAIM-[A-F0-9]{16}$" },
257
+ "claim_text": { "type": "string", "minLength": 1 },
258
+ "role": {
259
+ "type": "string",
260
+ "enum": [
261
+ "normative",
262
+ "definition",
263
+ "descriptive",
264
+ "condition",
265
+ "exception",
266
+ "rationale",
267
+ "example",
268
+ "subjective"
269
+ ]
270
+ },
271
+ "status": {
272
+ "type": "string",
273
+ "enum": [
274
+ "modeled",
275
+ "ambiguous",
276
+ "ontology_gap",
277
+ "nonlogical",
278
+ "missing"
279
+ ]
280
+ },
281
+ "span": {
282
+ "type": "object",
283
+ "required": ["start", "end"],
284
+ "properties": {
285
+ "start": { "type": "integer", "minimum": 0 },
286
+ "end": { "type": "integer", "minimum": 0 }
287
+ },
288
+ "additionalProperties": false
289
+ },
290
+ "semantic_key": { "type": "string" },
291
+ "payload_hash": { "type": "string" },
292
+ "reason": { "type": "string" }
293
+ },
294
+ "additionalProperties": false
295
+ }
296
+ },
47
297
  "sourceFile": { "type": "string" },
48
298
  "granularity_reason": {
49
299
  "type": "string",
@@ -94,7 +344,9 @@
94
344
  "observation",
95
345
  "meta",
96
346
  "predicate_schema",
97
- "predicate"
347
+ "predicate",
348
+ "rule_schema",
349
+ "rule"
98
350
  ]
99
351
  },
100
352
  "subject_key": { "type": "string" },
@@ -134,7 +386,14 @@
134
386
  },
135
387
  "aliases": { "type": "array", "items": { "type": "string" } },
136
388
  "examples": { "type": "array", "items": { "type": "string" } },
137
- "predicate_args": { "type": "array", "items": { "type": "string" } }
389
+ "predicate_args": { "type": "array", "items": { "type": "string" } },
390
+ "rule_ir": { "$ref": "#/$defs/logicRule" },
391
+ "rule_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
392
+ "rule_schema_id": { "type": "string", "minLength": 1 },
393
+ "rule_name": { "type": "string", "minLength": 1 },
394
+ "semantic_key": { "type": "string", "pattern": "^SEM-[A-F0-9]{24}$" },
395
+ "claim_span_start": { "type": "integer", "minimum": 0 },
396
+ "claim_span_end": { "type": "integer", "minimum": 0 }
138
397
  },
139
398
  "required": [
140
399
  "id",
@@ -173,6 +432,36 @@
173
432
  }
174
433
  }
175
434
  },
435
+ {
436
+ "if": {
437
+ "properties": {
438
+ "type": { "const": "fact" },
439
+ "fact_kind": { "const": "rule_schema" }
440
+ },
441
+ "required": ["type", "fact_kind"]
442
+ },
443
+ "then": {
444
+ "required": ["rule_name", "argument_names", "argument_types"]
445
+ }
446
+ },
447
+ {
448
+ "if": {
449
+ "properties": {
450
+ "type": { "const": "fact" },
451
+ "fact_kind": { "const": "rule" }
452
+ },
453
+ "required": ["type", "fact_kind"]
454
+ },
455
+ "then": {
456
+ "required": [
457
+ "rule_ir",
458
+ "rule_hash",
459
+ "rule_schema_id",
460
+ "rule_name",
461
+ "semantic_key"
462
+ ]
463
+ }
464
+ },
176
465
  {
177
466
  "if": {
178
467
  "properties": { "type": { "const": "fact" } }
@@ -207,11 +496,25 @@
207
496
  { "required": ["argument_descriptions"] },
208
497
  { "required": ["aliases"] },
209
498
  { "required": ["examples"] },
210
- { "required": ["predicate_args"] }
499
+ { "required": ["predicate_args"] },
500
+ { "required": ["rule_ir"] },
501
+ { "required": ["rule_hash"] },
502
+ { "required": ["rule_schema_id"] },
503
+ { "required": ["rule_name"] },
504
+ { "required": ["semantic_key"] },
505
+ { "required": ["claim_span_start"] },
506
+ { "required": ["claim_span_end"] }
211
507
  ]
212
508
  }
213
509
  }
214
510
  },
511
+ {
512
+ "if": {
513
+ "properties": { "type": { "const": "req" } }
514
+ },
515
+ "then": {},
516
+ "else": { "not": { "required": ["semantic_inventory"] } }
517
+ },
215
518
  {
216
519
  "if": {
217
520
  "properties": {
@@ -17,6 +17,7 @@
17
17
  "constrains",
18
18
  "requires_property",
19
19
  "requires_predicate",
20
+ "requires_rule",
20
21
  "guards",
21
22
  "publishes",
22
23
  "consumes",