kibi-cli 2.31.1 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/cli-register-proof.d.ts.map +1 -1
  2. package/dist/cli-register-proof.js +19 -7
  3. package/dist/cli-register-reporting.d.ts.map +1 -1
  4. package/dist/cli-register-reporting.js +2 -0
  5. package/dist/commands/check.d.ts +1 -0
  6. package/dist/commands/check.d.ts.map +1 -1
  7. package/dist/commands/check.js +14 -5
  8. package/dist/commands/discovery-table.d.ts.map +1 -1
  9. package/dist/commands/discovery-table.js +51 -4
  10. package/dist/commands/doctor.js +19 -4
  11. package/dist/commands/migrate.d.ts.map +1 -1
  12. package/dist/commands/migrate.js +89 -3
  13. package/dist/commands/prove.d.ts +48 -1
  14. package/dist/commands/prove.d.ts.map +1 -1
  15. package/dist/commands/prove.js +293 -8
  16. package/dist/commands/report.d.ts +1 -0
  17. package/dist/commands/report.d.ts.map +1 -1
  18. package/dist/commands/report.js +70 -5
  19. package/dist/commands/signoff.d.ts.map +1 -1
  20. package/dist/commands/signoff.js +20 -1
  21. package/dist/commands/sync/manifest.d.ts.map +1 -1
  22. package/dist/commands/sync/manifest.js +20 -4
  23. package/dist/commands/sync/persistence.d.ts.map +1 -1
  24. package/dist/commands/sync/persistence.js +16 -5
  25. package/dist/diagnostics.js +1 -1
  26. package/dist/engine.js +1 -1
  27. package/dist/extractors/markdown.d.ts +3 -1
  28. package/dist/extractors/markdown.d.ts.map +1 -1
  29. package/dist/extractors/markdown.js +17 -0
  30. package/dist/operations/bootstrap/candidate-helpers.d.ts +3 -0
  31. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  32. package/dist/operations/bootstrap/candidate-helpers.js +4 -0
  33. package/dist/operations/migration/evidence-floor.d.ts +41 -0
  34. package/dist/operations/migration/evidence-floor.d.ts.map +1 -0
  35. package/dist/operations/migration/evidence-floor.js +230 -0
  36. package/dist/operations/migration/proof-contract-claims.d.ts +59 -0
  37. package/dist/operations/migration/proof-contract-claims.d.ts.map +1 -0
  38. package/dist/operations/migration/proof-contract-claims.js +182 -0
  39. package/dist/operations/migration/schema6.d.ts +6 -0
  40. package/dist/operations/migration/schema6.d.ts.map +1 -1
  41. package/dist/operations/migration/schema6.js +94 -0
  42. package/dist/operations/mutation/omitted-properties.d.ts +11 -0
  43. package/dist/operations/mutation/omitted-properties.d.ts.map +1 -0
  44. package/dist/operations/mutation/omitted-properties.js +76 -0
  45. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  46. package/dist/operations/mutation/serialization.js +1 -0
  47. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  48. package/dist/operations/mutation/strict-fact.js +6 -2
  49. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  50. package/dist/operations/mutation/symbol-granularity.js +5 -3
  51. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  52. package/dist/operations/mutation/upsert.js +7 -1
  53. package/dist/operations/mutation/validation.d.ts +2 -0
  54. package/dist/operations/mutation/validation.d.ts.map +1 -1
  55. package/dist/operations/mutation/validation.js +4 -0
  56. package/dist/operations/proof/claim-bindings.d.ts +23 -0
  57. package/dist/operations/proof/claim-bindings.d.ts.map +1 -0
  58. package/dist/operations/proof/claim-bindings.js +211 -0
  59. package/dist/operations/proof/code-certificates.d.ts +135 -0
  60. package/dist/operations/proof/code-certificates.d.ts.map +1 -0
  61. package/dist/operations/proof/code-certificates.js +785 -0
  62. package/dist/operations/proof/code-scope.d.ts +11 -1
  63. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  64. package/dist/operations/proof/code-scope.js +20 -2
  65. package/dist/operations/proof/compact-receipts.d.ts.map +1 -1
  66. package/dist/operations/proof/compact-receipts.js +4 -3
  67. package/dist/operations/proof/explain.d.ts +32 -0
  68. package/dist/operations/proof/explain.d.ts.map +1 -1
  69. package/dist/operations/proof/explain.js +91 -0
  70. package/dist/operations/proof/ingest-proof.d.ts +9 -1
  71. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  72. package/dist/operations/proof/ingest-proof.js +41 -2
  73. package/dist/operations/proof/receipt-compaction.d.ts +2 -0
  74. package/dist/operations/proof/receipt-compaction.d.ts.map +1 -1
  75. package/dist/operations/proof/receipt-compaction.js +6 -2
  76. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  77. package/dist/operations/semantic-advisor/shared.js +4 -0
  78. package/dist/operations/semantic-advisor/strict-rules.js +3 -3
  79. package/dist/operations/semantic-advisor/types.d.ts +2 -1
  80. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  81. package/dist/plugins/approved-source-analyzers.generated.d.ts +6 -6
  82. package/dist/plugins/approved-source-analyzers.generated.js +6 -6
  83. package/dist/proof/command-test-report.d.ts +4 -3
  84. package/dist/proof/command-test-report.d.ts.map +1 -1
  85. package/dist/proof/command-test-report.js +4 -10
  86. package/dist/proof/evaluate.d.ts.map +1 -1
  87. package/dist/proof/evaluate.js +18 -2
  88. package/dist/proof/inspect.d.ts.map +1 -1
  89. package/dist/proof/inspect.js +58 -0
  90. package/dist/proof/producers/playwright-reporter.d.ts +3 -0
  91. package/dist/proof/producers/playwright-reporter.d.ts.map +1 -1
  92. package/dist/proof/producers/playwright-reporter.js +25 -2
  93. package/dist/proof/step-runner.d.ts +36 -0
  94. package/dist/proof/step-runner.d.ts.map +1 -0
  95. package/dist/proof/step-runner.js +234 -0
  96. package/dist/public/evidence-levels.d.ts +12 -0
  97. package/dist/public/evidence-levels.d.ts.map +1 -0
  98. package/dist/public/evidence-levels.js +19 -0
  99. package/dist/public/impact/coverage-depth-quality.d.ts +7 -0
  100. package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
  101. package/dist/public/impact/coverage-depth-quality.js +59 -0
  102. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  103. package/dist/public/impact/full-kb-quality.js +3 -1
  104. package/dist/public/operations/catalog.d.ts +167 -6
  105. package/dist/public/operations/catalog.d.ts.map +1 -1
  106. package/dist/public/operations/check-executor.d.ts +2 -0
  107. package/dist/public/operations/check-executor.d.ts.map +1 -1
  108. package/dist/public/operations/check-executor.js +6 -0
  109. package/dist/public/operations/evidence-floor.d.ts +48 -0
  110. package/dist/public/operations/evidence-floor.d.ts.map +1 -0
  111. package/dist/public/operations/evidence-floor.js +143 -0
  112. package/dist/public/operations/migration-plan.d.ts +19 -5
  113. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  114. package/dist/public/operations/migration-plan.js +22 -5
  115. package/dist/public/operations/node-ports.d.ts.map +1 -1
  116. package/dist/public/operations/node-ports.js +4 -1
  117. package/dist/public/operations/proof-contract-claims.d.ts +26 -0
  118. package/dist/public/operations/proof-contract-claims.d.ts.map +1 -0
  119. package/dist/public/operations/proof-contract-claims.js +71 -0
  120. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  121. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  122. package/dist/public/operations/specs/check-rules.generated.js +3 -1
  123. package/dist/public/operations/specs/check.d.ts +1 -1
  124. package/dist/public/operations/specs/mutation-schemas.d.ts +157 -5
  125. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  126. package/dist/public/operations/specs/mutation-schemas.js +15 -2
  127. package/dist/public/operations/specs/proof.d.ts +9 -0
  128. package/dist/public/operations/specs/proof.d.ts.map +1 -1
  129. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  130. package/dist/public/operations/specs/reporting.js +19 -10
  131. package/dist/public/operations/specs/upsert.d.ts +157 -5
  132. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  133. package/dist/public/proof-certificates.d.ts +89 -0
  134. package/dist/public/proof-certificates.d.ts.map +1 -0
  135. package/dist/public/proof-certificates.js +207 -0
  136. package/dist/public/proof-protocol.d.ts +126 -3
  137. package/dist/public/proof-protocol.d.ts.map +1 -1
  138. package/dist/public/proof-protocol.js +239 -3
  139. package/dist/public/proof-receipt.d.ts +89 -6
  140. package/dist/public/proof-receipt.d.ts.map +1 -1
  141. package/dist/public/proof-receipt.js +83 -7
  142. package/dist/public/schemas/entity.d.ts.map +1 -1
  143. package/dist/public/schemas/entity.js +18 -1
  144. package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
  145. package/dist/public/skills/kibi-commit-review/SKILL.md +1 -1
  146. package/dist/public/skills/kibi-commit-review/resources/staged-gate.md +6 -1
  147. package/dist/public/skills/kibi-decisions/SKILL.md +10 -2
  148. package/dist/public/skills/kibi-decisions/resources/decision-records.md +6 -1
  149. package/dist/public/skills/kibi-freshness/SKILL.md +5 -1
  150. package/dist/public/skills/kibi-traceability/SKILL.md +11 -1
  151. package/dist/public/skills/kibi-usage/SKILL.md +6 -4
  152. package/dist/public/skills/kibi-usage/resources/proof.md +124 -19
  153. package/dist/public/skills/kibi-usage/resources/workflows.md +4 -4
  154. package/dist/report/html-report.css +38 -1
  155. package/dist/report/html-report.d.ts +8 -0
  156. package/dist/report/html-report.d.ts.map +1 -1
  157. package/dist/report/html-report.js +141 -6
  158. package/dist/report/report-view.d.ts +1 -1
  159. package/dist/report/report-view.d.ts.map +1 -1
  160. package/dist/report/report-view.js +7 -0
  161. package/dist/schemas/entity.schema.json +212 -4
  162. package/dist/search-answer.d.ts.map +1 -1
  163. package/dist/search-answer.js +1 -0
  164. package/dist/signoff/html.d.ts.map +1 -1
  165. package/dist/signoff/html.js +3 -0
  166. package/dist/signoff/markdown.d.ts.map +1 -1
  167. package/dist/signoff/markdown.js +3 -0
  168. package/dist/signoff/model.d.ts +20 -0
  169. package/dist/signoff/model.d.ts.map +1 -1
  170. package/dist/signoff/model.js +20 -1
  171. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  172. package/dist/traceability/impact-knowledge.js +1 -0
  173. package/dist/traceability/temp-kb.d.ts.map +1 -1
  174. package/dist/traceability/temp-kb.js +1 -0
  175. package/dist/types/entities.d.ts +4 -1
  176. package/dist/types/entities.d.ts.map +1 -1
  177. package/dist/utils/merge-driver-setup.d.ts +8 -1
  178. package/dist/utils/merge-driver-setup.d.ts.map +1 -1
  179. package/dist/utils/merge-driver-setup.js +23 -2
  180. package/dist/utils/rule-registry.generated.d.ts +10 -0
  181. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  182. package/dist/utils/rule-registry.generated.js +12 -0
  183. package/dist/utils/schema-version.d.ts +1 -1
  184. package/dist/utils/schema-version.d.ts.map +1 -1
  185. package/dist/utils/schema-version.js +5 -1
  186. package/package.json +6 -2
  187. package/schema/entities.pl +6 -0
  188. package/schema/validation.pl +4 -1
  189. package/src/public/evidence-levels.ts +23 -0
  190. package/src/public/impact/coverage-depth-quality.ts +73 -0
  191. package/src/public/impact/full-kb-quality.ts +6 -1
  192. package/src/public/operations/check-executor.ts +13 -0
  193. package/src/public/operations/evidence-floor.ts +203 -0
  194. package/src/public/operations/migration-plan.ts +39 -6
  195. package/src/public/operations/node-ports.ts +3 -1
  196. package/src/public/operations/proof-contract-claims.ts +103 -0
  197. package/src/public/operations/specs/check-rules.generated.ts +3 -1
  198. package/src/public/operations/specs/mutation-schemas.ts +17 -2
  199. package/src/public/operations/specs/reporting.ts +20 -10
  200. package/src/public/proof-certificates.ts +271 -0
  201. package/src/public/proof-protocol-types.d.ts +17 -1
  202. package/src/public/proof-protocol.ts +318 -3
  203. package/src/public/proof-receipt.ts +127 -7
  204. package/src/public/schemas/entity.ts +19 -1
  205. package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
  206. package/src/public/skills/kibi-commit-review/SKILL.md +1 -1
  207. package/src/public/skills/kibi-commit-review/resources/staged-gate.md +6 -1
  208. package/src/public/skills/kibi-decisions/SKILL.md +10 -2
  209. package/src/public/skills/kibi-decisions/resources/decision-records.md +6 -1
  210. package/src/public/skills/kibi-freshness/SKILL.md +5 -1
  211. package/src/public/skills/kibi-traceability/SKILL.md +11 -1
  212. package/src/public/skills/kibi-usage/SKILL.md +6 -4
  213. package/src/public/skills/kibi-usage/resources/proof.md +124 -19
  214. package/src/public/skills/kibi-usage/resources/workflows.md +4 -4
  215. package/src/schemas/entity.schema.json +212 -4
  216. package/dist/commands/proof-impact.d.ts +0 -7
  217. package/dist/commands/proof-impact.d.ts.map +0 -1
  218. package/dist/commands/proof-impact.js +0 -39
  219. package/dist/operations/proof/baseline-diff.d.ts +0 -41
  220. package/dist/operations/proof/baseline-diff.d.ts.map +0 -1
  221. package/dist/operations/proof/baseline-diff.js +0 -153
  222. package/dist/operations/proof/impact.d.ts +0 -51
  223. package/dist/operations/proof/impact.d.ts.map +0 -1
  224. package/dist/operations/proof/impact.js +0 -138
@@ -1,3 +1,4 @@
1
+ import { COARSE_GRANULARITY_REASONS } from "../symbol-granularity.generated.js";
1
2
  function entitiesById(manifestResults) {
2
3
  return new Map(manifestResults.map((result) => [result.entity.id, result.entity]));
3
4
  }
@@ -223,3 +224,61 @@ export function createCoverageDepthQualityDiagnostics(manifestResults, proofByRe
223
224
  })
224
225
  .toSorted((left, right) => (left.entityId ?? "").localeCompare(right.entityId ?? ""));
225
226
  }
227
+ const COARSE_REASONS = new Set(COARSE_GRANULARITY_REASONS);
228
+ /**
229
+ * Requirements whose every implementing production symbol is a whole-file
230
+ * anchor (a coarse granularity_reason). Coverage then only says some test
231
+ * touches the file, so `tested` evidence is cheap; narrower behavioral
232
+ * symbols would tie it to the code that implements the claim.
233
+ */
234
+ // implements REQ-audit-quality-diagnostics-v1
235
+ export function createCoarseAnchorQualityDiagnostics(manifestResults) {
236
+ const superseded = supersededRequirementIds(manifestResults);
237
+ const anchorsByRequirement = new Map();
238
+ for (const result of manifestResults) {
239
+ if (result.entity.type !== "symbol")
240
+ continue;
241
+ // Executable test code is not a production symbol.
242
+ if (result.relationships.some((rel) => rel.type === "executable_for"))
243
+ continue;
244
+ for (const relationship of result.relationships) {
245
+ if (relationship.type !== "implements")
246
+ continue;
247
+ const list = anchorsByRequirement.get(relationship.to) ?? [];
248
+ list.push(result.entity);
249
+ anchorsByRequirement.set(relationship.to, list);
250
+ }
251
+ }
252
+ return manifestResults
253
+ .filter((result) => result.entity.type === "req" &&
254
+ isReviewableRequirement(result.entity, superseded))
255
+ .flatMap((result) => {
256
+ const symbols = uniqueEntities(anchorsByRequirement.get(result.entity.id) ?? []);
257
+ if (symbols.length === 0 ||
258
+ !symbols.every((symbol) => COARSE_REASONS.has(symbol.granularity_reason ?? "")))
259
+ return [];
260
+ const requirement = result.entity;
261
+ return [
262
+ {
263
+ id: "coarse_anchor_only_review",
264
+ severity: "review",
265
+ blocking: false,
266
+ category: "coverage",
267
+ entityId: requirement.id,
268
+ source: requirement.source,
269
+ files: [requirement.source],
270
+ message: `Requirement ${requirement.id} (${requirement.title}) is implemented only by whole-file anchors, so its coverage says a test touches those files, not the code behind the claim.`,
271
+ suggestion: "Link the functions, methods or types that implement the requirement with implements (and covered_by to their tests); keep the file anchor only for genuinely module-level behavior.",
272
+ evidence: {
273
+ requirementId: requirement.id,
274
+ title: requirement.title,
275
+ symbols: symbols.map((symbol) => ({
276
+ id: symbol.id,
277
+ granularityReason: symbol.granularity_reason ?? "",
278
+ })),
279
+ },
280
+ },
281
+ ];
282
+ })
283
+ .toSorted((left, right) => (left.entityId ?? "").localeCompare(right.entityId ?? ""));
284
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAatC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAWjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AASpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC;IAC7D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAA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ChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAqgBF,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,GAClD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA8C7B;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,OAAO,GAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAM/C;AA2ID,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAmCvC"}
@@ -5,7 +5,7 @@ import { runOperationJsonQuery, toPrologAtom, toPrologList, } from "../operation
5
5
  import { PROOF_RECEIPT_MAX_AGE_SECONDS } from "../proof-receipt.js";
6
6
  import relationshipSchema from "../schemas/relationship.js";
7
7
  import { analyzeTelemetryAcceptance, createTelemetryAcceptanceDiagnostics, parseTelemetryUsageLog, } from "../telemetry-acceptance.js";
8
- import { createCoverageDepthQualityDiagnostics } from "./coverage-depth-quality.js";
8
+ import { createCoarseAnchorQualityDiagnostics, createCoverageDepthQualityDiagnostics, } from "./coverage-depth-quality.js";
9
9
  import { createRequirementQualityDiagnostics } from "./requirement-quality.js";
10
10
  import { createSymbolQualityDiagnostics } from "./symbol-quality.js";
11
11
  const RELATIONSHIP_TYPES = relationshipSchema.properties.type.enum;
@@ -225,6 +225,7 @@ function toExtractedEntity(entity) {
225
225
  "aliases",
226
226
  "examples",
227
227
  "predicate_args",
228
+ "value_set",
228
229
  ]) {
229
230
  const values = optionalStringArrayField(entity, field);
230
231
  if (values !== undefined)
@@ -552,6 +553,7 @@ export async function collectFullKbQualityDiagnostics(options) {
552
553
  : {}),
553
554
  }),
554
555
  ...coverageDepthDiagnostics,
556
+ ...createCoarseAnchorQualityDiagnostics(manifestResults),
555
557
  ...createSymbolQualityDiagnostics({
556
558
  manifestResults,
557
559
  symbolsByFile: new Map(),
@@ -1147,6 +1147,11 @@ export declare const OPERATION_CATALOG: readonly [{
1147
1147
  readonly enum: readonly ["firm", "default", "exploratory"];
1148
1148
  readonly description: "req/adr only. firm = a human stated it as a rule (needs origin.ref to their words); its title, meaning or firmness changes only with new human words (a new origin.ref) or by supersede. default = delegated or agent choice; exploratory = flagged guess. Absent = default if an agent wrote it, else firm.";
1149
1149
  };
1150
+ readonly required_evidence: {
1151
+ readonly type: "string";
1152
+ readonly enum: readonly ["proved", "tested", "asserted", "unverified"];
1153
+ readonly description: "Requirement-only. Weakest evidence level it accepts; the evidence-floor rule fails below it. Absent = tested if firm, else unverified.";
1154
+ };
1150
1155
  readonly rationale: {
1151
1156
  readonly type: "string";
1152
1157
  readonly minLength: 1;
@@ -1226,7 +1231,87 @@ export declare const OPERATION_CATALOG: readonly [{
1226
1231
  };
1227
1232
  readonly success_policy: {
1228
1233
  readonly type: "string";
1229
- readonly enum: readonly ["all_required_first_attempt"];
1234
+ readonly enum: readonly ["all_required_first_attempt", "own_results_first_attempt"];
1235
+ };
1236
+ readonly kind: {
1237
+ readonly type: "string";
1238
+ readonly enum: readonly ["e2e", "example", "property", "exhaustive", "typecheck", "arithmetic", "smt"];
1239
+ readonly description: "What the checker establishes; absent means e2e. exhaustive, typecheck, arithmetic and smt must leave a kibi.code-certificate.v1 that Kibi re-checks before the receipt counts as proved.";
1240
+ };
1241
+ readonly domain_source: {
1242
+ readonly type: "object";
1243
+ readonly description: "exhaustive and typecheck: the symbol that defines the finite domain. The proof must import it from its source file; a hand-listed domain downgrades the receipt to example. Kibi reads the export named `export`, or the symbol's title when `export` is absent.";
1244
+ readonly required: readonly ["symbol_id"];
1245
+ readonly properties: {
1246
+ readonly symbol_id: {
1247
+ readonly type: "string";
1248
+ readonly minLength: 1;
1249
+ };
1250
+ readonly export: {
1251
+ readonly type: "string";
1252
+ readonly minLength: 1;
1253
+ readonly description: "The name the domain is exported under in the symbol's source file, when the symbol's title is not that name.";
1254
+ };
1255
+ };
1256
+ readonly additionalProperties: false;
1257
+ };
1258
+ readonly witness: {
1259
+ readonly type: "object";
1260
+ readonly description: "typecheck: the repository-relative witness file Kibi compiles (an exhaustive switch ending in never, or a mapped type over the domain).";
1261
+ readonly required: readonly ["path"];
1262
+ readonly properties: {
1263
+ readonly path: {
1264
+ readonly type: "string";
1265
+ readonly minLength: 1;
1266
+ };
1267
+ };
1268
+ readonly additionalProperties: false;
1269
+ };
1270
+ readonly proves: {
1271
+ readonly type: "array";
1272
+ readonly description: "Certificate kinds: the requirement claim keys (CLAIM-...) this certificate proves. Each must be a modeled claim of a current requirement the test reaches through its scenarios. Kibi derives what the certificate must establish from the claim's grounding fact (a set fact for exhaustive or typecheck, a numeric fact for arithmetic or smt); a claim with no such derivation is only attested and never counts as proved.";
1273
+ readonly minItems: 1;
1274
+ readonly items: {
1275
+ readonly type: "string";
1276
+ readonly pattern: "^CLAIM-";
1277
+ };
1278
+ readonly uniqueItems: true;
1279
+ };
1280
+ readonly value_source: {
1281
+ readonly type: "array";
1282
+ readonly description: "arithmetic and smt: code constants the assumptions read. Kibi evaluates each export at ingest and requires the certificate to assume the variable equals that value, so the proof is about the code and not only the knowledge base.";
1283
+ readonly minItems: 1;
1284
+ readonly items: {
1285
+ readonly type: "object";
1286
+ readonly required: readonly ["symbol_id"];
1287
+ readonly properties: {
1288
+ readonly symbol_id: {
1289
+ readonly type: "string";
1290
+ readonly minLength: 1;
1291
+ };
1292
+ readonly export: {
1293
+ readonly type: "string";
1294
+ readonly minLength: 1;
1295
+ };
1296
+ };
1297
+ readonly additionalProperties: false;
1298
+ };
1299
+ };
1300
+ readonly constraint_source: {
1301
+ readonly type: "object";
1302
+ readonly description: "arithmetic and smt: the typed numeric property_value facts the certificate's assumptions come from. Kibi checks the assumptions (or the query's assertions) are exactly these facts' constraints, so the proof is about the knowledge base, not numbers the test chose.";
1303
+ readonly required: readonly ["fact_ids"];
1304
+ readonly properties: {
1305
+ readonly fact_ids: {
1306
+ readonly type: "array";
1307
+ readonly minItems: 1;
1308
+ readonly items: {
1309
+ readonly type: "string";
1310
+ readonly minLength: 1;
1311
+ };
1312
+ };
1313
+ };
1314
+ readonly additionalProperties: false;
1230
1315
  };
1231
1316
  };
1232
1317
  readonly additionalProperties: false;
@@ -1274,12 +1359,12 @@ export declare const OPERATION_CATALOG: readonly [{
1274
1359
  readonly maxItems: 50;
1275
1360
  readonly items: {
1276
1361
  readonly type: "object";
1277
- readonly description: "Kibi-derived kibi.proof-receipt.v1. Receipts are never caller-authored; kb_ingest_proof derives them from kibi.proof-run.v1 artifacts.";
1362
+ readonly description: "Kibi-derived kibi.proof-receipt.v2 (kibi.proof-receipt.v1 entries are still read). Receipts are never caller-authored; kb_ingest_proof derives them from kibi.proof-run.v1 artifacts.";
1278
1363
  readonly required: readonly ["version", "receipt_id", "test_id", "scope", "outcome", "code_snapshot", "environment_hash", "started_at", "finished_at", "artifact_digest", "contract_hash", "fingerprint", "fingerprint_components", "integration_id", "producer", "command_argv", "run_outcome", "proof_results"];
1279
1364
  readonly properties: {
1280
1365
  readonly version: {
1281
1366
  readonly type: "string";
1282
- readonly const: "kibi.proof-receipt.v1";
1367
+ readonly enum: readonly ["kibi.proof-receipt.v1", "kibi.proof-receipt.v2"];
1283
1368
  };
1284
1369
  readonly receipt_id: {
1285
1370
  readonly type: "string";
@@ -1461,6 +1546,63 @@ export declare const OPERATION_CATALOG: readonly [{
1461
1546
  readonly additionalProperties: false;
1462
1547
  };
1463
1548
  };
1549
+ readonly kind: {
1550
+ readonly type: "string";
1551
+ readonly enum: readonly ["e2e", "example", "property", "exhaustive", "typecheck", "arithmetic", "smt"];
1552
+ };
1553
+ readonly evidence_level: {
1554
+ readonly type: "string";
1555
+ readonly enum: readonly ["proved", "tested"];
1556
+ };
1557
+ readonly certificate: {
1558
+ readonly type: "object";
1559
+ };
1560
+ readonly certificate_digest: {
1561
+ readonly type: "string";
1562
+ readonly pattern: "^[a-f0-9]{64}$";
1563
+ };
1564
+ readonly certificate_rejection: {
1565
+ readonly type: "string";
1566
+ readonly minLength: 1;
1567
+ };
1568
+ readonly claim_bindings: {
1569
+ readonly type: "array";
1570
+ readonly description: "Certificate kinds: how the certificate binds to each claim its contract names in proves, judged at ingest. derived means Kibi derived the certificate's obligation from the claim's grounding fact and the certificate satisfies it; attested means no derivation exists and the author vouches for it (never proved); rejected names why.";
1571
+ readonly items: {
1572
+ readonly type: "object";
1573
+ readonly required: readonly ["claim_key", "binding"];
1574
+ readonly properties: {
1575
+ readonly claim_key: {
1576
+ readonly type: "string";
1577
+ readonly minLength: 1;
1578
+ };
1579
+ readonly requirement_id: {
1580
+ readonly type: "string";
1581
+ readonly minLength: 1;
1582
+ };
1583
+ readonly fact_id: {
1584
+ readonly type: "string";
1585
+ readonly minLength: 1;
1586
+ };
1587
+ readonly binding: {
1588
+ readonly type: "string";
1589
+ readonly enum: readonly ["derived", "attested", "rejected"];
1590
+ };
1591
+ readonly scope: {
1592
+ readonly type: "string";
1593
+ readonly enum: readonly ["code", "intent"];
1594
+ };
1595
+ readonly obligation: {
1596
+ readonly type: "object";
1597
+ };
1598
+ readonly reason: {
1599
+ readonly type: "string";
1600
+ readonly minLength: 1;
1601
+ };
1602
+ };
1603
+ readonly additionalProperties: false;
1604
+ };
1605
+ };
1464
1606
  readonly gaps: {
1465
1607
  readonly type: "array";
1466
1608
  readonly items: {
@@ -1508,8 +1650,8 @@ export declare const OPERATION_CATALOG: readonly [{
1508
1650
  };
1509
1651
  readonly value_type: {
1510
1652
  readonly type: "string";
1511
- readonly enum: readonly ["string", "int", "number", "bool"];
1512
- readonly description: "Optional typed value discriminator for property_value facts. Pair with exactly one value_string, value_int, value_number, or value_bool; do not use generic value.";
1653
+ readonly enum: readonly ["string", "int", "number", "bool", "set"];
1654
+ readonly description: "Optional typed value discriminator for property_value facts. Pair with exactly one value_string, value_int, value_number, value_bool, or value_set (set: an exact list of allowed values, operator eq or neq); do not use generic value.";
1513
1655
  };
1514
1656
  readonly value_string: {
1515
1657
  readonly type: "string";
@@ -1527,6 +1669,16 @@ export declare const OPERATION_CATALOG: readonly [{
1527
1669
  readonly type: "boolean";
1528
1670
  readonly description: "Optional boolean value for property_value facts.";
1529
1671
  };
1672
+ readonly value_set: {
1673
+ readonly type: "array";
1674
+ readonly items: {
1675
+ readonly type: "string";
1676
+ readonly minLength: 1;
1677
+ };
1678
+ readonly minItems: 1;
1679
+ readonly uniqueItems: true;
1680
+ readonly description: "Optional exact set of values for property_value facts with value_type set, such as the members a domain must have.";
1681
+ };
1530
1682
  readonly unit: {
1531
1683
  readonly type: "string";
1532
1684
  readonly description: "Optional unit for numeric property_value facts.";
@@ -1859,7 +2011,7 @@ export declare const OPERATION_CATALOG: readonly [{
1859
2011
  readonly type: "string";
1860
2012
  readonly enum: readonly string[];
1861
2013
  };
1862
- readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, symbol-granularity, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, decision-firm-unreferenced, decision-firm-superseded, decision-firm-edited, supersedes-reason-missing, supersedes-reason-acknowledged, policy-ownership, policy-markers, kb-consistency, kb-consistency-unresolved. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
2014
+ readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, symbol-granularity, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, decision-firm-unreferenced, decision-firm-superseded, decision-firm-edited, supersedes-reason-missing, supersedes-reason-acknowledged, policy-ownership, policy-markers, kb-consistency, kb-consistency-unresolved, evidence-floor, proof-contract-claims. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
1863
2015
  };
1864
2016
  readonly sourceFiles: {
1865
2017
  readonly type: "array";
@@ -2472,6 +2624,15 @@ export declare const OPERATION_CATALOG: readonly [{
2472
2624
  readonly minLength: 1;
2473
2625
  };
2474
2626
  };
2627
+ readonly certificates: {
2628
+ readonly type: "array";
2629
+ readonly description: "kibi.code-certificate.v1 objects the run left for certificate-kind contracts, one per test. Kibi re-checks each before a receipt counts as proved.";
2630
+ readonly maxItems: 1000;
2631
+ readonly items: {
2632
+ readonly type: "object";
2633
+ readonly required: readonly ["version", "kind", "test_id"];
2634
+ };
2635
+ };
2475
2636
  };
2476
2637
  readonly additionalProperties: false;
2477
2638
  };
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/public/operations/catalog.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBe,CAAC;AAyF9C,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,aAAa,GAClB,qBAAqB,CA+BvB;AAQD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,IAAI,EAAE,aAAa,GAClB,qBAAqB,CAKvB;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,qBAAqB,CAElE;AAGD,wBAAgB,SAAS,IAAI,SAAS,qBAAqB,EAAE,CAE5D"}
@@ -11,6 +11,8 @@ export type CheckInput = {
11
11
  readonly includeWorkingTreeDiff?: boolean;
12
12
  readonly includeImpactDiagnostics?: boolean;
13
13
  readonly maxDiagnostics?: number;
14
+ /** evidence-floor judges receipts as they are and needs a clean snapshot. */
15
+ readonly freshEvidence?: boolean;
14
16
  };
15
17
  export type CheckPayload = CheckStructuredContent;
16
18
  export type { CheckDiagnostic, CheckEvaluated, CheckStructuredContent };
@@ -1 +1 @@
1
- {"version":3,"file":"check-executor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-executor.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIL,iBAAiB,EAGjB,iBAAiB,EAGlB,MAAM,oBAAoB,CAAC;AAY5B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AAOvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,6CAA6C,CAA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AC;IACjC,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,6CAA6C,CAAC,EAAE,OAAO,CAAC;IACjE;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAoFF;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,MAAM,GACpB,SAAS,GAAG,IAAI,CAgClB;AAGD,wBAAsB,YAAY,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAwQxC"}
@@ -8,9 +8,11 @@ import { collectCheckPolicyViolations } from "./check-policy-rules.js";
8
8
  import { collectDecisionFirmnessViolations } from "./decision-firmness.js";
9
9
  import { executeStatus } from "./discovery-executors.js";
10
10
  import { collectEntityContextViolations } from "./entity-context.js";
11
+ import { collectEvidenceFloorViolations } from "./evidence-floor.js";
11
12
  import { buildActionsFromCheck, buildMigrationPlan, mergeMigrationPlans, } from "./migration-plan.js";
12
13
  import { collectOriginReviewViolations } from "./origin-review.js";
13
14
  import { collectPredicateSchemaConformanceViolations } from "./predicate-schema-conformance.js";
15
+ import { collectProofContractClaimViolations } from "./proof-contract-claims.js";
14
16
  import { SOURCE_PATH_DANGLING_RULE, collectSourcePathDanglingViolations, } from "./source-path-dangling.js";
15
17
  import { collectSourceRelationshipParityViolations } from "./source-relationship-parity.js";
16
18
  import { collectSymbolGranularityViolations } from "./symbol-granularity-check.js";
@@ -242,6 +244,8 @@ export async function executeCheck(args, context, options = {}) {
242
244
  const entityContextFindings = collectEntityContextViolations(rulesAllowlist, workspaceRoot);
243
245
  const decisionFirmnessFindings = collectDecisionFirmnessViolations(rulesAllowlist, workspaceRoot);
244
246
  const checkPolicyFindings = await collectCheckPolicyViolations(prolog, rulesAllowlist, workspaceRoot);
247
+ const evidenceFloorFindings = await collectEvidenceFloorViolations(context, rulesAllowlist, { freshEvidence: args.freshEvidence === true });
248
+ const proofContractClaimFindings = await collectProofContractClaimViolations(context, rulesAllowlist);
245
249
  const partitioned = partitionCheckFindings([
246
250
  ...aggregatedFindings,
247
251
  ...queryPlanViolations,
@@ -253,6 +257,8 @@ export async function executeCheck(args, context, options = {}) {
253
257
  ...entityContextFindings,
254
258
  ...decisionFirmnessFindings,
255
259
  ...checkPolicyFindings,
260
+ ...evidenceFloorFindings,
261
+ ...proofContractClaimFindings,
256
262
  ]);
257
263
  const violations = partitioned.violations;
258
264
  const evaluated = await describeEvaluation(prolog, rulesAllowlist);
@@ -0,0 +1,48 @@
1
+ import type { Violation } from "../../utils/rule-registry.js";
2
+ import type { OperationContext } from "./runtime-types.js";
3
+ import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
4
+ /**
5
+ * The schema version from which a current requirement's evidence level must
6
+ * reach its floor; older KBs get the floor with their schema upgrade, whose
7
+ * migration records the floor of firm requirements without a proof path.
8
+ */
9
+ export declare const EVIDENCE_FLOOR_SCHEMA_VERSION = 11;
10
+ /** A current requirement's evidence level must reach its floor. */
11
+ export declare const EVIDENCE_FLOOR_RULE = "evidence-floor";
12
+ export type EvidenceFloorRow = Readonly<{
13
+ id: string;
14
+ evidenceLevel: string;
15
+ requiredEvidence: string;
16
+ requiredEvidenceSource: string;
17
+ status: "below" | "pending_reproof";
18
+ proofStatus: string;
19
+ proofGaps: readonly string[];
20
+ /** The tests and symbols behind the gaps; empty lists are left out. */
21
+ gapDetails?: Readonly<Record<string, readonly string[]>>;
22
+ }>;
23
+ export type EvidenceFloorOptions = Readonly<{
24
+ /**
25
+ * Judge receipts as they are: stale receipts no longer count as pending
26
+ * re-proof, and the proof snapshot must be clean. CI uses it right after
27
+ * `kibi prove --all`.
28
+ */
29
+ freshEvidence?: boolean;
30
+ }>;
31
+ /** The entities behind the gaps, for a person reading kibi check's text. */
32
+ export declare function gapDetailLines(row: EvidenceFloorRow): string[];
33
+ /** One finding per current requirement whose evidence is below its floor. */
34
+ export declare function evidenceFloorViolations(rows: readonly EvidenceFloorRow[], options?: EvidenceFloorOptions): Violation[];
35
+ /**
36
+ * Every current requirement whose evidence is below its floor (status below
37
+ * or pending_reproof), judged on the attached store with the same
38
+ * per-contract receipt binding kb_coverage uses. Unlike the check rule this
39
+ * ignores the schema version, so a migration can read the floor the ladder
40
+ * will apply before it records the new schema.
41
+ */
42
+ export declare function readEvidenceFloorRows(context: OperationContext, snapshotEvidence?: Awaited<ReturnType<typeof readWorkspaceSnapshot>>): Promise<readonly EvidenceFloorRow[]>;
43
+ /**
44
+ * Evaluate the evidence-floor rule against the attached store, with the same
45
+ * per-contract receipt binding kb_coverage uses.
46
+ */
47
+ export declare function collectEvidenceFloorViolations(context: OperationContext, rules: ReadonlySet<string>, options?: EvidenceFloorOptions): Promise<Violation[]>;
48
+ //# sourceMappingURL=evidence-floor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-floor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/evidence-floor.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;GAIG;AAEH,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,mEAAmE;AAEnE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AA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+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { readKbManifest } from "../../utils/kb-manifest.js";
19
+ import { PROOF_RECEIPT_MAX_AGE_SECONDS } from "../proof-receipt.js";
20
+ import { runOperationJsonQuery, toPrologAtom } from "./prolog-json.js";
21
+ import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
22
+ /**
23
+ * The schema version from which a current requirement's evidence level must
24
+ * reach its floor; older KBs get the floor with their schema upgrade, whose
25
+ * migration records the floor of firm requirements without a proof path.
26
+ */
27
+ // implements REQ-kibi-evidence-floors
28
+ export const EVIDENCE_FLOOR_SCHEMA_VERSION = 11;
29
+ /** A current requirement's evidence level must reach its floor. */
30
+ // implements REQ-kibi-evidence-floors
31
+ export const EVIDENCE_FLOOR_RULE = "evidence-floor";
32
+ function floorSource(row) {
33
+ return row.requiredEvidenceSource === "explicit"
34
+ ? "its required_evidence"
35
+ : row.requiredEvidence === "tested"
36
+ ? "the floor of a firm requirement"
37
+ : "its floor";
38
+ }
39
+ const GAP_DETAIL_LABELS = {
40
+ failedReceiptTests: "failing receipts",
41
+ missingReceiptTests: "no receipt",
42
+ staleReceiptTests: "stale receipts",
43
+ invalidReceiptTests: "invalid receipts",
44
+ contractMismatchReceiptTests: "receipts for an older contract",
45
+ uncoveredSymbols: "production symbols without qualifying coverage",
46
+ missingCoordinateSymbols: "symbols without source coordinates",
47
+ unprovedClaims: "claims no certificate derives",
48
+ };
49
+ /** The entities behind the gaps, for a person reading kibi check's text. */
50
+ // implements REQ-kibi-evidence-floors
51
+ export function gapDetailLines(row) {
52
+ return Object.entries(row.gapDetails ?? {}).flatMap(([key, ids]) => ids.length === 0
53
+ ? []
54
+ : [
55
+ `${GAP_DETAIL_LABELS[key] ?? key}: ${ids.slice(0, 8).join(", ")}${ids.length > 8 ? ` (+${ids.length - 8} more)` : ""}`,
56
+ ]);
57
+ }
58
+ function suggestionFor(row) {
59
+ if (row.status === "pending_reproof")
60
+ return `Run kibi prove for the tests behind ${row.id} so its receipts match the current code, then rerun kibi check --fresh-evidence.`;
61
+ switch (row.requiredEvidence) {
62
+ case "proved":
63
+ return `Prove every applicable claim of ${row.id}${(row.gapDetails?.unprovedClaims ?? []).length > 0 ? ` (unproved: ${(row.gapDetails?.unprovedClaims ?? []).join(", ")})` : ""}: model each as a set fact (prove it with exhaustive or typecheck) or a numeric fact (arithmetic or smt), name it in a certificate test's proof_contract.proves, and run kibi prove; kibi proof explain ${row.id} shows each claim's bindings. A claim with no such fact can only be attested, so lower required_evidence to tested with the reason in the requirement if that is enough.`;
64
+ case "tested":
65
+ return `Link ${row.id} to a scenario with an end-to-end test that has a proof contract, run kibi prove, and fix its proof gaps (${row.proofGaps.join(", ") || "none listed"}${gapDetailLines(row).length > 0 ? `; ${gapDetailLines(row).join("; ")}` : ""}); kibi proof explain ${row.id} shows each one. Or lower required_evidence if a person decides it does not need tests.`;
66
+ default:
67
+ return `Have a person approve ${row.id} (origin.approved_by) or state it as firm with origin.ref to their words, or lower required_evidence.`;
68
+ }
69
+ }
70
+ /** One finding per current requirement whose evidence is below its floor. */
71
+ // implements REQ-kibi-evidence-floors
72
+ export function evidenceFloorViolations(rows, options = {}) {
73
+ return rows
74
+ .filter((row) => options.freshEvidence === true || row.status === "below")
75
+ .map((row) => ({
76
+ rule: EVIDENCE_FLOOR_RULE,
77
+ entityId: row.id,
78
+ description: row.status === "pending_reproof"
79
+ ? `${row.id} is ${row.evidenceLevel} but needs ${row.requiredEvidence} (${floorSource(row)}); its receipts are older than the code`
80
+ : `${row.id} is ${row.evidenceLevel} but needs ${row.requiredEvidence} (${floorSource(row)})`,
81
+ suggestion: suggestionFor(row),
82
+ evidence: {
83
+ evidenceLevel: row.evidenceLevel,
84
+ requiredEvidence: row.requiredEvidence,
85
+ requiredEvidenceSource: row.requiredEvidenceSource,
86
+ status: row.status,
87
+ proofStatus: row.proofStatus,
88
+ proofGaps: row.proofGaps,
89
+ ...(row.gapDetails === undefined ? {} : { gapDetails: row.gapDetails }),
90
+ },
91
+ }));
92
+ }
93
+ /**
94
+ * Every current requirement whose evidence is below its floor (status below
95
+ * or pending_reproof), judged on the attached store with the same
96
+ * per-contract receipt binding kb_coverage uses. Unlike the check rule this
97
+ * ignores the schema version, so a migration can read the floor the ladder
98
+ * will apply before it records the new schema.
99
+ */
100
+ // implements REQ-kibi-evidence-floors
101
+ export async function readEvidenceFloorRows(context, snapshotEvidence) {
102
+ const prolog = context.prolog ?? (await context.ensureProlog?.());
103
+ if (prolog === undefined)
104
+ return [];
105
+ const evidence = snapshotEvidence ?? (await readWorkspaceSnapshot(context));
106
+ const snapshot = evidence.available ? evidence.snapshot.hash : "unknown";
107
+ const { perContractTestBindings } = await import("./specs/reporting.js");
108
+ const bindings = await perContractTestBindings({ ...context, prolog });
109
+ const checkedAt = context.clock().toISOString();
110
+ const goal = `discovery:evidence_floor_json(${bindings === null ? "strict_snapshot, _{}" : `per_contract, ${bindings}`}, ${toPrologAtom(snapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`;
111
+ const payload = await runOperationJsonQuery(prolog, "discovery.pl", goal, "Evidence floor evaluation");
112
+ return payload.rows ?? [];
113
+ }
114
+ /**
115
+ * Evaluate the evidence-floor rule against the attached store, with the same
116
+ * per-contract receipt binding kb_coverage uses.
117
+ */
118
+ // implements REQ-kibi-evidence-floors
119
+ export async function collectEvidenceFloorViolations(context, rules, options = {}) {
120
+ if (!rules.has(EVIDENCE_FLOOR_RULE) || context.prolog === undefined)
121
+ return [];
122
+ // A store without a manifest predates schema 11 as much as an old one.
123
+ const schemaVersion = readKbManifest(context.workspaceRoot)?.schemaVersion;
124
+ if (schemaVersion === undefined ||
125
+ schemaVersion < EVIDENCE_FLOOR_SCHEMA_VERSION)
126
+ return [];
127
+ const snapshotEvidence = await readWorkspaceSnapshot(context);
128
+ const rows = await readEvidenceFloorRows(context, snapshotEvidence);
129
+ const violations = evidenceFloorViolations(rows, options);
130
+ if (options.freshEvidence === true) {
131
+ const clean = snapshotEvidence.available && snapshotEvidence.snapshot.dirty === false;
132
+ if (!clean)
133
+ violations.unshift({
134
+ rule: EVIDENCE_FLOOR_RULE,
135
+ entityId: "proof-snapshot",
136
+ description: snapshotEvidence.available
137
+ ? "--fresh-evidence needs a clean proof snapshot, but the working tree has uncommitted changes"
138
+ : `--fresh-evidence needs a proof snapshot, but none is available: ${snapshotEvidence.error}`,
139
+ suggestion: "Commit or stash working-tree changes (or run inside a Git checkout), run kibi prove, then rerun kibi check --fresh-evidence.",
140
+ });
141
+ }
142
+ return violations;
143
+ }