kibi-cli 0.17.0 → 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 (181) 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/coverage.d.ts +5 -0
  12. package/dist/commands/coverage.d.ts.map +1 -1
  13. package/dist/commands/coverage.js +5 -0
  14. package/dist/commands/discovery-table.d.ts.map +1 -1
  15. package/dist/commands/discovery-table.js +96 -5
  16. package/dist/commands/sync/cache.d.ts +2 -0
  17. package/dist/commands/sync/cache.d.ts.map +1 -1
  18. package/dist/commands/sync/cache.js +8 -0
  19. package/dist/commands/sync/persistence.d.ts.map +1 -1
  20. package/dist/commands/sync/persistence.js +58 -1
  21. package/dist/commands/sync.d.ts.map +1 -1
  22. package/dist/commands/sync.js +72 -15
  23. package/dist/commands/usage-metrics.d.ts +66 -2
  24. package/dist/commands/usage-metrics.d.ts.map +1 -1
  25. package/dist/commands/usage-metrics.js +34 -24
  26. package/dist/commands/usage-remediation.d.ts +9 -0
  27. package/dist/commands/usage-remediation.d.ts.map +1 -0
  28. package/dist/commands/usage-remediation.js +52 -0
  29. package/dist/extractors/markdown.d.ts +8 -0
  30. package/dist/extractors/markdown.d.ts.map +1 -1
  31. package/dist/extractors/markdown.js +69 -2
  32. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
  33. package/dist/operations/modeling/logic-modeling.js +14 -5
  34. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  35. package/dist/operations/modeling/model-requirement.js +27 -2
  36. package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
  37. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  38. package/dist/operations/modeling/predicate-applyplan.js +18 -6
  39. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
  40. package/dist/operations/modeling/predicate-inference.js +5 -17
  41. package/dist/operations/modeling/predicate-loader.js +1 -1
  42. package/dist/operations/modeling/predicate-types.d.ts +9 -1
  43. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  44. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  45. package/dist/operations/modeling/suggest-predicates.js +35 -11
  46. package/dist/operations/mutation/audit.js +1 -1
  47. package/dist/operations/mutation/contradictions.d.ts +1 -1
  48. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  49. package/dist/operations/mutation/contradictions.js +23 -18
  50. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  51. package/dist/operations/mutation/serialization.js +6 -3
  52. package/dist/operations/mutation/upsert.d.ts +3 -1
  53. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  54. package/dist/operations/mutation/upsert.js +51 -12
  55. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  56. package/dist/operations/mutation/validate-upsert.js +18 -2
  57. package/dist/operations/mutation/validation.d.ts.map +1 -1
  58. package/dist/operations/mutation/validation.js +8 -0
  59. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  60. package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
  61. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  62. package/dist/operations/semantic-advisor/analyze-prose.js +76 -61
  63. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  64. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  65. package/dist/operations/semantic-advisor/clauses.js +7 -7
  66. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
  67. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
  68. package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
  69. package/dist/operations/semantic-advisor/shared.d.ts +8 -0
  70. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  71. package/dist/operations/semantic-advisor/shared.js +37 -3
  72. package/dist/operations/semantic-advisor/types.d.ts +5 -0
  73. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  74. package/dist/prolog/codec.d.ts.map +1 -1
  75. package/dist/prolog/codec.js +9 -2
  76. package/dist/prolog.d.ts +6 -0
  77. package/dist/prolog.d.ts.map +1 -1
  78. package/dist/prolog.js +240 -61
  79. package/dist/public/diagnostic-usage.d.ts +17 -0
  80. package/dist/public/diagnostic-usage.d.ts.map +1 -0
  81. package/dist/public/diagnostic-usage.js +152 -0
  82. package/dist/public/distribution-parity.d.ts +90 -0
  83. package/dist/public/distribution-parity.d.ts.map +1 -0
  84. package/dist/public/distribution-parity.js +367 -0
  85. package/dist/public/impact/full-kb-quality.d.ts +2 -0
  86. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  87. package/dist/public/impact/full-kb-quality.js +53 -1
  88. package/dist/public/impact-diagnostics.d.ts +2 -0
  89. package/dist/public/impact-diagnostics.d.ts.map +1 -1
  90. package/dist/public/impact-diagnostics.js +1 -0
  91. package/dist/public/operations/catalog.d.ts +151 -6
  92. package/dist/public/operations/catalog.d.ts.map +1 -1
  93. package/dist/public/operations/check-executor.d.ts.map +1 -1
  94. package/dist/public/operations/check-executor.js +4 -0
  95. package/dist/public/operations/discovery-executors.d.ts +6 -0
  96. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  97. package/dist/public/operations/discovery-executors.js +18 -2
  98. package/dist/public/operations/index.d.ts +4 -0
  99. package/dist/public/operations/index.d.ts.map +1 -1
  100. package/dist/public/operations/index.js +4 -0
  101. package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
  102. package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
  103. package/dist/public/operations/legacy-migration-plan.js +409 -0
  104. package/dist/public/operations/node-ports.d.ts.map +1 -1
  105. package/dist/public/operations/node-ports.js +90 -0
  106. package/dist/public/operations/repair-plan.d.ts +184 -0
  107. package/dist/public/operations/repair-plan.d.ts.map +1 -0
  108. package/dist/public/operations/repair-plan.js +397 -0
  109. package/dist/public/operations/runtime-types.d.ts +7 -0
  110. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  111. package/dist/public/operations/specs/check.d.ts +2 -2
  112. package/dist/public/operations/specs/check.js +2 -2
  113. package/dist/public/operations/specs/discovery.d.ts +1 -1
  114. package/dist/public/operations/specs/discovery.js +1 -1
  115. package/dist/public/operations/specs/modeling.d.ts +19 -1
  116. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  117. package/dist/public/operations/specs/modeling.js +16 -1
  118. package/dist/public/operations/specs/mutation-schemas.d.ts +96 -1
  119. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  120. package/dist/public/operations/specs/mutation-schemas.js +40 -1
  121. package/dist/public/operations/specs/reporting.d.ts +42 -1
  122. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  123. package/dist/public/operations/specs/reporting.js +70 -6
  124. package/dist/public/operations/specs/semantic.js +1 -1
  125. package/dist/public/operations/specs/upsert.d.ts +96 -1
  126. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  127. package/dist/public/operations/workspace-snapshot.d.ts +10 -0
  128. package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
  129. package/dist/public/operations/workspace-snapshot.js +20 -0
  130. package/dist/public/schemas/entity.d.ts.map +1 -1
  131. package/dist/public/schemas/entity.js +43 -1
  132. package/dist/public/skills/kibi-traceability/SKILL.md +7 -1
  133. package/dist/public/skills/kibi-usage/SKILL.md +10 -4
  134. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
  135. package/dist/public/skills/kibi-usage/resources/logic-ir.md +1 -1
  136. package/dist/public/skills/kibi-usage/resources/workflows.md +19 -2
  137. package/dist/public/telemetry-acceptance.d.ts +89 -0
  138. package/dist/public/telemetry-acceptance.d.ts.map +1 -0
  139. package/dist/public/telemetry-acceptance.js +597 -0
  140. package/dist/public/telemetry-remediation.d.ts +33 -0
  141. package/dist/public/telemetry-remediation.d.ts.map +1 -0
  142. package/dist/public/telemetry-remediation.js +257 -0
  143. package/dist/public/verification-receipt.d.ts +75 -0
  144. package/dist/public/verification-receipt.d.ts.map +1 -0
  145. package/dist/public/verification-receipt.js +129 -0
  146. package/dist/schemas/entity.schema.json +96 -2
  147. package/dist/traceability/temp-kb.d.ts.map +1 -1
  148. package/dist/traceability/temp-kb.js +36 -3
  149. package/dist/types/entities.d.ts +1 -0
  150. package/dist/types/entities.d.ts.map +1 -1
  151. package/dist/utils/rule-registry.d.ts +2 -0
  152. package/dist/utils/rule-registry.d.ts.map +1 -1
  153. package/package.json +30 -2
  154. package/src/public/diagnostic-usage.ts +206 -0
  155. package/src/public/distribution-parity.ts +580 -0
  156. package/src/public/impact/full-kb-quality.ts +74 -1
  157. package/src/public/impact-diagnostics.ts +16 -0
  158. package/src/public/operations/check-executor.ts +4 -0
  159. package/src/public/operations/discovery-executors.ts +24 -2
  160. package/src/public/operations/index.ts +4 -0
  161. package/src/public/operations/legacy-migration-plan.ts +688 -0
  162. package/src/public/operations/node-ports.ts +109 -0
  163. package/src/public/operations/repair-plan.ts +562 -0
  164. package/src/public/operations/runtime-types.ts +8 -0
  165. package/src/public/operations/specs/check.ts +2 -2
  166. package/src/public/operations/specs/discovery.ts +1 -1
  167. package/src/public/operations/specs/modeling.ts +19 -1
  168. package/src/public/operations/specs/mutation-schemas.ts +47 -1
  169. package/src/public/operations/specs/reporting.ts +91 -6
  170. package/src/public/operations/specs/semantic.ts +1 -1
  171. package/src/public/operations/workspace-snapshot.ts +28 -0
  172. package/src/public/schemas/entity.ts +44 -1
  173. package/src/public/skills/kibi-traceability/SKILL.md +7 -1
  174. package/src/public/skills/kibi-usage/SKILL.md +10 -4
  175. package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
  176. package/src/public/skills/kibi-usage/resources/logic-ir.md +1 -1
  177. package/src/public/skills/kibi-usage/resources/workflows.md +19 -2
  178. package/src/public/telemetry-acceptance.ts +859 -0
  179. package/src/public/telemetry-remediation.ts +462 -0
  180. package/src/public/verification-receipt.ts +170 -0
  181. package/src/schemas/entity.schema.json +96 -2
@@ -133,7 +133,7 @@ function serializeTypedFactFields(entity) {
133
133
  }
134
134
  return fields;
135
135
  }
136
- function buildEntityAssertionGoal(entity) {
136
+ function buildEntityAssertionGoal(entity, sourceFile) {
137
137
  const props = [
138
138
  `id=${toPrologAtom(entity.id)}`,
139
139
  `title=${toPrologString(entity.title)}`,
@@ -153,12 +153,45 @@ function buildEntityAssertionGoal(entity) {
153
153
  props.push(`severity=${toPrologAtom(entity.severity)}`);
154
154
  if (entity.text_ref)
155
155
  props.push(`text_ref=${toPrologString(entity.text_ref)}`);
156
+ if (entity.type === "req" && entity.semantic_text) {
157
+ props.push(`semantic_text=${toPrologString(entity.semantic_text)}`);
158
+ }
156
159
  if (entity.type === "req" && entity.logic_claims) {
157
160
  props.push(`logic_claims=[${entity.logic_claims.map(toPrologAtom).join(",")}]`);
158
161
  }
162
+ if (entity.type === "req" && entity.semantic_clauses) {
163
+ props.push(`semantic_clauses=[${entity.semantic_clauses.map(toPrologString).join(",")}]`);
164
+ }
165
+ if (entity.type === "req" && entity.semantic_inventory_version) {
166
+ props.push(`semantic_inventory_version=${toPrologString(entity.semantic_inventory_version)}`);
167
+ }
168
+ if (entity.type === "req" && entity.semantic_source_field) {
169
+ props.push(`semantic_source_field=${toPrologString(entity.semantic_source_field)}`);
170
+ }
171
+ if (entity.type === "req" && entity.semantic_source_hash) {
172
+ props.push(`semantic_source_hash=${toPrologString(entity.semantic_source_hash)}`);
173
+ }
159
174
  if (entity.type === "req" && entity.semantic_inventory) {
160
175
  props.push(`semantic_inventory=${toPrologString(JSON.stringify(entity.semantic_inventory))}`);
161
176
  }
177
+ if (sourceFile)
178
+ props.push(`sourceFile=${toPrologString(sourceFile)}`);
179
+ if (entity.type === "symbol") {
180
+ if (entity.symbol_role)
181
+ props.push(`symbol_role=${toPrologAtom(entity.symbol_role)}`);
182
+ if (entity.granularity_reason)
183
+ props.push(`granularity_reason=${toPrologAtom(entity.granularity_reason)}`);
184
+ for (const key of [
185
+ "sourceLine",
186
+ "sourceColumn",
187
+ "sourceEndLine",
188
+ "sourceEndColumn",
189
+ ]) {
190
+ const value = entity[key];
191
+ if (typeof value === "number")
192
+ props.push(`${key}=${value}`);
193
+ }
194
+ }
162
195
  if (entity.type === "fact") {
163
196
  props.push(...serializeTypedFactFields(entity));
164
197
  }
@@ -215,11 +248,11 @@ async function consultOverlay(ctx) {
215
248
  export { consultOverlay };
216
249
  // implements REQ-014
217
250
  export async function projectStagedEntities(prolog, results) {
218
- for (const { entity } of results) {
251
+ for (const { entity, sourceFile } of results) {
219
252
  // Retract stale relationships before re-asserting entity
220
253
  // (kb_assert_entity_no_audit preserves relationships on upsert)
221
254
  await prolog.query(`kb_retract_entity_relationships('${entity.id}')`);
222
- const assertEntityResult = await prolog.query(buildEntityAssertionGoal(entity));
255
+ const assertEntityResult = await prolog.query(buildEntityAssertionGoal(entity, sourceFile));
223
256
  if (!assertEntityResult.success) {
224
257
  throw new Error(`Failed to assert staged entity ${entity.id}: ${assertEntityResult.error || "unknown error"}`);
225
258
  }
@@ -47,6 +47,7 @@ export interface TestVerificationFields {
47
47
  }
48
48
  export type Requirement = BaseEntity & {
49
49
  type: "req";
50
+ semantic_text?: string;
50
51
  logic_claims?: string[];
51
52
  };
52
53
  export type Scenario = BaseEntity & {
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAA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E,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACjD,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,MAAM,GACd,WAAW,GACX,QAAQ,GACR,UAAU,GACV,GAAG,GACH,IAAI,GACJ,KAAK,GACL,MAAM,GACN,IAAI,CAAC"}
@@ -18,6 +18,8 @@ export interface Violation {
18
18
  description: string;
19
19
  suggestion?: string;
20
20
  source?: string;
21
+ /** Exact source-bound proof evidence, when the check can produce it. */
22
+ evidence?: Readonly<Record<string, unknown>>;
21
23
  }
22
24
  export interface ChecksConfig {
23
25
  rules: Record<string, boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"rule-registry.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,cAAc,CAAC;CACnE;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC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AAE,OAAO,CAAC,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,kBAAkB,EAAE,yBAAyB,CAAC;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,cAAc,EAsHjC,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU,aAAoC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAKnC,CAAC;AAEF;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAC/B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,GAChB,GAAG,CAAC,MAAM,CAAC,CAsBb;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC9B,YAAY,CAWd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-cli",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "type": "module",
5
5
  "description": "Kibi CLI for knowledge base management",
6
6
  "engines": {
@@ -34,6 +34,14 @@
34
34
  "types": "./dist/public/operations/runtime-types.d.ts",
35
35
  "default": "./dist/public/operations/runtime-types.js"
36
36
  },
37
+ "./operations/node-ports": {
38
+ "types": "./dist/public/operations/node-ports.d.ts",
39
+ "default": "./dist/public/operations/node-ports.js"
40
+ },
41
+ "./verification-receipt": {
42
+ "types": "./dist/public/verification-receipt.d.ts",
43
+ "default": "./dist/public/verification-receipt.js"
44
+ },
37
45
  "./operations/semantic-advisor/analyze-prose": {
38
46
  "types": "./dist/operations/semantic-advisor/analyze-prose.d.ts",
39
47
  "default": "./dist/operations/semantic-advisor/analyze-prose.js"
@@ -90,6 +98,26 @@
90
98
  "types": "./dist/public/impact-diagnostics.d.ts",
91
99
  "default": "./dist/public/impact-diagnostics.js"
92
100
  },
101
+ "./telemetry-acceptance": {
102
+ "types": "./dist/public/telemetry-acceptance.d.ts",
103
+ "default": "./dist/public/telemetry-acceptance.js"
104
+ },
105
+ "./telemetry-remediation": {
106
+ "types": "./dist/public/telemetry-remediation.d.ts",
107
+ "default": "./dist/public/telemetry-remediation.js"
108
+ },
109
+ "./diagnostic-usage": {
110
+ "types": "./dist/public/diagnostic-usage.d.ts",
111
+ "default": "./dist/public/diagnostic-usage.js"
112
+ },
113
+ "./distribution-parity": {
114
+ "types": "./dist/public/distribution-parity.d.ts",
115
+ "default": "./dist/public/distribution-parity.js"
116
+ },
117
+ "./legacy-migration-plan": {
118
+ "types": "./dist/public/operations/legacy-migration-plan.d.ts",
119
+ "default": "./dist/public/operations/legacy-migration-plan.js"
120
+ },
93
121
  "./public/symbol-granularity": {
94
122
  "types": "./dist/public/symbol-granularity.d.ts",
95
123
  "default": "./dist/public/symbol-granularity.js"
@@ -161,7 +189,7 @@
161
189
  "fast-glob": "^3.2.12",
162
190
  "gray-matter": "^4.0.3",
163
191
  "js-yaml": "^4.1.0",
164
- "kibi-core": "^0.8.0",
192
+ "kibi-core": "^0.9.1",
165
193
  "ts-morph": "^23.0.0",
166
194
  "ignore": "^5.3.0"
167
195
  },
@@ -0,0 +1,206 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { appendFileSync, mkdirSync } from "node:fs";
3
+ import path from "node:path";
4
+
5
+ export interface DiagnosticUsageInput {
6
+ readonly workspaceRoot: string;
7
+ readonly tool: string;
8
+ readonly businessArgs: Readonly<Record<string, unknown>>;
9
+ readonly telemetry: Readonly<Record<string, unknown>> | null;
10
+ readonly startedAt: Date;
11
+ readonly finishedAt?: Date;
12
+ readonly status: "success" | "error";
13
+ readonly result?: unknown;
14
+ readonly error?: string;
15
+ readonly requestId?: string;
16
+ readonly logPath?: string;
17
+ }
18
+
19
+ function isRecord(value: unknown): value is Record<string, unknown> {
20
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
21
+ }
22
+
23
+ function resultRecord(result: unknown): Record<string, unknown> | undefined {
24
+ if (!isRecord(result)) return undefined;
25
+ return isRecord(result.structuredContent) ? result.structuredContent : result;
26
+ }
27
+
28
+ function stringArray(value: unknown): string[] {
29
+ return Array.isArray(value)
30
+ ? value.filter((item): item is string => typeof item === "string")
31
+ : [];
32
+ }
33
+
34
+ function canonicalValue(value: unknown): unknown {
35
+ if (Array.isArray(value)) return value.map(canonicalValue);
36
+ if (!isRecord(value)) return value;
37
+ return Object.fromEntries(
38
+ Object.entries(value)
39
+ .filter(([key]) => key !== "_diagnostic_telemetry")
40
+ .sort(([left], [right]) => left.localeCompare(right))
41
+ .map(([key, child]) => [key, canonicalValue(child)]),
42
+ );
43
+ }
44
+
45
+ export function diagnosticMutationFingerprint(
46
+ args: Readonly<Record<string, unknown>>,
47
+ ): string {
48
+ return createHash("sha256")
49
+ .update(JSON.stringify(canonicalValue(args)))
50
+ .digest("hex");
51
+ }
52
+
53
+ function appendMutationFields(
54
+ fields: Record<string, unknown>,
55
+ args: Readonly<Record<string, unknown>>,
56
+ ): void {
57
+ fields.mutation_fingerprint = diagnosticMutationFingerprint(args);
58
+ const type = typeof args.type === "string" ? args.type : "unknown";
59
+ const id = typeof args.id === "string" ? args.id : "unknown";
60
+ fields.mutation_target = `${type}:${id}`;
61
+ }
62
+
63
+ function appendSemanticFields(
64
+ fields: Record<string, unknown>,
65
+ receipt: unknown,
66
+ ): void {
67
+ if (!isRecord(receipt)) return;
68
+ const inventory = isRecord(receipt.inventory_contract)
69
+ ? receipt.inventory_contract
70
+ : undefined;
71
+ if (typeof inventory?.source_hash === "string") {
72
+ fields.semantic_source_hash = inventory.source_hash;
73
+ }
74
+ if (typeof receipt.logic_readiness === "string") {
75
+ fields.semantic_logic_readiness = receipt.logic_readiness;
76
+ }
77
+ if (typeof receipt.candidate_lane === "string") {
78
+ fields.semantic_candidate_lane = receipt.candidate_lane;
79
+ }
80
+ }
81
+
82
+ const RECEIPT_GAP_CODES = new Set([
83
+ "missing_verification_receipt",
84
+ "stale_verification_receipt",
85
+ "failed_verification_receipt",
86
+ "invalid_verification_receipt",
87
+ "verification_snapshot_unavailable",
88
+ ]);
89
+
90
+ function appendCoverageFields(
91
+ fields: Record<string, unknown>,
92
+ args: Readonly<Record<string, unknown>>,
93
+ result: Record<string, unknown>,
94
+ ): void {
95
+ const rows = Array.isArray(result.rows) ? result.rows.filter(isRecord) : [];
96
+ const summary = isRecord(result.summary) ? result.summary : {};
97
+ const gapCodes = rows.flatMap((row) => stringArray(row.proofGaps));
98
+ const repairPlan = isRecord(result.repairPlan)
99
+ ? result.repairPlan
100
+ : undefined;
101
+ const scope = isRecord(repairPlan?.scope) ? repairPlan.scope : undefined;
102
+ fields.coverage_by = typeof args.by === "string" ? args.by : "req";
103
+ fields.coverage_requirement_count = Number(summary.total ?? rows.length);
104
+ fields.coverage_proven_count = Number(summary.proofProven ?? 0);
105
+ fields.coverage_proof_missing_count = Number(summary.proofMissing ?? 0);
106
+ fields.coverage_proof_gap_count = gapCodes.length;
107
+ fields.coverage_gap_codes = [...new Set(gapCodes)].sort();
108
+ fields.coverage_receipt_gap_count = gapCodes.filter((code) =>
109
+ RECEIPT_GAP_CODES.has(code),
110
+ ).length;
111
+ if (typeof scope?.complete === "boolean") {
112
+ fields.coverage_scope_complete = scope.complete;
113
+ }
114
+ }
115
+
116
+ export function deriveDiagnosticUsageFields(
117
+ tool: string,
118
+ args: Readonly<Record<string, unknown>>,
119
+ telemetry: Readonly<Record<string, unknown>> | null,
120
+ result: unknown,
121
+ ): Record<string, unknown> {
122
+ const fields: Record<string, unknown> = {
123
+ telemetry_status: telemetry ? "provided" : "missing",
124
+ };
125
+ if (telemetry) {
126
+ fields.telemetry_is_autonomous = telemetry.is_autonomous ?? null;
127
+ fields.telemetry_confidence_score = telemetry.confidence_score ?? null;
128
+ fields.telemetry_attempt_number = telemetry.attempt_number ?? null;
129
+ if (typeof telemetry.session_id === "string") {
130
+ fields.session_id = telemetry.session_id;
131
+ }
132
+ if (typeof telemetry.actor_id === "string") {
133
+ fields.actor_id = telemetry.actor_id;
134
+ }
135
+ }
136
+
137
+ const structured = resultRecord(result);
138
+ if (tool === "kb_query" || tool === "kb_search") {
139
+ const resultCount = Number(structured?.count ?? 0);
140
+ fields.result_count = resultCount;
141
+ fields.zero_results = resultCount === 0;
142
+ fields.result_summary =
143
+ resultCount === 0 ? "0 results" : `${resultCount} results`;
144
+ }
145
+ if (tool === "kb_check") {
146
+ const count = Number(structured?.count ?? 0);
147
+ fields.violation_count = count;
148
+ fields.requested_rules = Array.isArray(args.rules) ? args.rules : [];
149
+ fields.result_summary =
150
+ count === 0 ? "0 violations" : `${count} violations`;
151
+ }
152
+ if (tool === "kb_coverage" && structured) {
153
+ appendCoverageFields(fields, args, structured);
154
+ fields.result_summary = `${String(
155
+ fields.coverage_proven_count,
156
+ )} proven; ${String(fields.coverage_proof_gap_count)} proof gaps`;
157
+ }
158
+ if (tool === "kb_semantic_advisor" && structured) {
159
+ appendSemanticFields(fields, structured.receipt);
160
+ }
161
+ if (tool === "kb_validate_upsert") {
162
+ appendMutationFields(fields, args);
163
+ fields.validation_valid = structured?.valid === true;
164
+ appendSemanticFields(fields, structured?.semanticAdvisor);
165
+ }
166
+ if (tool === "kb_upsert") {
167
+ appendMutationFields(fields, args);
168
+ appendSemanticFields(fields, structured?.semanticAdvisor);
169
+ }
170
+ if (!fields.result_summary) fields.result_summary = `${tool} completed`;
171
+ return fields;
172
+ }
173
+
174
+ export function appendCliDiagnosticUsage(input: DiagnosticUsageInput): void {
175
+ const finishedAt = input.finishedAt ?? new Date();
176
+ const requestId = input.requestId ?? `cli-${randomUUID()}`;
177
+ const logPath =
178
+ input.logPath ??
179
+ process.env.KIBI_CLI_DIAGNOSTIC_USAGE_LOG_PATH ??
180
+ path.join(input.workspaceRoot, ".kb", "usage.log");
181
+ mkdirSync(path.dirname(logPath), { recursive: true });
182
+ appendFileSync(
183
+ logPath,
184
+ `${JSON.stringify({
185
+ timestamp: finishedAt.toISOString(),
186
+ request_id: requestId,
187
+ tool: input.tool,
188
+ interface: "cli_json",
189
+ telemetry: input.telemetry,
190
+ business_args: input.businessArgs,
191
+ status: input.status,
192
+ started_at: input.startedAt.toISOString(),
193
+ finished_at: finishedAt.toISOString(),
194
+ duration_ms: finishedAt.getTime() - input.startedAt.getTime(),
195
+ active_branch: process.env.KIBI_BRANCH ?? null,
196
+ ...(input.error ? { error_message: input.error } : {}),
197
+ ...deriveDiagnosticUsageFields(
198
+ input.tool,
199
+ input.businessArgs,
200
+ input.telemetry,
201
+ input.result,
202
+ ),
203
+ })}\n`,
204
+ "utf8",
205
+ );
206
+ }