kibi-cli 0.16.1 → 0.18.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.
Files changed (229) hide show
  1. package/dist/cli-json-command.d.ts.map +1 -1
  2. package/dist/cli-json-command.js +87 -11
  3. package/dist/cli-register-maintenance.d.ts.map +1 -1
  4. package/dist/cli-register-maintenance.js +8 -0
  5. package/dist/cli-register-reporting.d.ts.map +1 -1
  6. package/dist/cli-register-reporting.js +5 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +2 -1
  9. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  10. package/dist/commands/aggregated-checks.js +1 -0
  11. package/dist/commands/check.d.ts.map +1 -1
  12. package/dist/commands/check.js +1 -1
  13. package/dist/commands/coverage.d.ts +5 -0
  14. package/dist/commands/coverage.d.ts.map +1 -1
  15. package/dist/commands/coverage.js +5 -0
  16. package/dist/commands/discovery-table.d.ts.map +1 -1
  17. package/dist/commands/discovery-table.js +96 -5
  18. package/dist/commands/sync/cache.d.ts +2 -0
  19. package/dist/commands/sync/cache.d.ts.map +1 -1
  20. package/dist/commands/sync/cache.js +8 -0
  21. package/dist/commands/sync/manifest.d.ts +12 -1
  22. package/dist/commands/sync/manifest.d.ts.map +1 -1
  23. package/dist/commands/sync/manifest.js +22 -5
  24. package/dist/commands/sync/persistence.d.ts.map +1 -1
  25. package/dist/commands/sync/persistence.js +76 -2
  26. package/dist/commands/sync.d.ts.map +1 -1
  27. package/dist/commands/sync.js +72 -15
  28. package/dist/commands/usage-metrics.d.ts +66 -2
  29. package/dist/commands/usage-metrics.d.ts.map +1 -1
  30. package/dist/commands/usage-metrics.js +34 -24
  31. package/dist/commands/usage-remediation.d.ts +9 -0
  32. package/dist/commands/usage-remediation.d.ts.map +1 -0
  33. package/dist/commands/usage-remediation.js +52 -0
  34. package/dist/extractors/markdown.d.ts +17 -1
  35. package/dist/extractors/markdown.d.ts.map +1 -1
  36. package/dist/extractors/markdown.js +81 -2
  37. package/dist/logic/ir.d.ts +112 -0
  38. package/dist/logic/ir.d.ts.map +1 -0
  39. package/dist/logic/ir.js +729 -0
  40. package/dist/operations/modeling/logic-modeling.d.ts +22 -0
  41. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -0
  42. package/dist/operations/modeling/logic-modeling.js +120 -0
  43. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  44. package/dist/operations/modeling/model-requirement.js +83 -2
  45. package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
  46. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  47. package/dist/operations/modeling/predicate-applyplan.js +29 -4
  48. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
  49. package/dist/operations/modeling/predicate-inference.js +3 -0
  50. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  51. package/dist/operations/modeling/predicate-loader.js +7 -1
  52. package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
  53. package/dist/operations/modeling/predicate-ranker.js +40 -2
  54. package/dist/operations/modeling/predicate-types.d.ts +12 -1
  55. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  56. package/dist/operations/modeling/requirement-types.d.ts +12 -0
  57. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  58. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  59. package/dist/operations/modeling/suggest-predicates.js +35 -11
  60. package/dist/operations/mutation/audit.js +1 -1
  61. package/dist/operations/mutation/contradictions.d.ts +1 -1
  62. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  63. package/dist/operations/mutation/contradictions.js +23 -18
  64. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  65. package/dist/operations/mutation/relationships.js +8 -0
  66. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  67. package/dist/operations/mutation/serialization.js +6 -0
  68. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  69. package/dist/operations/mutation/strict-fact.js +68 -3
  70. package/dist/operations/mutation/upsert.d.ts +3 -1
  71. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  72. package/dist/operations/mutation/upsert.js +51 -12
  73. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  74. package/dist/operations/mutation/validate-upsert.js +18 -2
  75. package/dist/operations/mutation/validation.d.ts.map +1 -1
  76. package/dist/operations/mutation/validation.js +8 -0
  77. package/dist/operations/semantic-advisor/analysis-receipt.d.ts +2 -2
  78. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  79. package/dist/operations/semantic-advisor/analysis-receipt.js +30 -16
  80. package/dist/operations/semantic-advisor/analyze-prose.d.ts +1 -1
  81. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  82. package/dist/operations/semantic-advisor/analyze-prose.js +464 -27
  83. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  84. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  85. package/dist/operations/semantic-advisor/clauses.js +7 -7
  86. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
  87. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
  88. package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
  89. package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -1
  90. package/dist/operations/semantic-advisor/observation-plan.js +15 -3
  91. package/dist/operations/semantic-advisor/shared.d.ts +9 -0
  92. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  93. package/dist/operations/semantic-advisor/shared.js +38 -4
  94. package/dist/operations/semantic-advisor/types.d.ts +66 -1
  95. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  96. package/dist/prolog/codec.d.ts.map +1 -1
  97. package/dist/prolog/codec.js +19 -2
  98. package/dist/prolog.d.ts +6 -0
  99. package/dist/prolog.d.ts.map +1 -1
  100. package/dist/prolog.js +247 -63
  101. package/dist/public/diagnostic-usage.d.ts +17 -0
  102. package/dist/public/diagnostic-usage.d.ts.map +1 -0
  103. package/dist/public/diagnostic-usage.js +152 -0
  104. package/dist/public/distribution-parity.d.ts +90 -0
  105. package/dist/public/distribution-parity.d.ts.map +1 -0
  106. package/dist/public/distribution-parity.js +367 -0
  107. package/dist/public/impact/full-kb-quality.d.ts +2 -0
  108. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  109. package/dist/public/impact/full-kb-quality.js +53 -1
  110. package/dist/public/impact-diagnostics.d.ts +2 -0
  111. package/dist/public/impact-diagnostics.d.ts.map +1 -1
  112. package/dist/public/impact-diagnostics.js +1 -0
  113. package/dist/public/operations/catalog.d.ts +235 -11
  114. package/dist/public/operations/catalog.d.ts.map +1 -1
  115. package/dist/public/operations/check-executor.d.ts.map +1 -1
  116. package/dist/public/operations/check-executor.js +4 -0
  117. package/dist/public/operations/discovery-executors.d.ts +6 -0
  118. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  119. package/dist/public/operations/discovery-executors.js +18 -2
  120. package/dist/public/operations/index.d.ts +5 -0
  121. package/dist/public/operations/index.d.ts.map +1 -1
  122. package/dist/public/operations/index.js +5 -0
  123. package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
  124. package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
  125. package/dist/public/operations/legacy-migration-plan.js +409 -0
  126. package/dist/public/operations/node-ports.d.ts.map +1 -1
  127. package/dist/public/operations/node-ports.js +90 -0
  128. package/dist/public/operations/repair-plan.d.ts +184 -0
  129. package/dist/public/operations/repair-plan.d.ts.map +1 -0
  130. package/dist/public/operations/repair-plan.js +397 -0
  131. package/dist/public/operations/runtime-types.d.ts +7 -0
  132. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  133. package/dist/public/operations/specs/check.d.ts +3 -3
  134. package/dist/public/operations/specs/check.d.ts.map +1 -1
  135. package/dist/public/operations/specs/check.js +5 -2
  136. package/dist/public/operations/specs/discovery.d.ts +1 -1
  137. package/dist/public/operations/specs/discovery.js +1 -1
  138. package/dist/public/operations/specs/modeling.d.ts +35 -1
  139. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  140. package/dist/public/operations/specs/modeling.js +32 -1
  141. package/dist/public/operations/specs/mutation-schemas.d.ts +133 -3
  142. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  143. package/dist/public/operations/specs/mutation-schemas.js +67 -1
  144. package/dist/public/operations/specs/reporting.d.ts +42 -1
  145. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  146. package/dist/public/operations/specs/reporting.js +70 -6
  147. package/dist/public/operations/specs/semantic.d.ts +30 -2
  148. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  149. package/dist/public/operations/specs/semantic.js +35 -3
  150. package/dist/public/operations/specs/upsert.d.ts +133 -3
  151. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  152. package/dist/public/operations/workspace-snapshot.d.ts +10 -0
  153. package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
  154. package/dist/public/operations/workspace-snapshot.js +20 -0
  155. package/dist/public/schemas/entity.d.ts.map +1 -1
  156. package/dist/public/schemas/entity.js +332 -0
  157. package/dist/public/schemas/relationship.d.ts.map +1 -1
  158. package/dist/public/schemas/relationship.js +1 -0
  159. package/dist/public/skills/kibi-traceability/SKILL.md +7 -1
  160. package/dist/public/skills/kibi-usage/SKILL.md +44 -12
  161. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +12 -2
  162. package/dist/public/skills/kibi-usage/resources/logic-ir.md +43 -0
  163. package/dist/public/skills/kibi-usage/resources/operation-access.md +19 -19
  164. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
  165. package/dist/public/skills/kibi-usage/resources/workflows.md +40 -8
  166. package/dist/public/symbol-granularity.d.ts +9 -0
  167. package/dist/public/symbol-granularity.d.ts.map +1 -1
  168. package/dist/public/symbol-granularity.js +16 -0
  169. package/dist/public/telemetry-acceptance.d.ts +89 -0
  170. package/dist/public/telemetry-acceptance.d.ts.map +1 -0
  171. package/dist/public/telemetry-acceptance.js +597 -0
  172. package/dist/public/telemetry-remediation.d.ts +33 -0
  173. package/dist/public/telemetry-remediation.d.ts.map +1 -0
  174. package/dist/public/telemetry-remediation.js +257 -0
  175. package/dist/public/verification-receipt.d.ts +75 -0
  176. package/dist/public/verification-receipt.d.ts.map +1 -0
  177. package/dist/public/verification-receipt.js +129 -0
  178. package/dist/schemas/entity.schema.json +401 -4
  179. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  180. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  181. package/dist/traceability/staged-diagnostics.js +17 -10
  182. package/dist/traceability/staged-impact-contract.js +1 -1
  183. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  184. package/dist/traceability/staged-symbols-manifest.js +28 -10
  185. package/dist/traceability/temp-kb.d.ts.map +1 -1
  186. package/dist/traceability/temp-kb.js +49 -3
  187. package/dist/types/entities.d.ts +1 -0
  188. package/dist/types/entities.d.ts.map +1 -1
  189. package/dist/types/relationships.d.ts +1 -1
  190. package/dist/types/relationships.d.ts.map +1 -1
  191. package/dist/utils/rule-registry.d.ts +2 -0
  192. package/dist/utils/rule-registry.d.ts.map +1 -1
  193. package/dist/utils/rule-registry.js +18 -0
  194. package/dist/utils/schema-version.d.ts +1 -1
  195. package/dist/utils/schema-version.js +1 -1
  196. package/package.json +34 -2
  197. package/src/public/diagnostic-usage.ts +206 -0
  198. package/src/public/distribution-parity.ts +580 -0
  199. package/src/public/impact/full-kb-quality.ts +74 -1
  200. package/src/public/impact-diagnostics.ts +16 -0
  201. package/src/public/operations/check-executor.ts +4 -0
  202. package/src/public/operations/discovery-executors.ts +24 -2
  203. package/src/public/operations/index.ts +5 -0
  204. package/src/public/operations/legacy-migration-plan.ts +688 -0
  205. package/src/public/operations/node-ports.ts +109 -0
  206. package/src/public/operations/repair-plan.ts +562 -0
  207. package/src/public/operations/runtime-types.ts +8 -0
  208. package/src/public/operations/specs/check.ts +5 -2
  209. package/src/public/operations/specs/discovery.ts +1 -1
  210. package/src/public/operations/specs/modeling.ts +39 -1
  211. package/src/public/operations/specs/mutation-schemas.ts +77 -1
  212. package/src/public/operations/specs/reporting.ts +91 -6
  213. package/src/public/operations/specs/semantic.ts +42 -3
  214. package/src/public/operations/workspace-snapshot.ts +28 -0
  215. package/src/public/schemas/entity.ts +340 -1
  216. package/src/public/schemas/relationship.ts +1 -0
  217. package/src/public/skills/kibi-traceability/SKILL.md +7 -1
  218. package/src/public/skills/kibi-usage/SKILL.md +44 -12
  219. package/src/public/skills/kibi-usage/resources/fact-lanes.md +12 -2
  220. package/src/public/skills/kibi-usage/resources/logic-ir.md +43 -0
  221. package/src/public/skills/kibi-usage/resources/operation-access.md +19 -19
  222. package/src/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
  223. package/src/public/skills/kibi-usage/resources/workflows.md +40 -8
  224. package/src/public/symbol-granularity.ts +25 -0
  225. package/src/public/telemetry-acceptance.ts +859 -0
  226. package/src/public/telemetry-remediation.ts +462 -0
  227. package/src/public/verification-receipt.ts +170 -0
  228. package/src/schemas/entity.schema.json +401 -4
  229. package/src/schemas/relationship.schema.json +1 -0
@@ -18,6 +18,7 @@
18
18
 
19
19
  // Typed fact field enums per proposal
20
20
  import { SYMBOL_ROLES, type SymbolRole } from "../symbol-granularity.js";
21
+ import { VERIFICATION_RECEIPT_SCHEMA } from "../verification-receipt.js";
21
22
 
22
23
  type FactKind =
23
24
  | "subject"
@@ -25,7 +26,9 @@ type FactKind =
25
26
  | "observation"
26
27
  | "meta"
27
28
  | "predicate_schema"
28
- | "predicate";
29
+ | "predicate"
30
+ | "rule_schema"
31
+ | "rule";
29
32
  type Operator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
30
33
  type ValueType = "string" | "int" | "number" | "bool";
31
34
  type Polarity = "require" | "forbid" | "assert" | "deny";
@@ -74,6 +77,30 @@ const factConditionals = JSON.parse(`[
74
77
  }
75
78
  }
76
79
  },
80
+ {
81
+ "if": {
82
+ "properties": {
83
+ "type": { "const": "fact" },
84
+ "fact_kind": { "const": "rule_schema" }
85
+ },
86
+ "required": ["type", "fact_kind"]
87
+ },
88
+ "then": {
89
+ "required": ["rule_name", "argument_names", "argument_types"]
90
+ }
91
+ },
92
+ {
93
+ "if": {
94
+ "properties": {
95
+ "type": { "const": "fact" },
96
+ "fact_kind": { "const": "rule" }
97
+ },
98
+ "required": ["type", "fact_kind"]
99
+ },
100
+ "then": {
101
+ "required": ["rule_ir", "rule_hash", "rule_schema_id", "rule_name", "semantic_key"]
102
+ }
103
+ },
77
104
  {
78
105
  "if": {
79
106
  "properties": {
@@ -90,10 +117,209 @@ const factConditionals = JSON.parse(`[
90
117
  }
91
118
  ]`) as Array<Record<string, unknown>>;
92
119
 
120
+ // The persisted rule payload is still data, but its shape is constrained at
121
+ // the JSON boundary as well as by validateLogicIr. Keeping this vocabulary
122
+ // closed prevents a raw_goal/raw Prolog field from entering an upsert payload.
123
+ const logicTermSchema = {
124
+ oneOf: [
125
+ {
126
+ type: "object",
127
+ required: ["kind", "name", "type"],
128
+ properties: {
129
+ kind: { const: "var" },
130
+ name: { type: "string", pattern: "^[A-Z][A-Za-z0-9_]*$" },
131
+ type: { type: "string", pattern: "^[a-z][a-z0-9_:.\\/-]*$" },
132
+ },
133
+ additionalProperties: false,
134
+ },
135
+ {
136
+ type: "object",
137
+ required: ["kind", "value"],
138
+ properties: {
139
+ kind: { const: "const" },
140
+ value: { type: "string", minLength: 1 },
141
+ type: { type: "string", pattern: "^[a-z][a-z0-9_:.\\/-]*$" },
142
+ },
143
+ additionalProperties: false,
144
+ },
145
+ {
146
+ type: "object",
147
+ required: ["kind", "value"],
148
+ properties: {
149
+ kind: { const: "number" },
150
+ value: { type: "number" },
151
+ unit: { type: "string", pattern: "^[a-z][a-z0-9_:.\\/-]*$" },
152
+ },
153
+ additionalProperties: false,
154
+ },
155
+ {
156
+ type: "object",
157
+ required: ["kind", "value", "unit"],
158
+ properties: {
159
+ kind: { const: "duration" },
160
+ value: { type: "number", minimum: 0 },
161
+ unit: { type: "string", enum: ["ms", "s", "m", "h", "d", "w"] },
162
+ },
163
+ additionalProperties: false,
164
+ },
165
+ {
166
+ type: "object",
167
+ required: ["kind", "value"],
168
+ properties: {
169
+ kind: { const: "timestamp" },
170
+ value: { type: "string" },
171
+ },
172
+ additionalProperties: false,
173
+ },
174
+ {
175
+ type: "object",
176
+ required: ["kind", "start", "end"],
177
+ properties: {
178
+ kind: { const: "interval" },
179
+ start: { type: "string" },
180
+ end: { type: "string" },
181
+ },
182
+ additionalProperties: false,
183
+ },
184
+ ],
185
+ };
186
+
187
+ const logicAtomSchema = {
188
+ type: "object",
189
+ required: ["kind", "name", "args"],
190
+ properties: {
191
+ kind: { const: "atom" },
192
+ namespace: { type: "string", pattern: "^[a-z][a-z0-9_:.\\/-]*$" },
193
+ name: { type: "string", pattern: "^[a-z][a-z0-9_:.\\/-]*$" },
194
+ args: {
195
+ type: "array",
196
+ maxItems: 8,
197
+ items: { $ref: "#/$defs/logicTerm" },
198
+ },
199
+ polarity: { enum: ["positive", "negative"] },
200
+ closedWorld: { type: "boolean" },
201
+ },
202
+ additionalProperties: false,
203
+ };
204
+
205
+ const logicExpressionSchema = {
206
+ oneOf: [
207
+ { $ref: "#/$defs/logicAtom" },
208
+ {
209
+ type: "object",
210
+ required: ["kind", "items"],
211
+ properties: {
212
+ kind: { enum: ["all", "any"] },
213
+ items: {
214
+ type: "array",
215
+ minItems: 1,
216
+ maxItems: 32,
217
+ items: { $ref: "#/$defs/logicExpression" },
218
+ },
219
+ },
220
+ additionalProperties: false,
221
+ },
222
+ {
223
+ type: "object",
224
+ required: ["kind", "item"],
225
+ properties: {
226
+ kind: { const: "not" },
227
+ item: { $ref: "#/$defs/logicAtom" },
228
+ },
229
+ additionalProperties: false,
230
+ },
231
+ {
232
+ type: "object",
233
+ required: ["kind", "operator", "left", "right"],
234
+ properties: {
235
+ kind: { const: "compare" },
236
+ operator: { enum: ["eq", "neq", "lt", "lte", "gt", "gte"] },
237
+ left: { $ref: "#/$defs/logicTerm" },
238
+ right: { $ref: "#/$defs/logicTerm" },
239
+ },
240
+ additionalProperties: false,
241
+ },
242
+ {
243
+ type: "object",
244
+ required: ["kind", "atom", "operator", "value"],
245
+ properties: {
246
+ kind: { const: "count" },
247
+ atom: { $ref: "#/$defs/logicAtom" },
248
+ operator: { enum: ["eq", "neq", "lt", "lte", "gt", "gte"] },
249
+ value: { type: "integer", minimum: 0 },
250
+ },
251
+ additionalProperties: false,
252
+ },
253
+ {
254
+ type: "object",
255
+ required: ["kind", "relation", "left", "right"],
256
+ properties: {
257
+ kind: { const: "temporal" },
258
+ relation: {
259
+ enum: ["before", "after", "during", "overlaps", "starts", "finishes"],
260
+ },
261
+ left: { $ref: "#/$defs/logicTerm" },
262
+ right: { $ref: "#/$defs/logicTerm" },
263
+ },
264
+ additionalProperties: false,
265
+ },
266
+ ],
267
+ };
268
+
269
+ const logicRuleSchema = {
270
+ type: "object",
271
+ required: ["version", "kind", "modality"],
272
+ properties: {
273
+ version: { const: "kibi.logic.v1" },
274
+ kind: { enum: ["atom", "rule", "constraint"] },
275
+ modality: { enum: ["assert", "deny", "oblige", "permit", "forbid"] },
276
+ head: { $ref: "#/$defs/logicAtom" },
277
+ body: { $ref: "#/$defs/logicExpression" },
278
+ variables: {
279
+ type: "array",
280
+ maxItems: 32,
281
+ items: {
282
+ type: "object",
283
+ required: ["name", "type"],
284
+ properties: {
285
+ name: { type: "string", pattern: "^[A-Z][A-Za-z0-9_]*$" },
286
+ type: { type: "string", pattern: "^[a-z][a-z0-9_:.\\/-]*$" },
287
+ quantifier: { enum: ["forall", "exists"] },
288
+ },
289
+ additionalProperties: false,
290
+ },
291
+ },
292
+ exceptions: {
293
+ type: "array",
294
+ maxItems: 16,
295
+ items: { $ref: "#/$defs/logicExpression" },
296
+ },
297
+ scope: {
298
+ type: "object",
299
+ properties: {
300
+ authority: { type: "string" },
301
+ name: { type: "string" },
302
+ tags: { type: "array", items: { type: "string" } },
303
+ },
304
+ additionalProperties: false,
305
+ },
306
+ validFrom: { type: "string" },
307
+ validTo: { type: "string" },
308
+ ruleSchemaId: { type: "string", minLength: 1 },
309
+ },
310
+ additionalProperties: false,
311
+ };
312
+
93
313
  const entitySchema: Record<string, unknown> = {
94
314
  $id: "entity.schema.json",
95
315
  title: "Entity",
96
316
  type: "object",
317
+ $defs: {
318
+ logicTerm: logicTermSchema,
319
+ logicAtom: logicAtomSchema,
320
+ logicExpression: logicExpressionSchema,
321
+ logicRule: logicRuleSchema,
322
+ },
97
323
  properties: {
98
324
  id: { type: "string" },
99
325
  title: { type: "string" },
@@ -130,12 +356,81 @@ const entitySchema: Record<string, unknown> = {
130
356
  severity: { type: "string" },
131
357
  links: { type: "array", items: { type: "string" } },
132
358
  text_ref: { type: "string" },
359
+ semantic_text: {
360
+ type: "string",
361
+ description:
362
+ "Requirement-only authored prose whose exact UTF-8 bytes anchor the semantic inventory without replacing text_ref evidence.",
363
+ },
133
364
  logic_claims: {
134
365
  type: "array",
135
366
  minItems: 1,
136
367
  uniqueItems: true,
137
368
  items: { type: "string", pattern: "^CLAIM-[A-F0-9]{16}$" },
138
369
  },
370
+ semantic_clauses: {
371
+ type: "array",
372
+ minItems: 1,
373
+ items: { type: "string", minLength: 1 },
374
+ },
375
+ semantic_inventory_version: {
376
+ type: "string",
377
+ const: "kibi.semantic-inventory.v1",
378
+ },
379
+ semantic_source_field: {
380
+ type: "string",
381
+ enum: ["semantic_text", "text_ref", "title"],
382
+ },
383
+ semantic_source_hash: {
384
+ type: "string",
385
+ pattern: "^[a-f0-9]{64}$",
386
+ },
387
+ semantic_inventory: {
388
+ type: "array",
389
+ items: {
390
+ type: "object",
391
+ required: ["claim_key", "claim_text", "role", "status", "span"],
392
+ properties: {
393
+ claim_key: { type: "string", pattern: "^CLAIM-[A-F0-9]{16}$" },
394
+ claim_text: { type: "string", minLength: 1 },
395
+ role: {
396
+ type: "string",
397
+ enum: [
398
+ "normative",
399
+ "definition",
400
+ "descriptive",
401
+ "condition",
402
+ "exception",
403
+ "rationale",
404
+ "example",
405
+ "subjective",
406
+ ],
407
+ },
408
+ status: {
409
+ type: "string",
410
+ enum: [
411
+ "modeled",
412
+ "ambiguous",
413
+ "ontology_gap",
414
+ "nonlogical",
415
+ "missing",
416
+ ],
417
+ },
418
+ span: {
419
+ type: "object",
420
+ required: ["start", "end"],
421
+ properties: {
422
+ start: { type: "integer", minimum: 0 },
423
+ end: { type: "integer", minimum: 0 },
424
+ },
425
+ additionalProperties: false,
426
+ },
427
+ semantic_key: { type: "string" },
428
+ payload_hash: { type: "string" },
429
+ reason: { type: "string" },
430
+ },
431
+ additionalProperties: false,
432
+ },
433
+ },
139
434
  sourceFile: { type: "string" },
140
435
  granularity_reason: {
141
436
  type: "string",
@@ -158,6 +453,11 @@ const entitySchema: Record<string, unknown> = {
158
453
  type: "string",
159
454
  enum: ["internal", "consumer"] satisfies VerificationPerspective[],
160
455
  },
456
+ verification_receipts: {
457
+ type: "array",
458
+ maxItems: 50,
459
+ items: VERIFICATION_RECEIPT_SCHEMA,
460
+ },
161
461
  type: {
162
462
  type: "string",
163
463
  enum: [
@@ -181,6 +481,8 @@ const entitySchema: Record<string, unknown> = {
181
481
  "meta",
182
482
  "predicate_schema",
183
483
  "predicate",
484
+ "rule_schema",
485
+ "rule",
184
486
  ] satisfies FactKind[],
185
487
  },
186
488
  subject_key: { type: "string" },
@@ -212,6 +514,13 @@ const entitySchema: Record<string, unknown> = {
212
514
  aliases: { type: "array", items: { type: "string" } },
213
515
  examples: { type: "array", items: { type: "string" } },
214
516
  predicate_args: { type: "array", items: { type: "string" } },
517
+ rule_ir: { $ref: "#/$defs/logicRule" },
518
+ rule_hash: { type: "string", pattern: "^[a-f0-9]{64}$" },
519
+ rule_schema_id: { type: "string", minLength: 1 },
520
+ rule_name: { type: "string", minLength: 1 },
521
+ semantic_key: { type: "string", pattern: "^SEM-[A-F0-9]{24}$" },
522
+ claim_span_start: { type: "integer", minimum: 0 },
523
+ claim_span_end: { type: "integer", minimum: 0 },
215
524
  },
216
525
  required: [
217
526
  "id",
@@ -268,6 +577,13 @@ const entitySchema: Record<string, unknown> = {
268
577
  { required: ["aliases"] },
269
578
  { required: ["examples"] },
270
579
  { required: ["predicate_args"] },
580
+ { required: ["rule_ir"] },
581
+ { required: ["rule_hash"] },
582
+ { required: ["rule_schema_id"] },
583
+ { required: ["rule_name"] },
584
+ { required: ["semantic_key"] },
585
+ { required: ["claim_span_start"] },
586
+ { required: ["claim_span_end"] },
271
587
  ],
272
588
  },
273
589
  },
@@ -281,6 +597,29 @@ const entitySchema: Record<string, unknown> = {
281
597
  anyOf: [
282
598
  { required: ["verification_scope"] },
283
599
  { required: ["verification_perspective"] },
600
+ { required: ["verification_receipts"] },
601
+ ],
602
+ },
603
+ },
604
+ },
605
+ {
606
+ if: { required: ["verification_receipts"] },
607
+ // biome-ignore lint/suspicious/noThenProperty: JSON Schema conditional keyword.
608
+ then: { required: ["verification_scope"] },
609
+ },
610
+ {
611
+ if: {
612
+ properties: { type: { const: "req" } },
613
+ },
614
+ else: {
615
+ not: {
616
+ anyOf: [
617
+ { required: ["semantic_inventory"] },
618
+ { required: ["semantic_clauses"] },
619
+ { required: ["semantic_text"] },
620
+ { required: ["semantic_inventory_version"] },
621
+ { required: ["semantic_source_field"] },
622
+ { required: ["semantic_source_hash"] },
284
623
  ],
285
624
  },
286
625
  },
@@ -35,6 +35,7 @@ const relationshipSchema = {
35
35
  "constrains",
36
36
  "requires_property",
37
37
  "requires_predicate",
38
+ "requires_rule",
38
39
  "guards",
39
40
  "publishes",
40
41
  "consumes",
@@ -34,6 +34,7 @@ echo '{"sourceFiles":["src/auth/login.ts"],"includeImpactDiagnostics":true,"incl
34
34
  - After meaningful source edits, run `kb_check({sourceFiles:[...], includeImpactDiagnostics:true, includeWorkingTreeDiff:true})` or the equivalent `check --input` JSON recipe before deciding whether traceability is current.
35
35
  - Apply traceability updates sequentially through `kb_upsert` or `upsert --input` for requirements, scenarios, tests, facts, behavioral symbols, and source-linked relationships.
36
36
  - Validate constraints and consistency through `kb_check` or `check --input` after updates.
37
+ - Run `kb_coverage` by requirement after validation. Treat `coverageStatus` as structural compatibility only; use the separate `proofStatus`, `proofStages`, `proofGaps`, and ranked `proofRepairs` to decide whether the complete intent-to-code chain is proven.
37
38
  - Use `kb_delete` or `delete --input` only for explicit cleanup of obsolete records or relationships.
38
39
 
39
40
  ## Guidance
@@ -42,6 +43,11 @@ echo '{"sourceFiles":["src/auth/login.ts"],"includeImpactDiagnostics":true,"incl
42
43
  - Preserve source-file traceability whenever adding or changing requirements, scenarios, tests, facts, behavioral symbols, or implementation links.
43
44
  - Preserve the canonical chain `REQ-* -> SCEN-* -> TEST-*` when adding or changing requirements.
44
45
  - Production symbols should implement requirements; test symbols should remain executable evidence for tests.
46
+ - A proof-bearing test must be reached through the requirement's scenario, declare `verification_scope: end_to_end`, and carry a fresh passed `kibi.verification-receipt.v1` bound to the live `verificationSnapshot`. Link its executable code with `executable_for`; link each production symbol with `implements` and `covered_by` to that qualifying test. Durable `status: passing` is structural metadata, not execution proof.
47
+ - Read `kb_status` immediately before a proof-bearing run, execute the exact recorded command, then append—not replace—the receipt history with test ID, scope, runner, command, snapshot, environment hash, timestamps, outcome, and artifact digest. Re-read coverage; wrong-snapshot, stale, failed, malformed, future-dated, or unavailable evidence must remain a gap.
48
+ - A green structural count is not proof. Do not report success while a proposition is absent or unresolved, grounding is incomplete or non-bijective, contradiction analysis is incomplete, the E2E path is direct-only, its execution receipt is not fresh for the live snapshot, or proof-bearing symbols lack current generated coordinates.
49
+ - Use `kb_coverage.repairPlan` to turn row-local `proofRepairs` into small dependency-ordered batches. Require `scope.complete: true` before treating it as a project-wide inventory, apply only `state: ready` work, and treat every `autoApplicable: false` batch as reviewed guidance rather than an executable mutation payload. Query current endpoints, follow its validation policy, keep upserts sequential, then rerun coverage after each batch; newly visible downstream gaps supersede the older plan. Never reinterpret `no_conflict_found` as universal consistency; it only describes the modeled ground claims Kibi could inspect.
50
+ - When `.kb/usage.log` exists, run `kibi usage-metrics --format json --require-acceptance` after the final complete coverage call. A successful graph check does not override failed or insufficient `kibi.telemetry-acceptance.v1` evidence; follow ranked telemetry diagnostics for advisor/preflight bypasses, lookup misses, stalled proof recovery, receipt freshness, or repeated mutation failures.
45
51
  - Resolve impact at behavioral-symbol granularity when Kibi reports symbol-level diagnostics; avoid treating a whole file as impacted when the report identifies narrower linked behavior.
46
52
  - Treat `symbol_semantic_review_needed` as a prompt to inspect linked requirements and tests; Kibi reports graph links but does not prove prose semantics.
47
53
  - Do not read or edit files inside `.kb` directly; all modeling and cleanup goes through the selected Kibi interface.
@@ -51,4 +57,4 @@ Public training trajectories:
51
57
  [{"taskId":"kibi-traceability-requirement-discovery-train-1","family":"requirement-discovery","reflection":"Discover the requirement linked to the supplied source symbol. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-requirement-discovery-train-2","family":"requirement-discovery","reflection":"Discover the requirement linked to the supplied source symbol. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-symbol-impact-granularity-train-1","family":"symbol-impact-granularity","reflection":"Resolve impact at behavioral symbol granularity rather than file granularity. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-symbol-impact-granularity-train-2","family":"symbol-impact-granularity","reflection":"Resolve impact at behavioral symbol granularity rather than file granularity. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-relationship-chain-train-1","family":"relationship-chain","reflection":"Trace the requirement, scenario, and test relationship chain. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-relationship-chain-train-2","family":"relationship-chain","reflection":"Trace the requirement, scenario, and test relationship chain. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-executable-coverage-train-1","family":"executable-coverage","reflection":"Establish executable test identity and behavioral coverage links. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-executable-coverage-train-2","family":"executable-coverage","reflection":"Establish executable test identity and behavioral coverage links. This is train case 2; use only the public Kibi MCP surface."}]
52
58
 
53
59
  Previous development gate:
54
- {"mean":0,"hardPasses":0,"worstFamilyMean":0}
60
+ {"mean":0,"hardPasses":0,"worstFamilyMean":0}
@@ -2,7 +2,7 @@
2
2
  id: kibi-usage
3
3
  name: Kibi Usage
4
4
  description: Guides agents to use Kibi MCP, facts, relationships, and validation correctly
5
- version: 1.2.0
5
+ version: 1.3.0
6
6
  kibiCompatibility: ">=0.11.0"
7
7
  tags:
8
8
  - kibi
@@ -15,6 +15,8 @@ resources:
15
15
  - resources/fact-lanes.md
16
16
  - resources/workflows.md
17
17
  - resources/operation-access.md
18
+ - resources/ui-requirements.md
19
+ - resources/logic-ir.md
18
20
  ---
19
21
  # Kibi Usage
20
22
 
@@ -22,10 +24,10 @@ Consult this skill before any Kibi knowledge base operation, on first interactio
22
24
 
23
25
  ## Interface Selection
24
26
 
25
- Use this order for every Kibi operation:
27
+ Kibi exposes two peer surfaces over the same 18 operations: visible MCP tools and the trusted project-local CLI. Both accept the same business input and effects (see `resources/operation-access.md`). Choose by what is visible and approved in the current environment — MCP and the CLI are equal choices, not a preference order:
26
28
 
27
29
  1. If Kibi MCP tools are visible and approved in the current environment, use MCP.
28
- 2. Otherwise, in a trusted workspace, use the project-local CLI through a non-installing runner: `npx --no-install kibi ...` or `bunx --no-install kibi ...`.
30
+ 2. Otherwise, in a trusted workspace, use the project-local CLI through a non-installing runner: `npx --no-install kibi ...` or `bunx --no-install kibi ...`. The CLI is a peer interface, not a fallback.
29
31
  3. If the project-local CLI is unavailable or too old for the needed route, stop and tell the operator to enable or install Kibi.
30
32
  4. Never use a global fallback or an installing runner. Never probe or install packages as a side effect of interface selection.
31
33
 
@@ -99,6 +101,20 @@ relationships:
99
101
  to: REQ-ADMIN-BILLING-POLICY
100
102
  ```
101
103
 
104
+ ## Typed Logic IR Lane
105
+
106
+ Readable prose is retained for people, while every assertive proposition is inventoried and either grounded in a strict fact, a predicate fact, or a safe typed rule. Use the required extraction pass followed by an adversarial coverage audit; do not let a high-confidence single suggestion stand in for the rest of a compound requirement. Load `resources/logic-ir.md` for the IR grammar, proposition ledger, safety boundary, and proof semantics.
107
+
108
+ Use `kb_semantic_advisor` with up to three typed `interpretations` for ambiguous clauses. Kibi canonicalizes alternatives and keeps materially different meanings unresolved. Create `fact_kind: rule_schema` and `fact_kind: rule` endpoints from `kb_model_requirement`'s validated plan, then link `req -> rule` with `requires_rule`. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions`; unresolved, incomplete, or timed-out reasoning is not evidence of consistency.
109
+
110
+ The portable skill body must carry the core contract even when its detailed resources are unavailable: `kb_semantic_advisor` returns a `propositions[]` ledger and `semantic_inventory`; submit typed `interpretations` when wording has more than one plausible logical reading; validate modeled conditions through `kibi.logic.v1`; and preserve unresolved propositions as explicit gaps. Do not read or edit files inside `.kb` directly.
111
+
112
+ Requirement proof also requires fresh execution evidence. Read the available `verificationSnapshot` from `kb_status`, run the scenario-backed E2E command, and append a `kibi.verification-receipt.v1` carrying test ID, typed scope, runner, command, snapshot, environment hash, timestamps, outcome, and artifact digest. Never rewrite receipt history or treat durable `status: passing` as execution proof; re-run coverage and repair every receipt-specific gap.
113
+
114
+ Requirement-mode `kb_coverage` also returns `kibi.repair-plan.v1`. Use it only when `scope.complete` is true; a partial plan means pagination hid actionable requirements. Apply only the earliest `ready` batch for each requirement, query before mutation, create endpoints before relationships, validate every payload, and keep `kb_upsert` calls sequential. Batches are deliberately `autoApplicable: false`: semantic resolution, contradiction supersession, E2E execution, and source ownership always require review. Re-run coverage after every batch instead of continuing from a stale plan.
115
+
116
+ When `.kb/usage.log` exists, treat `kibi.telemetry-acceptance.v1` as the process-evidence lane. Run `kibi usage-metrics --format json --require-acceptance` before completion and inspect unfiltered `kb_check.qualityDiagnostics[]` for ranked `category: telemetry` repairs. The rolling report requires fresh evidence for advisor-before-requirement-write, exact validation-before-upsert, source-linked lookup results, proof-gap recovery, receipt freshness, and mutation retry discipline. `insufficient_evidence` is not a pass: capture current complete coverage and diagnostic events rather than waiving stale, partial, or pre-upgrade logs. A missing usage log means diagnostic logging is not active; do not invent telemetry evidence.
117
+
102
118
  ## Strict Fact Lane
103
119
 
104
120
  Normative requirements that must participate in contradiction blocking use the strict fact lane. Create a `fact_kind: subject` fact and link it from the requirement via `constrains`. Create a `fact_kind: property_value` fact and link it via `requires_property`.
@@ -126,19 +142,25 @@ Use `kb_model_requirement` for automated strict-fact modeling when available. It
126
142
 
127
143
  Granular fact examples for coherence checks include `REQ-ROLE-SET-2` versus `REQ-ROLE-SET-3` on `user.roles.allowed_set` (`user,admin` versus `user,admin,superadmin`) and `REQ-ADMIN-CAN-MANAGE-BILLING` versus `REQ-ONLY-SUPERADMIN-MANAGES-BILLING` on `billing.manage.allowed_actor`. See `resources/fact-lanes.md`; `domain-contradictions` uses these canonical keys.
128
144
 
145
+ ## UI / Visual Requirement Modeling
146
+
147
+ Optional, per-project lane for recording what the screen should look like so UI edits cannot silently drift from the spec. Non-UI projects skip it; no check rule requires it.
148
+
149
+ Use three layers: a prose `req` as the searchable anchor, strict `property_value` facts for checkable positions/alignment/order (linked `constrains` / `requires_property`, so incompatible values on the same subject/property are rejected on write unless `supersedes`), and relational predicates linked with `requires_predicate` (built-in `visual_layout_rule(subject, relation, target)` for "X must remain visually aligned with Y"). Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement, so component edits surface the visual spec in impact diagnostics. Full payloads and workflow: `resources/ui-requirements.md`.
150
+
129
151
  ## Complete Logical Coverage
130
152
 
131
153
  Readable prose is not evidence that a requirement is machine-checkable. Before treating a normative requirement as modeled, decompose its entire body into atomic normative clauses and ground every clause. One correct fact or relationship never proves that the other prose is covered.
132
154
 
133
155
  1. Call `kb_semantic_advisor` with the complete requirement prose. When the automatic split is incomplete or a sentence contains multiple obligations, pass an explicit `clauses` array containing every atomic normative clause.
134
156
  2. Use the stable `claim_key` returned for each clause. Every ground `property_value` or `predicate` fact must preserve that key in `claim_key` and preserve the clause in `claim_text`. Use the advisor-returned inventory exactly; do not add punctuation or wording variants of an existing clause.
135
- 3. Put the complete set of keys in the requirement's `logic_claims` manifest. Merge returned keys with existing values; never overwrite earlier claims while modeling a later clause.
136
- 4. Ground each key through exactly one suitable logical lane: `requires_property` to one strict `property_value` fact, or `requires_predicate` to one ground `predicate` fact. A subject fact supports a strict claim but does not ground a key by itself. Observation, meta, ambiguity, and ontology-gap facts explicitly remain unresolved and do not count as logical coverage.
137
- 5. Run `kb_check` with `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`. `logic-coverage` enforces a one-claim/one-ground-fact mapping and rejects distinct claim keys that encode the same logical term; human or agent review still confirms that the atomic clauses exhaust the prose and that each ground term preserves its meaning.
157
+ 3. Put exactly the current assertive proposition keys in the requirement's `logic_claims` manifest. Preserve unrelated metadata, but remove stale claim keys when the source meaning changes; never silently omit an earlier proposition that remains in the current prose.
158
+ 4. Ground each key through exactly one suitable logical lane: `requires_property` to one strict `property_value` fact, `requires_predicate` to one ground `predicate` fact, or `requires_rule` to one safe `rule` fact. A subject fact supports a strict claim but does not ground a key by itself. Observation, meta, ambiguity, and ontology-gap facts explicitly remain unresolved and do not count as logical coverage.
159
+ 5. Run `kb_check` with `logic-coverage`, `rule-safety`, `rule-verifiability`, `semantic-completeness`, `predicate-verifiability`, and `domain-contradictions`. `logic-coverage` enforces a one-claim/one-ground-fact mapping and rejects distinct claim keys that encode the same logical term; human or agent review still confirms that the atomic clauses exhaust the prose and that each ground term preserves its meaning.
138
160
 
139
161
  Kibi emits a non-blocking logical-coverage debt diagnostic for every current requirement without a manifest, independent of title wording. The `logic-coverage` rule is enabled by default for requirements that do declare manifests, so an unfiltered final check catches missing or orphaned ground claims while legacy requirements remain explicit backfill work.
140
162
 
141
- A complete `logic_claims` manifest alone is not a complete model. Semantic-advisor readiness remains partial until the payload has at least one distinct `requires_property` or `requires_predicate` grounding slot per normative claim. This count prevents one token edge from suppressing the remaining plans; only `logic-coverage` readback proves that each slot reaches the fact with the matching claim key.
163
+ A complete `logic_claims` manifest alone is not a complete model. Preserve the advisor's `inventory_contract` as `semantic_inventory_version`, `semantic_source_field`, and `semantic_source_hash`; every ledger span must select its exact claim text from that field. For new or migrated requirements, use requirement-only `semantic_text` for normalized authored prose and keep `text_ref` available for independent code or document evidence. Legacy direct payloads may still declare `text_ref` or `title`; an explicitly declared but empty semantic source fails closed instead of falling through. Mutation rejects duplicate or omitted propositions and requires every `modeled` entry to resolve through exactly one logical edge to a fact with the same claim key. Explicit unresolved entries remain ingestible but cannot prove the requirement.
142
164
 
143
165
  Never invent, reuse across different clauses, or manually alter a claim key. Kibi derives it from `claim_text` and rejects mismatched mutation and Markdown inputs.
144
166
 
@@ -165,11 +187,21 @@ Preserve the readable requirement prose. Facts add a machine-queryable model; th
165
187
 
166
188
  1. Call `kb_semantic_advisor` on the complete prose, verify its atomic clause inventory, and choose one lane per clause.
167
189
  2. For each relational clause, call `kb_suggest_predicates` with that clause and the current `existingLogicClaims`. Read each candidate as a Prolog-shaped ground term `predicate_name(arg1,...,argN)`: the schema fixes the predicate name, arity, argument roles, and argument order.
168
- 3. Accept a candidate only when its meaning and every ordered argument fit the prose. Use the returned `applyPlan`, including its exact `predicate_name`, `predicate_args`, `canonical_key`, and `polarity`; never invent a predicate name, reorder arguments, add variables, or write a raw Prolog clause.
190
+ 3. Accept a candidate only when its meaning and every ordered argument fit the prose. If lexical rank order prefers a false positive, retry with the reviewed candidate's exact `schema.id` as `schemaId`; do not mutate the candidate or treat a missing schema reference as an ontology gap. If it returns `binding_status: incomplete`, retry with exact `argumentBindings` for every `unbound_arguments` name; its empty `applyPlan` is a safety gate, and the literal `unknown` must never be persisted. Use `polarityHint` only when review of the complete claim proves that surface negation does not deny the selected predicate. Once complete, use the returned `applyPlan`, including its exact `predicate_name`, `predicate_args`, `canonical_key`, and `polarity`; never invent a predicate name, reorder arguments, add variables, or write a raw Prolog clause.
169
191
  4. Create or confirm the requirement and `fact_kind: predicate` endpoints, preserve `claim_key` and `claim_text`, merge the returned `logicClaims` into the requirement, then link requirement -> predicate fact with `requires_predicate`. Treat the requirement's logical representation as the conjunction of every linked ground term. Encode a prohibition with `polarity: deny` on the fitting positive schema, not a made-up negative predicate. An `assert` and `deny` requirement over the same namespace, name, and ordered arguments are a blocking `domain-contradictions` conflict, so requirements must reuse the same canonical schema and argument vocabulary for equivalent domain claims.
170
192
  5. Use an existing built-in or project-local `fact_kind: predicate_schema`. Create a new schema only when the task explicitly authorizes ontology extension and supplies a stable name, arity, `argument_names`, and `argument_types`; otherwise record `fact_kind: observation` with `review:ontology-gap`.
171
- 6. For each scalar, threshold, duration, boolean, enum-set, or cardinality clause, use `kb_model_requirement` with the current `existingLogicClaims` and the strict subject/property lane instead. For ambiguity or a lexical false positive, preserve the prose as a review observation and report the requirement as logically incomplete.
172
- 7. Validate every payload, create endpoints first, apply `kb_upsert` calls sequentially, read back all affected IDs, and run targeted `logic-coverage`, `predicate-verifiability`, and `domain-contradictions` checks before the final unfiltered `kb_check`. Exact query output can return an array when one relationship type has multiple targets; verify every target rather than reading only one edge.
193
+ 6. For each scalar, threshold, duration, boolean, enum-set, or cardinality clause, use `kb_model_requirement` with the current `existingLogicClaims` and the strict subject/property lane instead. For ambiguity or a lexical false positive, preserve the prose as a review observation, apply its returned `relates_to` review anchor when present, and report the requirement as logically incomplete. Use `review:ambiguity` for unresolved scope or interpretation and `review:keyword-false-positive` when a vocabulary match is not a domain assertion.
194
+ 7. Validate every payload, create endpoints first, apply `kb_upsert` calls sequentially, read back all affected IDs, and run targeted `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions` checks before the final unfiltered `kb_check`. Exact query output can return an array when one relationship type has multiple targets; verify every target rather than reading only one edge.
195
+
196
+ ### Schema-aware proposition boundary
197
+
198
+ A declared project-local predicate schema can encode one complete relation whose ordered arguments name several facets of the same claim. Do not split those arguments into separate propositions, invent one predicate per noun, or pass an explicit `clauses` array merely to enumerate the schema arguments. First ask `kb_semantic_advisor` about the complete sentence; add clauses only for independently asserted propositions that are not represented by the selected relation. For a schema-backed relation, preserve the one claim key for the complete relation, create the supporting `predicate_schema` with its minimal declared signature (supporting schemas do not carry `claim_key` or `logic_claims`), call `kb_suggest_predicates` on the complete claim, and apply its exact plan to create one ground predicate fact with the ordered schema arguments and that claim key. If `kb_model_requirement` returns an apply plan, execute that plan sequentially; do not fall back to observation facts when an explicitly declared schema fits. If a schema write is rejected, use `kb_validate_upsert` to reduce it to the supported signature, then retry once before considering an ontology gap.
199
+
200
+ ### Hard lane gates for unresolved prose and supplied schemas
201
+
202
+ The advisor's proposition `status` is a safety gate, not a confidence hint. A `nonlogical` proposition (including `subjective`, rationale, example, heading, or commentary) never receives a `logic_claims` entry and never goes through `kb_suggest_predicates` or `kb_model_requirement`; preserve the complete prose as one `fact_kind: observation` only when an auditable record is useful. Do not manufacture atomic clauses from a subjective sentence merely because it contains `when`, a domain noun, or the word `predicate`. An `ambiguous` proposition remains an ambiguity observation until the operator supplies a typed interpretation. An `ontology_gap` remains unresolved unless an approved schema or validated IR is actually available.
203
+
204
+ When authorized task input contains `projectLocalSchemas`, those declarations are the schema authority even if the first advisor or predicate lookup calls them an ontology gap. Do not treat an empty candidate list as final: create the minimal declared `predicate_schema` endpoint first, then call `kb_suggest_predicates` again on the one complete claim (with the current `existingLogicClaims`) and apply the resulting ground predicate plan. Preserve the single claim key for that relation; do not add keys for schema arguments. If the lookup still cannot return a plan after the declared schema exists, validate the exact schema-backed predicate payload once and report the remaining blocker rather than inventing a different predicate. For prohibition cues (`must not`, `never`, `cannot`, `forbidden`), use the positive schema with `polarity: deny`; never silently change it to `assert` or encode the negation in a new predicate name.
173
205
 
174
206
  Example: “Checkout requires payment authorization before order submission” fits `dependency_rule(subject, prerequisite, dependent)`. The ground model is `dependency_rule(checkout,payment_authorization,order_submission)`, stored as:
175
207
 
@@ -217,7 +249,7 @@ Never fire `kb_upsert` calls in parallel. Execute them sequentially to avoid loc
217
249
 
218
250
  ## Checks
219
251
 
220
- Run `kb_check` with specific rules during iteration for fast feedback. For normative requirement modeling, include `rules: ["logic-coverage", "predicate-verifiability", "domain-contradictions"]`; add `required-fields` and `no-dangling-refs` after writes. Run a full `kb_check` without rule filters before declaring Kibi work complete.
252
+ Run `kb_check` with specific rules during iteration for fast feedback. For normative requirement modeling, include `rules: ["rule-safety", "rule-verifiability", "semantic-completeness", "logic-coverage", "predicate-verifiability", "domain-contradictions"]`; add `required-fields` and `no-dangling-refs` after writes. Run a full `kb_check` without rule filters before declaring Kibi work complete.
221
253
 
222
254
  The `domain-contradictions` rule detects conflicts between strict-lane facts linked to requirements. When a contradiction is found, the supported escape hatch is `supersedes`: create a new requirement that supersedes the old one, then link the new requirement to updated facts.
223
255
 
@@ -238,7 +270,7 @@ Call `kb_status` when branch KB context may be stale or after switching context.
238
270
  | Tags as multi-ID lookup | Tags are metadata, not identifiers | Use `kb_query` with explicit `id` values |
239
271
  | `relates_to` for strict modeling | Loses contradiction safety | Use `constrains` and `requires_property` instead |
240
272
  | One fact for a compound requirement | Leaves untracked prose outside contradiction checks | Decompose all atomic clauses, preserve claim keys, and validate `logic_claims` with `logic-coverage` |
241
- | Replacing `logic_claims` on each call | Discards previously grounded clauses | Pass existing keys and merge the returned manifest |
273
+ | Keeping stale `logic_claims` after prose changes | Makes the manifest disagree with the source ledger | Replace it atomically with exactly the current assertive keys while preserving unrelated metadata |
242
274
  | Observation counted as coverage | Ambiguity or ontology gaps appear machine-checkable | Keep the claim unresolved until a strict or predicate ground fact exists |
243
275
  | Relationship type used as predicate name | Confuses graph edges with ontology terms | Select a declared predicate schema and keep `requires_predicate` as the req -> fact edge |
244
276
  | `status: implemented` on requirements | Not a valid lifecycle status | Use a valid status such as `closed`, add an `implemented` tag, and link evidence instead |
@@ -7,8 +7,8 @@ Requirement prose remains the human-readable source. Facts add queryable semanti
7
7
  Logical coverage is clause-based, not entity-based. Give `kb_semantic_advisor` the complete requirement body and verify that its `clauses` list contains every atomic obligation. Supply the `clauses` input yourself when automatic splitting would combine or omit obligations. For every normative clause:
8
8
 
9
9
  - preserve the returned stable key as `claim_key` and the exact clause as `claim_text` on its ground fact;
10
- - add the key to the requirement `logic_claims` manifest without removing existing keys;
11
- - link it through exactly one `requires_property` for `property_value` or one `requires_predicate` for `predicate`;
10
+ - add the key to the exact current `logic_claims` set, removing only stale keys whose propositions no longer exist in the source;
11
+ - link it through exactly one `requires_property` for `property_value`, one `requires_predicate` for `predicate`, or one `requires_rule` for a safe `rule` fact;
12
12
  - leave ambiguity and ontology gaps visibly unresolved—observations do not satisfy `logic-coverage`.
13
13
 
14
14
  Use the advisor-returned atomic inventory as the identity boundary. Trailing punctuation and copied conjunction commas are formatting, not new claims. `logic-coverage` rejects one claim grounded by multiple facts and distinct claim keys that resolve to the same ground logical term.
@@ -76,6 +76,16 @@ If another current requirement links an `assert` fact with the same predicate na
76
76
 
77
77
  The full logical representation of a requirement is the conjunction of all of its linked ground property and predicate terms. Conditions, exceptions, permissions, and ordering constraints remain explicit arguments of their declared schemas. Contradiction detection therefore depends on equivalent prose reusing the same predicate name, argument roles, ordered canonical values, and opposing polarity rather than inventing synonymous terms.
78
78
 
79
+ ### Lane gates before a predicate lookup
80
+
81
+ Treat the advisor's proposition status as a hard routing decision. `nonlogical`/`subjective` prose is not a logical claim: keep it as one observation when needed and do not add its key to `logic_claims`. `ambiguous` prose stays an ambiguity observation. `ontology_gap` prose stays unresolved unless an approved schema or validated Logic IR is available. Never split a subjective or commentary sentence into synthetic clauses just because it contains conditional words or domain vocabulary.
82
+
83
+ If authorized input supplies `projectLocalSchemas`, use those signatures as the authority. Create the minimal `predicate_schema` endpoint before lookup, then rerun `kb_suggest_predicates` on the complete relation if the first lookup had no candidate. Apply exactly one ground predicate and one claim key for that relation. For `must not`, `never`, `cannot`, or `forbidden` wording, preserve the positive schema and set `polarity: deny`; do not turn the result into an asserted predicate or invent a negative name. An empty lookup before the declared schema exists is a retry condition, not proof of an ontology gap.
84
+
85
+ ## Typed rule lane
86
+
87
+ Use a validated `kibi.logic.v1` object for a proposition whose meaning includes a condition, exception, obligation, prohibition, permission, quantifier, cardinality bound, or bounded temporal relation. `kb_model_requirement` returns the `rule_schema` and `rule` facts plus a `requires_rule` edge. The rule stores canonical JSON and a deterministic hash; any rendered Prolog is an audit view and is never executed. Reject raw goals, function symbols, cuts, meta-calls, dynamic predicates, I/O, unsafe variables, unstratified negation, and unbounded aggregation. Keep the exact proposition in `claim_text`, its advisor key in `claim_key`, and its byte span in the semantic ledger. Run `rule-safety` and `rule-verifiability` before treating the rule as modeled.
88
+
79
89
  ### Strict scalar
80
90
 
81
91
  Claim: “Sessions expire after at most 30 minutes.” This is a scalar limit, not a predicate. Route it through `kb_model_requirement` to a subject plus `property_value` with `operator: lte`, `value_type: int`, and `value_int: 30`, linked by `constrains` and `requires_property`.