kibi-cli 2.31.0 → 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 (226) 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 +21 -2
  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 +4 -3
  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-decisions/resources/signoff-views.md +3 -2
  150. package/dist/public/skills/kibi-freshness/SKILL.md +5 -1
  151. package/dist/public/skills/kibi-traceability/SKILL.md +11 -1
  152. package/dist/public/skills/kibi-usage/SKILL.md +6 -4
  153. package/dist/public/skills/kibi-usage/resources/proof.md +124 -19
  154. package/dist/public/skills/kibi-usage/resources/workflows.md +4 -4
  155. package/dist/report/html-report.css +38 -1
  156. package/dist/report/html-report.d.ts +8 -0
  157. package/dist/report/html-report.d.ts.map +1 -1
  158. package/dist/report/html-report.js +141 -6
  159. package/dist/report/report-view.d.ts +1 -1
  160. package/dist/report/report-view.d.ts.map +1 -1
  161. package/dist/report/report-view.js +7 -0
  162. package/dist/schemas/entity.schema.json +212 -4
  163. package/dist/search-answer.d.ts.map +1 -1
  164. package/dist/search-answer.js +1 -0
  165. package/dist/signoff/html.d.ts.map +1 -1
  166. package/dist/signoff/html.js +3 -0
  167. package/dist/signoff/markdown.d.ts.map +1 -1
  168. package/dist/signoff/markdown.js +3 -0
  169. package/dist/signoff/model.d.ts +20 -0
  170. package/dist/signoff/model.d.ts.map +1 -1
  171. package/dist/signoff/model.js +20 -1
  172. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  173. package/dist/traceability/impact-knowledge.js +1 -0
  174. package/dist/traceability/temp-kb.d.ts.map +1 -1
  175. package/dist/traceability/temp-kb.js +1 -0
  176. package/dist/types/entities.d.ts +4 -1
  177. package/dist/types/entities.d.ts.map +1 -1
  178. package/dist/utils/merge-driver-setup.d.ts +8 -1
  179. package/dist/utils/merge-driver-setup.d.ts.map +1 -1
  180. package/dist/utils/merge-driver-setup.js +23 -2
  181. package/dist/utils/rule-registry.generated.d.ts +10 -0
  182. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  183. package/dist/utils/rule-registry.generated.js +12 -0
  184. package/dist/utils/schema-version.d.ts +1 -1
  185. package/dist/utils/schema-version.d.ts.map +1 -1
  186. package/dist/utils/schema-version.js +5 -1
  187. package/package.json +6 -2
  188. package/schema/entities.pl +6 -0
  189. package/schema/validation.pl +4 -1
  190. package/src/public/evidence-levels.ts +23 -0
  191. package/src/public/impact/coverage-depth-quality.ts +73 -0
  192. package/src/public/impact/full-kb-quality.ts +6 -1
  193. package/src/public/operations/check-executor.ts +13 -0
  194. package/src/public/operations/evidence-floor.ts +203 -0
  195. package/src/public/operations/migration-plan.ts +39 -6
  196. package/src/public/operations/node-ports.ts +3 -1
  197. package/src/public/operations/proof-contract-claims.ts +103 -0
  198. package/src/public/operations/specs/check-rules.generated.ts +3 -1
  199. package/src/public/operations/specs/mutation-schemas.ts +17 -2
  200. package/src/public/operations/specs/reporting.ts +20 -10
  201. package/src/public/proof-certificates.ts +271 -0
  202. package/src/public/proof-protocol-types.d.ts +17 -1
  203. package/src/public/proof-protocol.ts +318 -3
  204. package/src/public/proof-receipt.ts +127 -7
  205. package/src/public/schemas/entity.ts +19 -1
  206. package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
  207. package/src/public/skills/kibi-commit-review/SKILL.md +4 -3
  208. package/src/public/skills/kibi-commit-review/resources/staged-gate.md +6 -1
  209. package/src/public/skills/kibi-decisions/SKILL.md +10 -2
  210. package/src/public/skills/kibi-decisions/resources/decision-records.md +6 -1
  211. package/src/public/skills/kibi-decisions/resources/signoff-views.md +3 -2
  212. package/src/public/skills/kibi-freshness/SKILL.md +5 -1
  213. package/src/public/skills/kibi-traceability/SKILL.md +11 -1
  214. package/src/public/skills/kibi-usage/SKILL.md +6 -4
  215. package/src/public/skills/kibi-usage/resources/proof.md +124 -19
  216. package/src/public/skills/kibi-usage/resources/workflows.md +4 -4
  217. package/src/schemas/entity.schema.json +212 -4
  218. package/dist/commands/proof-impact.d.ts +0 -7
  219. package/dist/commands/proof-impact.d.ts.map +0 -1
  220. package/dist/commands/proof-impact.js +0 -39
  221. package/dist/operations/proof/baseline-diff.d.ts +0 -41
  222. package/dist/operations/proof/baseline-diff.d.ts.map +0 -1
  223. package/dist/operations/proof/baseline-diff.js +0 -153
  224. package/dist/operations/proof/impact.d.ts +0 -51
  225. package/dist/operations/proof/impact.d.ts.map +0 -1
  226. package/dist/operations/proof/impact.js +0 -138
@@ -21,9 +21,9 @@ import { dump as dumpYAML, load as parseYAML } from "js-yaml";
21
21
  import { isSeq, parseDocument } from "yaml";
22
22
  import { coarseCoordinateSpan, coordinateIdentityHash, coordinateSourceHash, parseCoordinateArtifact, writeCoordinateArtifact, } from "../../extractors/symbol-coordinates.js";
23
23
  import { enrichSymbolCoordinates, } from "../../extractors/symbols-coordinator.js";
24
- import { resolveWorkspaceSourceAbsolute } from "../../utils/repo-relative-path.js";
25
24
  import { COARSE_GRANULARITY_REASONS, COARSE_GRANULARITY_REASONS_PARENTHESIZED, isCoarseGranularityReason, } from "../../public/symbol-granularity.js";
26
25
  import { resolveSymbolsManifestPaths } from "../../utils/manifest-paths.js";
26
+ import { resolveWorkspaceSourceAbsolute } from "../../utils/repo-relative-path.js";
27
27
  import { blockifySymbolManifest } from "../../utils/symbol-manifest-layout.js";
28
28
  function resolveDeps(overrides) {
29
29
  return {
@@ -55,6 +55,11 @@ export const SYMBOLS_MANIFEST_COMMENT_BLOCK = `# symbols.yaml
55
55
  # coordinate entry at all and is reported as failed; add symbol_role and
56
56
  # granularity_reason to opt it into the coarse fallback.
57
57
  `;
58
+ function sameCoordinateSpan(stored, next) {
59
+ return (stored !== undefined &&
60
+ stored.sourceFile === next.sourceFile &&
61
+ GENERATED_COORD_FIELDS.every((field) => stored[field] === next[field]));
62
+ }
58
63
  const GENERATED_COORD_FIELDS = [
59
64
  "sourceLine",
60
65
  "sourceColumn",
@@ -192,14 +197,20 @@ manifestPath, workspaceRoot, deps) {
192
197
  ? { ...entry }
193
198
  : {});
194
199
  let coordinatesPath = null;
200
+ // The stored artifact is the baseline a refresh is counted against: the
201
+ // authored manifest never holds coordinates, so comparing against it would
202
+ // report every symbol as refreshed.
203
+ let storedCoordinates = null;
195
204
  if (shouldRefreshCoordinates) {
196
205
  coordinatesPath =
197
206
  resolved.resolveSymbolsManifestPaths(workspaceRoot).coordinatesPath;
207
+ storedCoordinates = {};
198
208
  if (resolved.existsSync(coordinatesPath)) {
199
209
  const existing = parseCoordinateArtifact(String(resolved.readFileSync(coordinatesPath, "utf8")));
200
210
  if (existing.status === "invalid") {
201
211
  throw new Error(`Failed to parse coordinate artifact ${coordinatesPath}: ${existing.reason}`);
202
212
  }
213
+ storedCoordinates = existing.coordinates;
203
214
  }
204
215
  }
205
216
  const enriched = await resolved.enrichSymbolCoordinates(before, workspaceRoot, shouldRefreshCoordinates
@@ -210,8 +221,8 @@ manifestPath, workspaceRoot, deps) {
210
221
  // partially published compiler dependency. Symbols without extractable
211
222
  // coordinates stay absent from the artifact; coverage keeps their gap visible.
212
223
  let refreshedArtifactBytes = null;
224
+ const boundEntries = {};
213
225
  if (shouldRefreshCoordinates) {
214
- const boundEntries = {};
215
226
  for (const entry of enriched) {
216
227
  const id = typeof entry?.id === "string" ? entry.id : undefined;
217
228
  if (!id)
@@ -241,8 +252,13 @@ manifestPath, workspaceRoot, deps) {
241
252
  for (let i = 0; i < before.length; i++) {
242
253
  const previous = before[i] ?? {};
243
254
  const current = enriched[i] ?? previous;
244
- const changed = GENERATED_COORD_FIELDS.some((field) => previous[field] !==
245
- current[field]);
255
+ const id = typeof current.id === "string" ? current.id : undefined;
256
+ const changed = storedCoordinates === null
257
+ ? GENERATED_COORD_FIELDS.some((field) => previous[field] !==
258
+ current[field])
259
+ : id !== undefined &&
260
+ boundEntries[id] !== undefined &&
261
+ !sameCoordinateSpan(storedCoordinates[id], boundEntries[id]);
246
262
  if (changed) {
247
263
  refreshed++;
248
264
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/persistence.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2HrD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAuFD,iFAAiF;AACjF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAAC,MAAM,CAAC,CA+BjB;AAED,0EAA0E;AAC1E,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAED,8EAA8E;AAC9E,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,SAAS,qBAAqB,EAAE,GAC9C,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAmCD,6EAA6E;AAE7E,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC;AAEH;;;GAGG;AAEH,wBAAsB,gBAAgB,CACpC,MAAM,E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AAE,EAC3C,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GACvC,OAAO,CAAC;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CA0O7D"}
@@ -64,6 +64,7 @@ const STRING_ARRAY_FIELDS = new Set([
64
64
  "aliases",
65
65
  "examples",
66
66
  "predicate_args",
67
+ "value_set",
67
68
  ]);
68
69
  function getEntityField(entity, field) {
69
70
  // ExtractedEntity declares all fact fields as optional properties, so indexing
@@ -405,6 +406,9 @@ prolog, results, entityIds, options = {}) {
405
406
  entity.firmness !== undefined) {
406
407
  props.push(`firmness=${toPrologAtom(entity.firmness)}`);
407
408
  }
409
+ if (entity.type === "req" && entity.required_evidence !== undefined) {
410
+ props.push(`required_evidence=${toPrologAtom(entity.required_evidence)}`);
411
+ }
408
412
  if (entity.type === "scenario" && entity.expects !== undefined) {
409
413
  props.push(`expects=${toPrologAtom(entity.expects)}`);
410
414
  }
@@ -546,7 +550,13 @@ export function relationshipFailureMessage(singleError, batchError) {
546
550
  }
547
551
  // implements REQ-core-persistence
548
552
  export async function persistRelationships(prolog, results, shardRelationships, options = {}) {
549
- let relCount = 0;
553
+ // Distinct edges asserted: an edge stated in an entity's front matter and in
554
+ // a relationship shard, or extracted twice, is asserted more than once but
555
+ // stored once, so counting assert calls overstates what this sync added.
556
+ const assertedEdges = new Set();
557
+ const countEdge = (type, fromId, toId) => {
558
+ assertedEdges.add(`${type}|${fromId}|${toId}`);
559
+ };
550
560
  let kbModified = false;
551
561
  // Build ID lookup for relationship resolution
552
562
  const idLookup = new Map();
@@ -603,7 +613,8 @@ export async function persistRelationships(prolog, results, shardRelationships,
603
613
  ? await relationshipBatchRunner(chunk.map(({ goal }) => goal))
604
614
  : { success: false, error: "batch unsupported" };
605
615
  if (batch.success) {
606
- relCount += chunk.length;
616
+ for (const item of chunk)
617
+ countEdge(item.rel.type, item.fromId, item.toId);
607
618
  kbModified = true;
608
619
  continue;
609
620
  }
@@ -611,7 +622,7 @@ export async function persistRelationships(prolog, results, shardRelationships,
611
622
  try {
612
623
  const single = await prolog.query(item.goal);
613
624
  if (single.success) {
614
- relCount++;
625
+ countEdge(item.rel.type, item.fromId, item.toId);
615
626
  kbModified = true;
616
627
  }
617
628
  else {
@@ -643,7 +654,7 @@ export async function persistRelationships(prolog, results, shardRelationships,
643
654
  const goal = `kb_assert_relationship(${toPrologAtom(rel.type)}, ${toPrologAtom(fromId)}, ${toPrologAtom(toId)}, [])`;
644
655
  const result = await prolog.query(goal);
645
656
  if (result.success) {
646
- relCount++;
657
+ countEdge(rel.type, fromId, toId);
647
658
  kbModified = true;
648
659
  }
649
660
  else {
@@ -715,5 +726,5 @@ export async function persistRelationships(prolog, results, shardRelationships,
715
726
  console.warn("\nTip: Ensure target entities exist before creating relationships.");
716
727
  }
717
728
  }
718
- return { relationshipCount: relCount, kbModified };
729
+ return { relationshipCount: assertedEdges.size, kbModified };
719
730
  }
@@ -82,7 +82,7 @@ export function formatSyncSummary(summary) {
82
82
  lines.push(`KB Totals: ${entityTotal} entities`);
83
83
  pushCounts(lines, totals.entities);
84
84
  lines.push(`KB Relationships: ${totals.relationships}`);
85
- lines.push(`Imported This Sync (changed sources only): ${imported} entities, ${summary.relationshipCount} relationship records`);
85
+ lines.push(`Imported This Sync (changed sources only): ${imported} entities, ${summary.relationshipCount} distinct relationships`);
86
86
  pushCounts(lines, summary.entityCounts);
87
87
  }
88
88
  lines.push("");
package/dist/engine.js CHANGED
@@ -250,7 +250,7 @@ function safeEngineGoal(goal) {
250
250
  if (/\b(?:halt|abort|shell|system|process_create|consult|load_files|open|close|delete_file|rename_file|make_directory|thread_create|rdf_attach_db|rdf_load|rdf_save|assertz|asserta|retractall|set_prolog_flag)\s*\(/.test(executable)) {
251
251
  return false;
252
252
  }
253
- return /(?:^|[(:,\s])(?:kb_|checks:|status:|discovery:|requirement_proof:|findall\(|aggregate_all\(|rdf_transaction\(|use_module\(|atom_json_dict\(|member\(|once\(|true\b|fail\b)/.test(goal.trim());
253
+ return /(?:^|[(:,\s])(?:kb_|checks:|status:|discovery:|requirement_proof:|code_certificates:|claim_obligations:|findall\(|aggregate_all\(|rdf_transaction\(|use_module\(|atom_json_dict\(|member\(|once\(|true\b|fail\b)/.test(goal.trim());
254
254
  }
255
255
  function frame(value) {
256
256
  const payload = Buffer.from(JSON.stringify(value), "utf8");
@@ -17,6 +17,7 @@ export interface ExtractedEntity {
17
17
  text_ref?: string;
18
18
  origin?: EntityOrigin;
19
19
  firmness?: Firmness;
20
+ required_evidence?: "proved" | "tested" | "asserted" | "unverified";
20
21
  semantic_text?: string;
21
22
  logic_claims?: string[];
22
23
  semantic_clauses?: string[];
@@ -46,8 +47,9 @@ export interface ExtractedEntity {
46
47
  subject_key?: string;
47
48
  property_key?: string;
48
49
  operator?: "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
49
- value_type?: "string" | "int" | "number" | "bool";
50
+ value_type?: "string" | "int" | "number" | "bool" | "set";
50
51
  value_string?: string;
52
+ value_set?: string[];
51
53
  value_int?: number;
52
54
  value_number?: number;
53
55
  value_bool?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAuEpC,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UA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MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;gBAG5B,OAAO,EAAE,MAAM,EACR,QAAQ,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;IAYM,QAAQ;CAUlB;AA2DD;;;;;GAKG;AAEH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlE;AAED;;;;;GAKG;AAEH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAeD,wBAAgB,sBAAsB,CAEpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAkDV;AA0jBD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAElB;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAatE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASjE;AASD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQpE"}
@@ -23,6 +23,7 @@ import { FIRMNESS_VALUES, carriesFirmness, isFirmness, } from "../decision-firmn
23
23
  import { withoutContextSections } from "../entity-body-context.js";
24
24
  import { deriveFactClaimKey, semanticClaimKey, } from "../operations/semantic-advisor/clauses.js";
25
25
  import { normalizeEntityOrigin, } from "../public/entity-origin.js";
26
+ import { EVIDENCE_LEVELS } from "../public/evidence-levels.js";
26
27
  import { PROOF_BINDINGS_SCHEMA, PROOF_CONTRACT_SCHEMA, } from "../public/proof-protocol.js";
27
28
  import { proofReceiptHistoryErrors, } from "../public/proof-receipt.js";
28
29
  import entitySchema from "../schemas/entity.schema.json" with { type: "json" };
@@ -68,6 +69,7 @@ const FACT_STRING_ARRAY_FIELDS = [
68
69
  "aliases",
69
70
  "examples",
70
71
  "predicate_args",
72
+ "value_set",
71
73
  ];
72
74
  const FACT_ONLY_FIELDS = [
73
75
  ...FACT_STRING_FIELDS,
@@ -534,6 +536,21 @@ function extractFromMarkdownContent(content, filePath) {
534
536
  }
535
537
  entity.firmness = data.firmness;
536
538
  }
539
+ // implements REQ-kibi-evidence-floors
540
+ // The weakest evidence level the requirement accepts; the evidence-floor
541
+ // rule reads it, and derives it from firmness when absent.
542
+ if (data.required_evidence !== undefined) {
543
+ if (type !== "req" ||
544
+ !EVIDENCE_LEVELS.includes(data.required_evidence)) {
545
+ throw new FrontmatterError(type === "req"
546
+ ? "Invalid required_evidence; expected one of proved, tested, asserted, unverified"
547
+ : "required_evidence is only allowed on type: req", filePath, {
548
+ classification: "Invalid Required Evidence",
549
+ hint: "Set required_evidence to the weakest evidence level the requirement accepts (proved, tested, asserted or unverified), or remove the field to derive it from firmness.",
550
+ });
551
+ }
552
+ entity.required_evidence = data.required_evidence;
553
+ }
537
554
  if (type === "req" && Array.isArray(data.exempts_claims)) {
538
555
  entity.exempts_claims = data.exempts_claims.filter((value) => typeof value === "string");
539
556
  }
@@ -19,6 +19,9 @@ export declare function withDocumentBody(step: Readonly<Record<string, unknown>>
19
19
  * Record a requirement bootstrap read from a person's document as theirs: an
20
20
  * import with a reference to the passage, and `firmness: firm`, so an agent
21
21
  * asks before changing it instead of treating it as its own default choice.
22
+ * Nothing tests it yet, so its evidence floor is `asserted` (the document
23
+ * stands behind it), as `kibi migrate` sets for untested firm requirements;
24
+ * a freshly bootstrapped knowledge base passes `kibi check`.
22
25
  */
23
26
  export declare function asImportedRule(step: Readonly<Record<string, unknown>>, ref: string): Readonly<Record<string, unknown>>;
24
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-helpers.d.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CA0C9C;AAED;;;GAGG;AAEH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,IAAI,EAAE,MAAM,GACX,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEnC;AAED;;;;;;;GAOG;AAEH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,GAAG,EAAE,MAAM,GACV,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAcnC;AAED;;;;GAIG;AAEH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED,yEAAyE;AAEzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;GAGG;AAEH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,CAMR"}
@@ -73,6 +73,9 @@ export function withDocumentBody(step, body) {
73
73
  * Record a requirement bootstrap read from a person's document as theirs: an
74
74
  * import with a reference to the passage, and `firmness: firm`, so an agent
75
75
  * asks before changing it instead of treating it as its own default choice.
76
+ * Nothing tests it yet, so its evidence floor is `asserted` (the document
77
+ * stands behind it), as `kibi migrate` sets for untested firm requirements;
78
+ * a freshly bootstrapped knowledge base passes `kibi check`.
76
79
  */
77
80
  // implements REQ-kb-decision-firmness
78
81
  export function asImportedRule(step, ref) {
@@ -85,6 +88,7 @@ export function asImportedRule(step, ref) {
85
88
  ...properties,
86
89
  origin: { kind: "import", ref },
87
90
  firmness: "firm",
91
+ required_evidence: "asserted",
88
92
  },
89
93
  };
90
94
  }
@@ -0,0 +1,41 @@
1
+ import type { BodyContextPlan } from "./entity-body-context.js";
2
+ /** Schema 11: record the floor of firm requirements that had no proof path. */
3
+ export declare const EVIDENCE_FLOOR_PIN_CODE = "evidence_floor_pin";
4
+ /** Pins to write, plus the firm requirements that keep the tested floor. */
5
+ export type EvidenceFloorPlan = BodyContextPlan & Readonly<{
6
+ kept: readonly string[];
7
+ /**
8
+ * Whether the floors were decided by the evidence ladder on the compiled
9
+ * store (`ladder`) or only from authored receipts (`authored`), because
10
+ * no synced store could be read.
11
+ */
12
+ decidedBy: "ladder" | "authored";
13
+ }>;
14
+ /**
15
+ * The evidence ladder's verdict on the current store: requirement id to the
16
+ * evidence-floor status of every requirement below a tested floor
17
+ * (`below`, or `pending_reproof` when only receipts older than the code
18
+ * stand in the way). Requirements absent from the map meet the floor.
19
+ */
20
+ export type LadderFloorVerdicts = ReadonlyMap<string, "below" | "pending_reproof">;
21
+ /**
22
+ * Current firm requirements without required_evidence and without a proof
23
+ * path that has passed. From schema 11 a firm requirement needs tested
24
+ * evidence, which these have not reached, so the migration records their
25
+ * floor as asserted in the requirement itself, where a reviewer sees it and
26
+ * can raise it later. Requirements with a passing proof path keep the tested
27
+ * floor; `kept` lists them, since remaining gaps (a stale receipt, a missing
28
+ * covered_by) still show in kibi check. Read-only.
29
+ */
30
+ export declare function planEvidenceFloorPins(workspaceRoot: string, ladder?: LadderFloorVerdicts | null): EvidenceFloorPlan;
31
+ /** Write the planned floors; returns how many requirements were rewritten. */
32
+ export declare function applyEvidenceFloorPins(workspaceRoot: string, ladder?: LadderFloorVerdicts | null): number;
33
+ /**
34
+ * Read the evidence ladder's floor verdicts from the branch's compiled store,
35
+ * so the migration keeps the tested floor only where kibi check will accept
36
+ * it. Returns null when no healthy, synced store is attached (never synced,
37
+ * damaged, another branch's store) or the evaluation fails; the migration
38
+ * then decides from authored receipts alone and says so.
39
+ */
40
+ export declare function readLadderFloorVerdicts(workspaceRoot: string): Promise<LadderFloorVerdicts | null>;
41
+ //# sourceMappingURL=evidence-floor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-floor.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/evidence-floor.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,0BAA0B,CAAC;AAQlC,+EAA+E;AAE/E,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,eAAe,GAC7C,QAAQ,CAAC;IACP,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,SAAS,EAAE,QAAQ,GAAG,UAAU,CAAC;CAClC,CAAC,CAAC;AAEL;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAC3C,MAAM,EACN,OAAO,GAAG,iBAAiB,CAC5B,CAAC;AA+GF;;;;;;;;GAQG;AAEH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,GAClC,iBAAiB,CAsDnB;AAED,8EAA8E;AAE9E,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,GAClC,MAAM,CAKR;AAED;;;;;;GAMG;AAEH,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAuCrC"}
@@ -0,0 +1,230 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ 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 path from "node:path";
19
+ import { effectiveFirmness } from "../../decision-firmness.js";
20
+ import { authoredSupersededIds, isCurrentAuthoredEntity, readAuthoredEntity, } from "../../public/operations/entity-context.js";
21
+ import { readAllShards } from "../../relationships/shards.js";
22
+ import { listLaneMarkdownFiles, readText, withTopLevelField, writeFileAtomically, } from "./kb-sources.js";
23
+ /** Schema 11: record the floor of firm requirements that had no proof path. */
24
+ // implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
25
+ export const EVIDENCE_FLOOR_PIN_CODE = "evidence_floor_pin";
26
+ /** The floor the migration records: a person stands behind the requirement. */
27
+ const PINNED_FLOOR = "asserted";
28
+ function linkTargets(entity, type) {
29
+ const links = entity.data.links;
30
+ if (!Array.isArray(links))
31
+ return [];
32
+ return links.flatMap((link) => link !== null &&
33
+ typeof link === "object" &&
34
+ link.type === type &&
35
+ typeof link.target === "string"
36
+ ? [link.target]
37
+ : []);
38
+ }
39
+ function authoredEntities(workspaceRoot, lane) {
40
+ const entities = [];
41
+ for (const file of listLaneMarkdownFiles(workspaceRoot, [lane])) {
42
+ const content = readText(file.absolutePath);
43
+ if (content === null)
44
+ continue;
45
+ const entity = readAuthoredEntity(content, file.relativePath);
46
+ if (entity !== null)
47
+ entities.push({ entity, content, relativePath: file.relativePath });
48
+ }
49
+ return entities;
50
+ }
51
+ /**
52
+ * An end-to-end test with a proof contract whose newest receipt passed: the
53
+ * least a requirement needs to have been tested, judged on the receipt the
54
+ * evidence ladder reads. A contract that was never run through kibi prove,
55
+ * one whose latest run failed, or a unit-scoped one cannot reach tested.
56
+ */
57
+ function hasPassingProof(entity) {
58
+ if (entity.data.proof_contract === undefined)
59
+ return false;
60
+ if (entity.data.verification_scope !== "end_to_end")
61
+ return false;
62
+ const receipts = entity.data.proof_receipts;
63
+ if (!Array.isArray(receipts) || receipts.length === 0)
64
+ return false;
65
+ const latest = receipts.reduce((best, receipt, index) => {
66
+ if (receipt === null || typeof receipt !== "object")
67
+ return best;
68
+ const record = receipt;
69
+ // Finish times increase strictly; history order is the fallback.
70
+ const at = typeof record.finished_at === "string"
71
+ ? record.finished_at
72
+ : String(index).padStart(12, "0");
73
+ return best === null || at >= best.at
74
+ ? { at, outcome: record.outcome }
75
+ : best;
76
+ }, null);
77
+ return latest?.outcome === "passed";
78
+ }
79
+ /**
80
+ * Requirement ids with a proof path: a linked scenario (specified_by) that an
81
+ * end-to-end test with a proof contract and a passing receipt verifies
82
+ * (scenario verified_by test, or test validates scenario), read from authored
83
+ * links and relationship shards.
84
+ */
85
+ function requirementsWithProofPath(workspaceRoot, requirements) {
86
+ const scenariosOf = new Map();
87
+ const testsOf = new Map();
88
+ const add = (map, from, to) => {
89
+ const set = map.get(from) ?? new Set();
90
+ set.add(to);
91
+ map.set(from, set);
92
+ };
93
+ for (const requirement of requirements)
94
+ for (const target of linkTargets(requirement, "specified_by"))
95
+ add(scenariosOf, requirement.id, target);
96
+ for (const { entity } of authoredEntities(workspaceRoot, "scenarios"))
97
+ for (const target of linkTargets(entity, "verified_by"))
98
+ add(testsOf, entity.id, target);
99
+ const contracted = new Set();
100
+ for (const { entity } of authoredEntities(workspaceRoot, "tests")) {
101
+ if (hasPassingProof(entity))
102
+ contracted.add(entity.id);
103
+ for (const target of linkTargets(entity, "validates"))
104
+ add(testsOf, target, entity.id);
105
+ }
106
+ try {
107
+ for (const relationship of readAllShards(path.join(workspaceRoot, ".kb"))) {
108
+ if (relationship.type === "specified_by")
109
+ add(scenariosOf, relationship.from, relationship.to);
110
+ else if (relationship.type === "verified_by")
111
+ add(testsOf, relationship.from, relationship.to);
112
+ else if (relationship.type === "validates")
113
+ add(testsOf, relationship.to, relationship.from);
114
+ }
115
+ }
116
+ catch {
117
+ // Malformed shards fail sync with their own diagnostic.
118
+ }
119
+ const withPath = new Set();
120
+ for (const [requirementId, scenarios] of scenariosOf)
121
+ for (const scenarioId of scenarios)
122
+ for (const testId of testsOf.get(scenarioId) ?? [])
123
+ if (contracted.has(testId))
124
+ withPath.add(requirementId);
125
+ return withPath;
126
+ }
127
+ /**
128
+ * Current firm requirements without required_evidence and without a proof
129
+ * path that has passed. From schema 11 a firm requirement needs tested
130
+ * evidence, which these have not reached, so the migration records their
131
+ * floor as asserted in the requirement itself, where a reviewer sees it and
132
+ * can raise it later. Requirements with a passing proof path keep the tested
133
+ * floor; `kept` lists them, since remaining gaps (a stale receipt, a missing
134
+ * covered_by) still show in kibi check. Read-only.
135
+ */
136
+ // implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
137
+ export function planEvidenceFloorPins(workspaceRoot, ladder) {
138
+ const files = authoredEntities(workspaceRoot, "requirements").filter(({ entity }) => entity.type === "req");
139
+ const requirements = files.map(({ entity }) => entity);
140
+ const superseded = authoredSupersededIds(workspaceRoot, requirements);
141
+ const withPath = requirementsWithProofPath(workspaceRoot, requirements);
142
+ const targets = [];
143
+ const kept = [];
144
+ const skipped = [];
145
+ for (const { entity, content, relativePath } of files) {
146
+ if (entity.data.required_evidence !== undefined ||
147
+ entity.data.proof_exempt === true ||
148
+ !isCurrentAuthoredEntity(entity, superseded) ||
149
+ effectiveFirmness(entity.type, entity.data.firmness, entity.data.origin) !== "firm")
150
+ continue;
151
+ // The ladder on the compiled store judges every gap (failed latest
152
+ // receipts, missing coverage or coordinates), so a requirement it puts
153
+ // below the tested floor is pinned even with a passing receipt; one
154
+ // without any authored proof path is pinned whatever the store says,
155
+ // since the store may predate the authored sources.
156
+ if (withPath.has(entity.id) && ladder?.get(entity.id) !== "below") {
157
+ kept.push(entity.id);
158
+ continue;
159
+ }
160
+ const after = withTopLevelField(content, "required_evidence", PINNED_FLOOR);
161
+ if (after === null) {
162
+ skipped.push({
163
+ id: entity.id,
164
+ path: relativePath,
165
+ reason: "required_evidence could not be edited safely",
166
+ });
167
+ continue;
168
+ }
169
+ targets.push({
170
+ id: entity.id,
171
+ type: entity.type,
172
+ path: relativePath,
173
+ before: content,
174
+ after,
175
+ });
176
+ }
177
+ return {
178
+ targets,
179
+ skipped,
180
+ kept,
181
+ decidedBy: ladder === undefined || ladder === null ? "authored" : "ladder",
182
+ };
183
+ }
184
+ /** Write the planned floors; returns how many requirements were rewritten. */
185
+ // implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
186
+ export function applyEvidenceFloorPins(workspaceRoot, ladder) {
187
+ const plan = planEvidenceFloorPins(workspaceRoot, ladder);
188
+ for (const target of plan.targets)
189
+ writeFileAtomically(path.join(workspaceRoot, target.path), target.after);
190
+ return plan.targets.length;
191
+ }
192
+ /**
193
+ * Read the evidence ladder's floor verdicts from the branch's compiled store,
194
+ * so the migration keeps the tested floor only where kibi check will accept
195
+ * it. Returns null when no healthy, synced store is attached (never synced,
196
+ * damaged, another branch's store) or the evaluation fails; the migration
197
+ * then decides from authored receipts alone and says so.
198
+ */
199
+ // implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
200
+ export async function readLadderFloorVerdicts(workspaceRoot) {
201
+ try {
202
+ const [{ createCliRuntime }, { executeOperation }, { statusSpec }, { readEvidenceFloorRows },] = await Promise.all([
203
+ import("../../runtime/cli-runtime.js"),
204
+ import("../../public/operations/runtime-types.js"),
205
+ import("../../public/operations/specs/discovery.js"),
206
+ import("../../public/operations/evidence-floor.js"),
207
+ ]);
208
+ const runtime = createCliRuntime({ workspaceRoot });
209
+ const status = (await executeOperation(runtime, statusSpec, {}))
210
+ .structuredContent;
211
+ if (status?.branchStore?.state !== "healthy" ||
212
+ status?.snapshotId === "missing" ||
213
+ status?.branchAttachment?.kind !== "exact")
214
+ return null;
215
+ const rows = await executeOperation(runtime, {
216
+ name: "kb_migrate_evidence_floor_preview",
217
+ effects: ["kb-read"],
218
+ requiresProlog: true,
219
+ execute: (_input, context) => readEvidenceFloorRows(context),
220
+ }, {});
221
+ const verdicts = new Map();
222
+ for (const row of rows)
223
+ if (row.requiredEvidence === "tested")
224
+ verdicts.set(row.id, row.status);
225
+ return verdicts;
226
+ }
227
+ catch {
228
+ return null;
229
+ }
230
+ }
@@ -0,0 +1,59 @@
1
+ import type { BodyContextTarget } from "./entity-body-context.js";
2
+ /** Schema 12: pin proves on a certificate contract with one provable claim. */
3
+ export declare const PROOF_CONTRACT_CLAIMS_PIN_CODE = "proof_contract_claims_pin";
4
+ /** Schema 12: certificate contracts a person must bind to their claims. */
5
+ export declare const PROOF_CONTRACT_CLAIMS_REVIEW_CODE = "proof_contract_claims_review";
6
+ /** A claim a certificate contract could prove: its fact derives an obligation. */
7
+ export type ClaimCandidate = Readonly<{
8
+ claim_key: string;
9
+ requirement_id: string;
10
+ fact_id: string;
11
+ }>;
12
+ /**
13
+ * A certificate-kind contract without proves, with the claims of the
14
+ * requirements its test reaches that its kind can derive an obligation for.
15
+ */
16
+ export type ClaimCandidateRow = Readonly<{
17
+ test_id: string;
18
+ kind: string;
19
+ candidates: readonly ClaimCandidate[];
20
+ }>;
21
+ export type ProofContractClaimsPlan = Readonly<{
22
+ targets: readonly BodyContextTarget[];
23
+ /** Contracts left without proves: none or several candidates. */
24
+ review: readonly Readonly<{
25
+ id: string;
26
+ path: string;
27
+ kind: string;
28
+ candidates: readonly string[];
29
+ }>[];
30
+ skipped: readonly Readonly<{
31
+ id: string;
32
+ path: string;
33
+ reason: string;
34
+ }>[];
35
+ }>;
36
+ /**
37
+ * Add proves to a test's proof_contract block, leaving every other byte of
38
+ * the document unchanged: the list goes after the block's last line, at the
39
+ * indentation of its other keys. Returns null when the contract is not a
40
+ * block mapping, already names proves, or the edit would not read back as
41
+ * exactly that change.
42
+ */
43
+ export declare function withProofContractProves(content: string, keys: readonly string[]): string | null;
44
+ /**
45
+ * Certificate-kind contracts without proves, judged on the synced store: a
46
+ * contract whose test reaches exactly one claim its kind can derive an
47
+ * obligation for gets that claim pinned in proves; any other is left for a
48
+ * person to bind (review). Read-only.
49
+ */
50
+ export declare function planProofContractClaimPins(workspaceRoot: string, rows: readonly ClaimCandidateRow[] | null): ProofContractClaimsPlan;
51
+ export declare function applyProofContractClaimPins(workspaceRoot: string, rows: readonly ClaimCandidateRow[] | null): ProofContractClaimsPlan;
52
+ /**
53
+ * The claim candidates of every certificate contract without proves, read
54
+ * from the branch's compiled store. Returns null when no healthy, synced
55
+ * store is attached or the evaluation fails; the migration then pins
56
+ * nothing, and proof-contract-claims lists the contracts.
57
+ */
58
+ export declare function readProofContractClaimCandidates(workspaceRoot: string): Promise<readonly ClaimCandidateRow[] | null>;
59
+ //# sourceMappingURL=proof-contract-claims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof-contract-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/proof-contract-claims.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,+EAA+E;AAE/E,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E,2EAA2E;AAE3E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF,kFAAkF;AAClF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,iEAAiE;IACjE,MAAM,EAAE,SA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