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
@@ -0,0 +1,43 @@
1
+ # Typed Logic IR and Proposition Coverage
2
+
3
+ Kibi stores human prose as readable requirement text, but verifiable meaning belongs in typed facts and `kibi.logic.v1` rule facts. The host agent may propose an interpretation; Kibi validates, canonicalizes, hashes, persists, and reasons over it. Never submit a Prolog source string, goal, module, or function symbol. Rendered Prolog is an inspection preview only.
4
+
5
+ ## Two-pass extraction
6
+
7
+ 1. Run `kb_semantic_advisor` over the complete text. Supply explicit `clauses` when sentence splitting could hide a condition, exception, definition, descriptive assertion, threshold, quantity, or temporal qualifier.
8
+ 2. Audit the returned `propositions` against the original UTF-8 text. Every assertive span must be `modeled`, `ambiguous`, `ontology_gap`, or `missing`; rationale, examples, and subjective commentary are `nonlogical` and remain readable prose.
9
+ 3. For each assertive proposition, submit up to three typed `interpretations` when alternatives are plausible. Kibi compares canonical semantic keys; materially different valid interpretations remain unresolved regardless of confidence.
10
+ 4. Apply only a validated plan, then read back the requirement, rule schema, rule fact, and all relationship targets. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions` before the final unfiltered check.
11
+
12
+ When a project-local schema names several ordered arguments, those arguments are facets of one relation, not separate propositions. Preserve the advisor claim key for the complete relation and do not manufacture clauses for each argument. Supporting `predicate_schema` facts carry the declared signature only; the ground predicate fact carries the claim provenance. Apply the exact `kb_suggest_predicates`/`kb_model_requirement` plan, reducing a rejected schema payload through `kb_validate_upsert` rather than silently downgrading a fitting declared relation to an observation.
13
+
14
+ ## Logic IR shape
15
+
16
+ The supported v1 forms are:
17
+
18
+ - `kind: atom` with a ground `head`;
19
+ - `kind: rule` with a range-restricted `head` and `body`;
20
+ - `kind: constraint` with a body and no head.
21
+
22
+ Terms are typed `const`, `var`, `number`, `duration`, or ISO `timestamp`. Variables are explicitly declared as `forall` (the default) or body-local `exists`; an existential variable may not occur in a rule head. Bodies use `all`, `any`, closed-world `not`, comparisons, bounded `count`, and bounded temporal expressions. Modalities are `assert`, `deny`, `oblige`, `permit`, and `forbid`.
23
+
24
+ Every head and body variable must be bound by a positive atom. Negation is allowed only on an atom with `closedWorld: true`, and only when its variables are also positively bound. Function symbols, raw goals, cuts, meta-calls, dynamic predicates, I/O, unbounded aggregation, unsafe variables, and unstratified negation are rejected before persistence.
25
+
26
+ Example (inspection data, not executable input):
27
+
28
+ ```json
29
+ {
30
+ "version": "kibi.logic.v1",
31
+ "kind": "rule",
32
+ "modality": "oblige",
33
+ "variables": [{"name": "U", "type": "user", "quantifier": "forall"}],
34
+ "head": {"kind": "atom", "name": "audit", "args": [{"kind": "var", "name": "U", "type": "user"}]},
35
+ "body": {"kind": "atom", "name": "admin_action", "args": [{"kind": "var", "name": "U", "type": "user"}]}
36
+ }
37
+ ```
38
+
39
+ Use `rule_schema` facts for stable predicate signatures and link a requirement to a `rule` fact with `requires_rule`. Keep `logic_claims` as the exact current assertive key set; `semantic_inventory` is the complete proposition ledger, anchored by `semantic_inventory_version`, `semantic_source_field`, and `semantic_source_hash`. Prefer requirement-only `semantic_text` as the semantic source for normalized authored prose so `text_ref` can remain independent code or document evidence; retain `text_ref` and `title` only as legacy semantic-source choices. A manifest is not proof until each modeled key is linked to exactly one same-key fact and the rule checks pass.
40
+
41
+ ## Contradictions and uncertainty
42
+
43
+ Kibi compares opposing modalities over matching heads and overlapping authority, scope, and validity intervals. `assert`/`deny`, `oblige`/`forbid`, and overlapping `permit`/`forbid` pairs can be contradictory. Different conditions, unresolved interpretations, unsupported ontology terms, analysis limits, and incomplete closure produce `unresolved`, never a false consistency proof. Preserve superseding requirements rather than deleting historical claims.
@@ -2,26 +2,26 @@
2
2
 
3
3
  This table is the machine-readable interface map for Kibi's shared operation catalog. Every CLI route shown is dedicated; there is no generic operation runner. `--input JSON or flags` means the route supports exact MCP-shaped JSON from a file or stdin as well as its established human flags. `--input JSON` means the dedicated parity route is JSON-only.
4
4
 
5
- | MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects | Capability preference |
5
+ | MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects | Interface |
6
6
  |---|---|---|---|---|---|---|
7
- | `kb_skills_list` | `skills-list` | `--input JSON` | read | no | `local-read` | MCP-first; CLI-fallback |
8
- | `kb_skills_load` | `skills-load` | `--input JSON` | read | no | `local-read` | MCP-first; CLI-fallback |
9
- | `kb_skills_read` | `skills-read` | `--input JSON` | read | no | `local-read` | MCP-first; CLI-fallback |
10
- | `kb_query` | `query` | `--input JSON or flags` | read | yes | `kb-read` | MCP-first; CLI-fallback |
11
- | `kb_search` | `search` | `--input JSON or flags` | read | yes | `kb-read` | MCP-first; CLI-fallback |
12
- | `kb_status` | `status` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` | MCP-first; CLI-fallback |
13
- | `kb_find_gaps` | `find-gaps` | `--input JSON or flags` | read | yes | `kb-read` | MCP-first; CLI-fallback |
14
- | `kb_coverage` | `coverage` | `--input JSON or flags` | read | yes | `kb-read` | MCP-first; CLI-fallback |
15
- | `kb_graph` | `graph` | `--input JSON or flags` | read | yes | `kb-read` | MCP-first; CLI-fallback |
16
- | `kb_semantic_advisor` | `semantic-advisor` | `--input JSON` | read | no | `local-read` | MCP-first; CLI-fallback |
17
- | `kb_model_requirement` | `model-requirement` | `--input JSON` | read | yes | `kb-read` | MCP-first; CLI-fallback |
18
- | `kb_suggest_predicates` | `suggest-predicates` | `--input JSON` | read | yes | `kb-read` | MCP-first; CLI-fallback |
19
- | `kb_autopilot_generate` | `autopilot-generate` | `--input JSON` | read | no | `workspace-read` | MCP-first; CLI-fallback |
20
- | `kb_validate_upsert` | `validate-upsert` | `--input JSON` | read | yes | `kb-read` | MCP-first; CLI-fallback |
21
- | `kb_upsert` | `upsert` | `--input JSON` | write | yes | `kb-write, workspace-write` | MCP-first; CLI-fallback |
22
- | `kb_delete` | `delete` | `--input JSON` | write | yes | `kb-write, workspace-write` | MCP-first; CLI-fallback |
23
- | `kb_check` | `check` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` | MCP-first; CLI-fallback |
24
- | `kb_sparql_remote` | `sparql-remote` | `--input JSON` | read | no | `network-read` | MCP-first; CLI-fallback |
7
+ | `kb_skills_list` | `skills-list` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
8
+ | `kb_skills_load` | `skills-load` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
9
+ | `kb_skills_read` | `skills-read` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
10
+ | `kb_query` | `query` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
11
+ | `kb_search` | `search` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
12
+ | `kb_status` | `status` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` | peer; capability-selected |
13
+ | `kb_find_gaps` | `find-gaps` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
14
+ | `kb_coverage` | `coverage` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
15
+ | `kb_graph` | `graph` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
16
+ | `kb_semantic_advisor` | `semantic-advisor` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
17
+ | `kb_model_requirement` | `model-requirement` | `--input JSON` | read | yes | `kb-read` | peer; capability-selected |
18
+ | `kb_suggest_predicates` | `suggest-predicates` | `--input JSON` | read | yes | `kb-read` | peer; capability-selected |
19
+ | `kb_autopilot_generate` | `autopilot-generate` | `--input JSON` | read | no | `workspace-read` | peer; capability-selected |
20
+ | `kb_validate_upsert` | `validate-upsert` | `--input JSON` | read | yes | `kb-read` | peer; capability-selected |
21
+ | `kb_upsert` | `upsert` | `--input JSON` | write | yes | `kb-write, workspace-write` | peer; capability-selected |
22
+ | `kb_delete` | `delete` | `--input JSON` | write | yes | `kb-write, workspace-write` | peer; capability-selected |
23
+ | `kb_check` | `check` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` | peer; capability-selected |
24
+ | `kb_sparql_remote` | `sparql-remote` | `--input JSON` | read | no | `network-read` | peer; capability-selected |
25
25
 
26
26
  ## JSON execution recipes
27
27
 
@@ -0,0 +1,96 @@
1
+ # UI / Visual Requirement Modeling
2
+
3
+ Optional, per-project lane for recording what the screen should look like so UI edits cannot
4
+ silently drift from the spec. Non-UI projects skip it entirely; no check rule requires it.
5
+
6
+ ## Three layers
7
+
8
+ 1. **Prose `req`** — the full on-screen description lives in the requirement body as the
9
+ searchable anchor agents discover with `kb_search` / `kb_query`.
10
+ 2. **Strict facts** — checkable visual invariants as `fact_kind: subject` (`subject_key`,
11
+ linked `constrains`) plus `fact_kind: property_value` (`property_key`, `operator`, typed
12
+ `value_*`, linked `requires_property`). Incompatible values on the same subject/property
13
+ from two current requirements are rejected on write unless `supersedes`.
14
+ 3. **Relational predicates** — ground `fact_kind: predicate` linked with `requires_predicate`.
15
+ The built-in `visual_layout_rule(subject, relation, target)` covers "X must remain visually
16
+ aligned with Y" (relation `aligned_with`). Other relational layout claims need a
17
+ project-local `predicate_schema` when the task authorizes ontology extension.
18
+
19
+ Kibi enforces stated facts and links, not pixels. Freeform spatial prose is stored and
20
+ searchable but is not machine-checked.
21
+
22
+ ## Button position
23
+
24
+ ```yaml
25
+ id: FACT-UI-SUBMIT-REGION
26
+ fact_kind: subject
27
+ subject_key: settings.screen.submit_button
28
+ ```
29
+
30
+ ```yaml
31
+ id: FACT-UI-SUBMIT-POSITION
32
+ fact_kind: property_value
33
+ subject_key: settings.screen.submit_button
34
+ property_key: position
35
+ operator: eq
36
+ value_type: string
37
+ value_string: bottom_right
38
+ canonical_key: settings.screen.submit_button.position.eq.bottom_right
39
+ ```
40
+
41
+ Link both facts from the requirement:
42
+
43
+ ```yaml
44
+ id: REQ-UI-SETTINGS
45
+ relationships:
46
+ - type: constrains
47
+ from: REQ-UI-SETTINGS
48
+ to: FACT-UI-SUBMIT-REGION
49
+ - type: requires_property
50
+ from: REQ-UI-SETTINGS
51
+ to: FACT-UI-SUBMIT-POSITION
52
+ ```
53
+
54
+ A later requirement writing `position: top_left` on the same subject is rejected on write.
55
+
56
+ ## Header item order
57
+
58
+ Use one indexed `property_key` per slot against the same subject region:
59
+ `nav_order_1: home`, `nav_order_2: search`, `nav_order_3: profile`, each as a separate
60
+ `property_value` fact linked with `requires_property`. This makes each slot independently
61
+ contradiction-checkable.
62
+
63
+ ## Relational alignment
64
+
65
+ ```yaml
66
+ id: FACT-UI-NAV-ALIGN
67
+ fact_kind: predicate
68
+ predicate_name: visual_layout_rule
69
+ predicate_args: [navigation_rail, aligned_with, header]
70
+ polarity: assert
71
+ canonical_key: visual_layout_rule(navigation_rail,aligned_with,header)
72
+ ```
73
+
74
+ Link with `requires_predicate`. An `assert`/`deny` pair over the same predicate namespace,
75
+ name, and ordered arguments is a blocking `domain-contradictions` conflict.
76
+
77
+ ## UI component traceability
78
+
79
+ Model the component as a `symbol` with `sourceFile` and `symbol_role: behavioral`, linked
80
+ `implements` to the requirement, so component edits surface the visual spec in impact
81
+ diagnostics (`symbol_semantic_review_needed`).
82
+
83
+ ## Workflow
84
+
85
+ 1. `kb_semantic_advisor` on the full description; audit or supply `clauses`.
86
+ 2. Relational clauses: `kb_suggest_predicates`, apply the predicate plan and
87
+ `requires_predicate`.
88
+ 3. Scalar placement/alignment/order clauses: `kb_model_requirement`, apply the strict
89
+ subject/property plan and `constrains` / `requires_property`.
90
+ 4. Preserve `claim_key` / `claim_text`; merge every key into the requirement
91
+ `logic_claims` manifest.
92
+ 5. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`.
93
+ 6. `kb_check` with `logic-coverage`, `predicate-verifiability`, `domain-contradictions`,
94
+ then a final unfiltered `kb_check`.
95
+
96
+ Non-UI projects: declare `has_ui: false` during bootstrap and no UI entities are proposed.
@@ -8,13 +8,20 @@ The canonical workflow for any KB operation follows this pattern:
8
8
  2. **Confirm**: `kb_query` for exact IDs and state
9
9
  3. **Inspect**: `kb_status` when freshness matters
10
10
  4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
11
- 5. **Choose per-clause lanes**: `kb_suggest_predicates` for relational clauses; `kb_model_requirement` for strict scalar clauses; observation review for ambiguity, false positives, and ontology gaps
11
+ 5. **Choose per-clause lanes**: strict facts for scalar claims; `kb_suggest_predicates` for approved ground ontology relations; `kb_model_requirement` with `kibi.logic.v1` for conditions, exceptions, modalities, quantifiers, cardinality, and bounded temporal rules; observation review for ambiguity, nonlogical prose, and ontology gaps
12
12
  6. **Preflight**: `kb_validate_upsert` for every intended entity or relationship payload
13
13
  7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
14
- 8. **Link**: validated `kb_upsert` with `requires_predicate`, `constrains`, or `requires_property`, sequentially
15
- 9. **Validate coverage and consistency**: targeted `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then final full `kb_check`
14
+ 8. **Link**: validated `kb_upsert` with `requires_rule`, `requires_predicate`, `constrains`, or `requires_property`, sequentially
15
+ 9. **Validate coverage and consistency**: targeted `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then final full `kb_check`
16
+ 10. **Prove execution**: read `kb_status.verificationSnapshot`, run each scenario-backed E2E command, append its `kibi.verification-receipt.v1`, and re-run `kb_coverage`; never promote durable test status into fresh evidence
17
+ 11. **Repair incrementally**: require `kb_coverage.repairPlan.scope.complete`, apply only one `ready` dependency batch per requirement, validate before every sequential write, and rerun coverage before selecting the next batch
18
+ 12. **Gate workflow evidence**: when `.kb/usage.log` exists, run `kibi usage-metrics --format json --require-acceptance`; repair ranked telemetry diagnostics and never treat stale or insufficient evidence as a pass
16
19
 
17
- Every current requirement without `logic_claims` remains visible as non-blocking backfill debt. Once a manifest exists, the default unfiltered check enforces its correspondence to linked ground facts.
20
+ Every current requirement without `logic_claims` remains visible as non-blocking backfill debt. Once a manifest and `semantic_inventory` exist, the unfiltered check enforces correspondence to linked ground facts/rules and rejects silently missing assertive propositions.
21
+
22
+ `kibi.repair-plan.v1` is a deterministic read-only plan, not a mutation script. Its phase order keeps source and proposition analysis ahead of ground endpoints, endpoints ahead of manifests/links, logic ahead of contradictions, scenarios ahead of tests and receipts, and production ownership ahead of coverage and coordinate refresh. A `blocked` batch is waiting on every listed `dependsOn` batch. If pagination makes the plan partial, increase the requirement coverage limit rather than applying an incomplete project view.
23
+
24
+ `kibi.telemetry-acceptance.v1` evaluates the latest 200 usage events and keeps process health separate from graph correctness. It requires at least 95% complete diagnostic telemetry and, when applicable, exact recent validation before every upsert and a same-requirement/current-hash advisor pass before requirement writes. It also evaluates source lookup misses, comparable complete-scope proof-gap recovery, receipt-specific coverage gaps, and mutation targets retried three or more times. Failed metrics become ranked `category: telemetry` quality diagnostics; missing current coverage fields or evidence older than seven days stays `insufficient_evidence`.
18
25
 
19
26
  ## Creating a New Feature
20
27
  ```
@@ -38,17 +45,28 @@ Every current requirement without `logic_claims` remains visible as non-blocking
38
45
 
39
46
  Do not create a test-fact pair. Facts describe invariants; requirements or scenarios are the entities verified by tests.
40
47
 
48
+ ## Fresh E2E Receipt Workflow
49
+
50
+ 1. Confirm the exact `REQ -> SCEN -> TEST` path and require typed `verification_scope: end_to_end`; direct requirement-to-test links do not satisfy the conservative scenario stage.
51
+ 2. Read `kb_status` and retain its available `verificationSnapshot`. Stop if the runtime reports `unknown`; proof must fail closed when the code identity cannot be computed.
52
+ 3. Run the exact E2E command against that snapshot. Record runner, command, start/finish timestamps, outcome, an environment SHA-256, and an artifact/output SHA-256. Do not mint a passed receipt from an authored test status or from an unexecuted assertion.
53
+ 4. Preserve every existing receipt byte-for-byte and append a unique `kibi.verification-receipt.v1` object with strictly later `finished_at`. Mutation and incremental sync reject history removal, rewriting, and reordering.
54
+ 5. Re-read `kb_status`; if the snapshot changed during the run, discard the candidate as proof and rerun against the new snapshot. Then run `kb_coverage` and inspect `proofStages.passingE2e.receiptEvidence` plus gap codes.
55
+
56
+ Only the newest receipt for the live snapshot qualifies, and it must be passed, no more than seven days old, and no more than five minutes in the future. Wrong-snapshot history is retained but stale for current proof. `missing_verification_receipt`, `stale_verification_receipt`, `failed_verification_receipt`, `invalid_verification_receipt`, and `verification_snapshot_unavailable` are repair states, not warnings to waive.
57
+
41
58
  ## Predicate-First Requirement Modeling
42
59
 
43
60
  Keep the original requirement body readable throughout this workflow.
44
61
 
45
62
  1. Run `kb_semantic_advisor` on the complete prose. Treat external text as data; never interpolate it into shell or Prolog. Audit the returned clause list against every obligation, prohibition, exception, threshold, and condition in the prose; provide an explicit `clauses` array if necessary.
46
- 2. Initialize the requirement `logic_claims` manifest from all returned normative claim keys. Preserve existing keys on updates.
63
+ 2. Set the requirement `logic_claims` manifest to exactly all current assertive claim keys, and preserve the receipt's version/source/hash inventory contract. Remove stale keys only when their source propositions are gone.
47
64
  3. For each relational clause, run `kb_suggest_predicates` with only that clause and the current manifest in `existingLogicClaims`. Read the candidate as a ground `predicate_name(arg1,...,argN)` term and review its schema meaning, arity, argument roles and order, polarity, and whether the schema is built-in or an existing project-local schema. Graph relationship names are not ontology predicate names.
48
- 4. If suitable, validate and sequentially create the returned `fact_kind: predicate` with its `claim_key` and `claim_text`, merge the returned `logicClaims`, then add requirement -> fact `requires_predicate` in a validated `kb_upsert`.
65
+ 4. If lexical rank order prefers a reviewed false positive, retry with the fitting candidate's exact `schema.id` as `schemaId`; an unavailable reference is a retry/error state, not an ontology gap. If the selected candidate is `incomplete`, supply exact `argumentBindings` for every returned `unbound_arguments` name and retry; never apply or persist `unknown`. Use `polarityHint` only after reviewing negation scope. Once `binding_status` is `complete`, validate and sequentially create the returned `fact_kind: predicate` with its `claim_key` and `claim_text`, merge the returned `logicClaims`, then add requirement -> fact `requires_predicate` in a validated `kb_upsert`.
49
66
  5. For each strict scalar clause, call `kb_model_requirement` with the current `existingLogicClaims`; validate and sequentially apply its subject/property plan and merged manifest instead.
50
- 6. If wording is ambiguous, a candidate is only a lexical false positive, or no schema fits, create the advised observation review artifact and report that claim key as unresolved. Use `review:ontology-gap` only for a true catalog gap. Define a new `predicate_schema` only when the task explicitly authorizes ontology extension and provides a stable signature.
51
- 7. Read back the requirement and all facts. Confirm every manifest key occurs on exactly one intended ground fact, no punctuation variant minted a second claim, and no two claim keys encode the same logical term. Exact query output may represent repeated relationship types as arrays, so inspect every target. Then run `kb_check` with `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`. Finish with an unfiltered `kb_check`.
67
+ 6. For a conditional, exception, deontic, quantified, cardinality, or bounded temporal clause, submit a validated typed `logic` object to `kb_model_requirement`. Apply its `rule_schema` and `rule` facts sequentially and link the requirement with `requires_rule`; rendered Prolog is for inspection only.
68
+ 7. If wording is ambiguous, a candidate is only a lexical false positive, or no schema/IR interpretation fits, create the advised observation review artifact and apply its returned `relates_to` review anchor when present; report that claim key as unresolved. Use `review:ambiguity` for unresolved interpretation, `review:keyword-false-positive` for a vocabulary match that is not a domain assertion, and `review:ontology-gap` only for a true catalog gap. Define a new `predicate_schema` only when the task explicitly authorizes ontology extension and provides a stable signature.
69
+ 8. Read back the requirement, proposition ledger, and all facts. Confirm every manifest key occurs on exactly one intended ground fact/rule, no punctuation variant minted a second claim, and no two claim keys encode the same logical term. Exact query output may represent repeated relationship types as arrays, so inspect every target. Then run `kb_check` with `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`. Finish with an unfiltered `kb_check`.
52
70
 
53
71
  Do not treat the manifest itself as proof of grounding. The advisor keeps readiness partial while there are fewer logical edge slots than normative claims; final readback and `logic-coverage` bind those slots to exact claim keys and ground terms.
54
72
 
@@ -56,6 +74,20 @@ Examples: built-in permission and deny claims use the suggested `permission_rule
56
74
 
57
75
  On resume after interruption, repeat `kb_query` for exact endpoints and apply only missing validated writes. Keep `kb_upsert` concurrency at one.
58
76
 
77
+ ## UI / Visual Requirement Modeling
78
+
79
+ Optional per-project workflow for recording what the screen should look like. Non-UI projects skip this lane entirely.
80
+
81
+ 1. Create a prose `req` holding the full visual description; it is the searchable anchor agents discover before touching a UI file.
82
+ 2. Run `kb_semantic_advisor` on the description; audit or supply `clauses`.
83
+ 3. For relational layout clauses ("X must remain visually aligned with Y"), call `kb_suggest_predicates`, apply the returned `fact_kind: predicate` plan with `predicate_name: visual_layout_rule` and `requires_predicate`.
84
+ 4. For scalar placement, alignment, and ordering clauses, call `kb_model_requirement` and apply strict `fact_kind: subject` / `fact_kind: property_value` facts linked with `constrains` / `requires_property`. Model header order as indexed property keys (`nav_order_1`, `nav_order_2`, ...) against one subject region.
85
+ 5. Preserve `claim_key` / `claim_text` on every ground fact and merge every key into the requirement `logic_claims` manifest.
86
+ 6. Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement.
87
+ 7. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`. Run `kb_check` with `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then a final unfiltered `kb_check`.
88
+
89
+ Incompatible values on the same subject/property from two current requirements are rejected on write; change an intentional value via a replacement requirement linked with `supersedes`. Full payloads are in `resources/ui-requirements.md`.
90
+
59
91
  ## Fixing a Traceability Gap
60
92
  ```
61
93
  1. kb_query --sourceFile <code-file> to find linked entities
@@ -4,6 +4,14 @@ export declare const TRACEABILITY_RELATIONSHIP_TYPES: readonly ["implements", "c
4
4
  export type TraceabilityRelationshipType = (typeof TRACEABILITY_RELATIONSHIP_TYPES)[number];
5
5
  export declare const ALLOWED_GRANULARITY_REASONS: readonly ["config-artifact", "module-level-behavior", "extractor-miss", "legacy-link"];
6
6
  export type GranularityReason = (typeof ALLOWED_GRANULARITY_REASONS)[number];
7
+ /**
8
+ * Granularity reasons that document coarse file/module-level coverage for which
9
+ * generated per-symbol coordinates are not expected. These anchors legitimately
10
+ * carry no coordinate artifact entries. `legacy-link` is intentionally excluded:
11
+ * it is a canonical reason but still coordinates a real extractable symbol.
12
+ */
13
+ export declare const COARSE_GRANULARITY_REASONS: readonly ["config-artifact", "module-level-behavior", "extractor-miss", "test-suite"];
14
+ export type CoarseGranularityReason = (typeof COARSE_GRANULARITY_REASONS)[number];
7
15
  export type SymbolKind = "function" | "class" | "method" | "property" | "accessor" | "interface" | "type" | "variable" | "enum" | "unknown";
8
16
  export type SourceSymbolKind = SymbolKind;
9
17
  export interface GranularSymbolCandidate {
@@ -16,6 +24,7 @@ export declare const inferSymbolRoleFromKind: typeof inferSymbolRole;
16
24
  export declare function isSymbolRole(value: unknown): value is SymbolRole;
17
25
  export declare function isTraceabilityRelationshipType(value: unknown): value is TraceabilityRelationshipType;
18
26
  export declare function isAllowedGranularityReason(value: unknown): value is GranularityReason;
27
+ export declare function isCoarseGranularityReason(value: unknown): value is CoarseGranularityReason;
19
28
  export declare function getSymbolRole(candidate: GranularSymbolCandidate): SymbolRole;
20
29
  export declare function isBehavioralSymbol(candidate: GranularSymbolCandidate): boolean;
21
30
  export declare function getBehavioralSymbolNames(candidates: GranularSymbolCandidate[]): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":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CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAIvC;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAE5B;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,uBAAuB,CAElC;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,uBAAuB,GAAG,UAAU,CAI5E;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,uBAAuB,GACjC,OAAO,CAET;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,uBAAuB,EAAE,GACpC,MAAM,EAAE,CAMV;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,uBAAuB,EAAE,GACpC,MAAM,EAAE,CAQV"}
@@ -17,8 +17,21 @@ export const ALLOWED_GRANULARITY_REASONS = [
17
17
  "extractor-miss",
18
18
  "legacy-link",
19
19
  ];
20
+ /**
21
+ * Granularity reasons that document coarse file/module-level coverage for which
22
+ * generated per-symbol coordinates are not expected. These anchors legitimately
23
+ * carry no coordinate artifact entries. `legacy-link` is intentionally excluded:
24
+ * it is a canonical reason but still coordinates a real extractable symbol.
25
+ */
26
+ export const COARSE_GRANULARITY_REASONS = [
27
+ "config-artifact",
28
+ "module-level-behavior",
29
+ "extractor-miss",
30
+ "test-suite",
31
+ ];
20
32
  const traceabilityRelationshipTypeSet = new Set(TRACEABILITY_RELATIONSHIP_TYPES);
21
33
  const allowedGranularityReasonSet = new Set(ALLOWED_GRANULARITY_REASONS);
34
+ const coarseGranularityReasonSet = new Set(COARSE_GRANULARITY_REASONS);
22
35
  export function inferSymbolRole(kind) {
23
36
  switch (kind) {
24
37
  case "function":
@@ -46,6 +59,9 @@ export function isTraceabilityRelationshipType(value) {
46
59
  export function isAllowedGranularityReason(value) {
47
60
  return typeof value === "string" && allowedGranularityReasonSet.has(value);
48
61
  }
62
+ export function isCoarseGranularityReason(value) {
63
+ return typeof value === "string" && coarseGranularityReasonSet.has(value);
64
+ }
49
65
  export function getSymbolRole(candidate) {
50
66
  if (candidate.role)
51
67
  return candidate.role;
@@ -0,0 +1,89 @@
1
+ import type { QualityDiagnostic } from "./impact/types.js";
2
+ export declare const TELEMETRY_ACCEPTANCE_VERSION: "kibi.telemetry-acceptance.v1";
3
+ export type TelemetryMetricStatus = "passed" | "failed" | "insufficient_evidence" | "not_applicable";
4
+ export type TelemetryAcceptanceStatus = "passed" | "failed" | "insufficient_evidence";
5
+ export type TelemetryMetricId = "telemetry_completeness" | "advisor_before_requirement_write" | "validation_before_upsert" | "source_lookup_zero_result_rate" | "proof_gap_recovery" | "e2e_receipt_freshness" | "repeated_mutation_failures";
6
+ export interface TelemetryUsageEvent {
7
+ readonly timestamp?: string;
8
+ readonly request_id?: string;
9
+ readonly session_id?: string;
10
+ readonly actor_id?: string;
11
+ readonly tool?: string;
12
+ readonly status?: string;
13
+ readonly success?: boolean;
14
+ readonly telemetry?: unknown;
15
+ readonly telemetry_status?: string;
16
+ readonly business_args?: Readonly<Record<string, unknown>>;
17
+ readonly args?: Readonly<Record<string, unknown>>;
18
+ readonly mutation_fingerprint?: string;
19
+ readonly mutation_target?: string;
20
+ readonly validation_valid?: boolean;
21
+ readonly semantic_source_hash?: string;
22
+ readonly coverage_by?: string;
23
+ readonly coverage_scope_complete?: boolean;
24
+ readonly coverage_proof_gap_count?: number;
25
+ readonly coverage_receipt_gap_count?: number;
26
+ readonly zero_results?: boolean;
27
+ readonly result_count?: number;
28
+ readonly error_category?: string;
29
+ }
30
+ export interface TelemetryAcceptancePolicy {
31
+ readonly eventLimit: number;
32
+ readonly minimumEvents: number;
33
+ readonly maxEvidenceAgeSeconds: number;
34
+ readonly maxFutureSkewSeconds: number;
35
+ readonly telemetryCompletenessMinimum: number;
36
+ readonly validationBeforeUpsertMinimum: number;
37
+ readonly advisorBeforeRequirementWriteMinimum: number;
38
+ readonly sourceLookupZeroResultMaximum: number;
39
+ readonly preflightMaxAgeSeconds: number;
40
+ readonly advisorMaxAgeSeconds: number;
41
+ readonly repeatedMutationFailureThreshold: number;
42
+ }
43
+ export interface TelemetryAcceptanceMetric {
44
+ readonly id: TelemetryMetricId;
45
+ readonly status: TelemetryMetricStatus;
46
+ readonly numerator: number;
47
+ readonly denominator: number;
48
+ readonly rate?: number;
49
+ readonly threshold?: Readonly<{
50
+ operator: ">=" | "<=" | "<";
51
+ value: number;
52
+ }>;
53
+ readonly message: string;
54
+ readonly evidence?: Readonly<Record<string, unknown>>;
55
+ }
56
+ export interface TelemetryAcceptanceReport {
57
+ readonly version: typeof TELEMETRY_ACCEPTANCE_VERSION;
58
+ readonly status: TelemetryAcceptanceStatus;
59
+ readonly evaluatedAt: string;
60
+ readonly policy: TelemetryAcceptancePolicy;
61
+ readonly scope: Readonly<{
62
+ totalEvents: number;
63
+ evaluatedEvents: number;
64
+ truncated: boolean;
65
+ firstTimestamp: string | null;
66
+ lastTimestamp: string | null;
67
+ evidenceAgeSeconds: number | null;
68
+ fresh: boolean;
69
+ }>;
70
+ readonly metrics: readonly TelemetryAcceptanceMetric[];
71
+ readonly diagnostics: readonly string[];
72
+ }
73
+ export declare const DEFAULT_TELEMETRY_ACCEPTANCE_POLICY: {
74
+ readonly eventLimit: 200;
75
+ readonly minimumEvents: 20;
76
+ readonly maxEvidenceAgeSeconds: number;
77
+ readonly maxFutureSkewSeconds: number;
78
+ readonly telemetryCompletenessMinimum: 0.95;
79
+ readonly validationBeforeUpsertMinimum: 1;
80
+ readonly advisorBeforeRequirementWriteMinimum: 1;
81
+ readonly sourceLookupZeroResultMaximum: 0.2;
82
+ readonly preflightMaxAgeSeconds: number;
83
+ readonly advisorMaxAgeSeconds: number;
84
+ readonly repeatedMutationFailureThreshold: 3;
85
+ };
86
+ export declare function parseTelemetryUsageLog(contents: string): TelemetryUsageEvent[];
87
+ export declare function analyzeTelemetryAcceptance(events: readonly TelemetryUsageEvent[], now?: Date, policy?: TelemetryAcceptancePolicy): TelemetryAcceptanceReport;
88
+ export declare function createTelemetryAcceptanceDiagnostics(report: TelemetryAcceptanceReport): readonly QualityDiagnostic[];
89
+ //# sourceMappingURL=telemetry-acceptance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-acceptance.d.ts","sourceRoot":"","sources":["../../src/public/telemetry-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,eAAO,MAAM,4BAA4B,EACvC,8BAAuC,CAAC;AAE1C,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,QAAQ,GACR,uBAAuB,GACvB,gBAAgB,CAAC;AAErB,MAAM,MAAM,yBAAyB,GACjC,QAAQ,GACR,QAAQ,GACR,uBAAuB,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GACzB,wBAAwB,GACxB,kCAAkC,GAClC,0BAA0B,GAC1B,gCAAgC,GAChC,oBAAoB,GACpB,uBAAuB,GACvB,4BAA4B,CAAC;AAEjC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,IAAI,CAAC,E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