kibi-cli 0.17.0 → 0.19.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 (241) hide show
  1. package/dist/cli-json-command.d.ts +1 -2
  2. package/dist/cli-json-command.d.ts.map +1 -1
  3. package/dist/cli-json-command.js +88 -44
  4. package/dist/cli-operation-loader.d.ts +3 -0
  5. package/dist/cli-operation-loader.d.ts.map +1 -0
  6. package/dist/cli-operation-loader.js +58 -0
  7. package/dist/cli-operation-metadata.d.ts +82 -0
  8. package/dist/cli-operation-metadata.d.ts.map +1 -0
  9. package/dist/cli-operation-metadata.js +106 -0
  10. package/dist/cli-protocol.d.ts +1 -1
  11. package/dist/cli-protocol.d.ts.map +1 -1
  12. package/dist/cli-protocol.js +4 -3
  13. package/dist/cli-register-foundation.d.ts.map +1 -1
  14. package/dist/cli-register-foundation.js +14 -17
  15. package/dist/cli-register-json.d.ts +3 -0
  16. package/dist/cli-register-json.d.ts.map +1 -0
  17. package/dist/cli-register-json.js +35 -0
  18. package/dist/cli-register-maintenance.d.ts.map +1 -1
  19. package/dist/cli-register-maintenance.js +41 -8
  20. package/dist/cli-register-reporting.d.ts.map +1 -1
  21. package/dist/cli-register-reporting.js +18 -14
  22. package/dist/cli-register-skills.d.ts.map +1 -1
  23. package/dist/cli-register-skills.js +8 -6
  24. package/dist/cli.d.ts.map +1 -1
  25. package/dist/cli.js +3 -2
  26. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  27. package/dist/commands/aggregated-checks.js +1 -0
  28. package/dist/commands/check.d.ts.map +1 -1
  29. package/dist/commands/check.js +30 -12
  30. package/dist/commands/coverage.d.ts +5 -0
  31. package/dist/commands/coverage.d.ts.map +1 -1
  32. package/dist/commands/coverage.js +6 -1
  33. package/dist/commands/discovery-shared.d.ts +2 -1
  34. package/dist/commands/discovery-shared.d.ts.map +1 -1
  35. package/dist/commands/discovery-shared.js +35 -13
  36. package/dist/commands/discovery-table.d.ts.map +1 -1
  37. package/dist/commands/discovery-table.js +96 -5
  38. package/dist/commands/engine.d.ts +8 -0
  39. package/dist/commands/engine.d.ts.map +1 -0
  40. package/dist/commands/engine.js +100 -0
  41. package/dist/commands/gaps.js +1 -1
  42. package/dist/commands/graph.js +1 -1
  43. package/dist/commands/query.d.ts.map +1 -1
  44. package/dist/commands/query.js +3 -1
  45. package/dist/commands/search.d.ts.map +1 -1
  46. package/dist/commands/search.js +3 -1
  47. package/dist/commands/status.d.ts.map +1 -1
  48. package/dist/commands/status.js +2 -1
  49. package/dist/commands/sync/cache.d.ts +12 -0
  50. package/dist/commands/sync/cache.d.ts.map +1 -1
  51. package/dist/commands/sync/cache.js +38 -1
  52. package/dist/commands/sync/persistence.d.ts +10 -1
  53. package/dist/commands/sync/persistence.d.ts.map +1 -1
  54. package/dist/commands/sync/persistence.js +276 -43
  55. package/dist/commands/sync/staging.d.ts +10 -1
  56. package/dist/commands/sync/staging.d.ts.map +1 -1
  57. package/dist/commands/sync/staging.js +84 -1
  58. package/dist/commands/sync.d.ts.map +1 -1
  59. package/dist/commands/sync.js +521 -27
  60. package/dist/commands/usage-metrics.d.ts +66 -2
  61. package/dist/commands/usage-metrics.d.ts.map +1 -1
  62. package/dist/commands/usage-metrics.js +34 -24
  63. package/dist/commands/usage-remediation.d.ts +9 -0
  64. package/dist/commands/usage-remediation.d.ts.map +1 -0
  65. package/dist/commands/usage-remediation.js +52 -0
  66. package/dist/engine-daemon.d.ts +3 -0
  67. package/dist/engine-daemon.d.ts.map +1 -0
  68. package/dist/engine-daemon.js +34 -0
  69. package/dist/engine.d.ts +63 -0
  70. package/dist/engine.d.ts.map +1 -0
  71. package/dist/engine.js +1256 -0
  72. package/dist/extractors/markdown.d.ts +8 -0
  73. package/dist/extractors/markdown.d.ts.map +1 -1
  74. package/dist/extractors/markdown.js +69 -2
  75. package/dist/extractors/relationships.d.ts +2 -0
  76. package/dist/extractors/relationships.d.ts.map +1 -1
  77. package/dist/extractors/relationships.js +15 -17
  78. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
  79. package/dist/operations/modeling/logic-modeling.js +14 -5
  80. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  81. package/dist/operations/modeling/model-requirement.js +27 -2
  82. package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
  83. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  84. package/dist/operations/modeling/predicate-applyplan.js +18 -6
  85. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
  86. package/dist/operations/modeling/predicate-inference.js +5 -17
  87. package/dist/operations/modeling/predicate-loader.js +1 -1
  88. package/dist/operations/modeling/predicate-types.d.ts +9 -1
  89. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  90. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  91. package/dist/operations/modeling/suggest-predicates.js +35 -11
  92. package/dist/operations/mutation/audit.js +1 -1
  93. package/dist/operations/mutation/contradictions.d.ts +1 -1
  94. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  95. package/dist/operations/mutation/contradictions.js +23 -18
  96. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  97. package/dist/operations/mutation/serialization.js +6 -3
  98. package/dist/operations/mutation/upsert.d.ts +3 -1
  99. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  100. package/dist/operations/mutation/upsert.js +51 -12
  101. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  102. package/dist/operations/mutation/validate-upsert.js +18 -2
  103. package/dist/operations/mutation/validation.d.ts.map +1 -1
  104. package/dist/operations/mutation/validation.js +8 -0
  105. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  106. package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
  107. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  108. package/dist/operations/semantic-advisor/analyze-prose.js +76 -61
  109. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  110. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  111. package/dist/operations/semantic-advisor/clauses.js +7 -7
  112. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
  113. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
  114. package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
  115. package/dist/operations/semantic-advisor/shared.d.ts +8 -0
  116. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  117. package/dist/operations/semantic-advisor/shared.js +37 -3
  118. package/dist/operations/semantic-advisor/types.d.ts +5 -0
  119. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  120. package/dist/prolog/codec.d.ts.map +1 -1
  121. package/dist/prolog/codec.js +9 -2
  122. package/dist/prolog.d.ts +14 -0
  123. package/dist/prolog.d.ts.map +1 -1
  124. package/dist/prolog.js +279 -69
  125. package/dist/public/diagnostic-usage.d.ts +17 -0
  126. package/dist/public/diagnostic-usage.d.ts.map +1 -0
  127. package/dist/public/diagnostic-usage.js +152 -0
  128. package/dist/public/distribution-parity.d.ts +90 -0
  129. package/dist/public/distribution-parity.d.ts.map +1 -0
  130. package/dist/public/distribution-parity.js +367 -0
  131. package/dist/public/impact/full-kb-quality.d.ts +2 -0
  132. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  133. package/dist/public/impact/full-kb-quality.js +53 -1
  134. package/dist/public/impact-diagnostics.d.ts +2 -0
  135. package/dist/public/impact-diagnostics.d.ts.map +1 -1
  136. package/dist/public/impact-diagnostics.js +1 -0
  137. package/dist/public/operations/catalog.d.ts +151 -6
  138. package/dist/public/operations/catalog.d.ts.map +1 -1
  139. package/dist/public/operations/check-executor.d.ts.map +1 -1
  140. package/dist/public/operations/check-executor.js +4 -0
  141. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  142. package/dist/public/operations/discovery-entities.js +3 -2
  143. package/dist/public/operations/discovery-executors.d.ts +6 -0
  144. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  145. package/dist/public/operations/discovery-executors.js +58 -5
  146. package/dist/public/operations/index.d.ts +4 -0
  147. package/dist/public/operations/index.d.ts.map +1 -1
  148. package/dist/public/operations/index.js +4 -0
  149. package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
  150. package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
  151. package/dist/public/operations/legacy-migration-plan.js +409 -0
  152. package/dist/public/operations/node-ports.d.ts.map +1 -1
  153. package/dist/public/operations/node-ports.js +90 -0
  154. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  155. package/dist/public/operations/prolog-json.js +14 -4
  156. package/dist/public/operations/repair-plan.d.ts +184 -0
  157. package/dist/public/operations/repair-plan.d.ts.map +1 -0
  158. package/dist/public/operations/repair-plan.js +397 -0
  159. package/dist/public/operations/runtime-types.d.ts +38 -0
  160. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  161. package/dist/public/operations/specs/check.d.ts +2 -2
  162. package/dist/public/operations/specs/check.js +2 -2
  163. package/dist/public/operations/specs/discovery.d.ts +1 -1
  164. package/dist/public/operations/specs/discovery.js +1 -1
  165. package/dist/public/operations/specs/modeling.d.ts +19 -1
  166. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  167. package/dist/public/operations/specs/modeling.js +16 -1
  168. package/dist/public/operations/specs/mutation-schemas.d.ts +96 -1
  169. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  170. package/dist/public/operations/specs/mutation-schemas.js +40 -1
  171. package/dist/public/operations/specs/reporting.d.ts +42 -1
  172. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  173. package/dist/public/operations/specs/reporting.js +70 -6
  174. package/dist/public/operations/specs/semantic.js +1 -1
  175. package/dist/public/operations/specs/upsert.d.ts +96 -1
  176. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  177. package/dist/public/operations/workspace-snapshot.d.ts +10 -0
  178. package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
  179. package/dist/public/operations/workspace-snapshot.js +20 -0
  180. package/dist/public/schemas/entity.d.ts.map +1 -1
  181. package/dist/public/schemas/entity.js +43 -1
  182. package/dist/public/skills/init-kibi/SKILL.md +2 -2
  183. package/dist/public/skills/kibi-freshness/SKILL.md +2 -2
  184. package/dist/public/skills/kibi-traceability/SKILL.md +8 -2
  185. package/dist/public/skills/kibi-usage/SKILL.md +12 -6
  186. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
  187. package/dist/public/skills/kibi-usage/resources/logic-ir.md +1 -1
  188. package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -1
  189. package/dist/public/skills/kibi-usage/resources/workflows.md +19 -2
  190. package/dist/public/telemetry-acceptance.d.ts +89 -0
  191. package/dist/public/telemetry-acceptance.d.ts.map +1 -0
  192. package/dist/public/telemetry-acceptance.js +597 -0
  193. package/dist/public/telemetry-remediation.d.ts +33 -0
  194. package/dist/public/telemetry-remediation.d.ts.map +1 -0
  195. package/dist/public/telemetry-remediation.js +257 -0
  196. package/dist/public/verification-receipt.d.ts +75 -0
  197. package/dist/public/verification-receipt.d.ts.map +1 -0
  198. package/dist/public/verification-receipt.js +129 -0
  199. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  200. package/dist/runtime/cli-runtime.js +33 -37
  201. package/dist/schemas/entity.schema.json +96 -2
  202. package/dist/traceability/temp-kb.d.ts.map +1 -1
  203. package/dist/traceability/temp-kb.js +36 -3
  204. package/dist/types/entities.d.ts +1 -0
  205. package/dist/types/entities.d.ts.map +1 -1
  206. package/dist/utils/rule-registry.d.ts +2 -0
  207. package/dist/utils/rule-registry.d.ts.map +1 -1
  208. package/package.json +36 -4
  209. package/src/public/diagnostic-usage.ts +206 -0
  210. package/src/public/distribution-parity.ts +580 -0
  211. package/src/public/impact/full-kb-quality.ts +74 -1
  212. package/src/public/impact-diagnostics.ts +16 -0
  213. package/src/public/operations/check-executor.ts +4 -0
  214. package/src/public/operations/discovery-entities.ts +3 -2
  215. package/src/public/operations/discovery-executors.ts +68 -5
  216. package/src/public/operations/index.ts +4 -0
  217. package/src/public/operations/legacy-migration-plan.ts +688 -0
  218. package/src/public/operations/node-ports.ts +109 -0
  219. package/src/public/operations/prolog-json.ts +15 -3
  220. package/src/public/operations/repair-plan.ts +562 -0
  221. package/src/public/operations/runtime-types.ts +47 -0
  222. package/src/public/operations/specs/check.ts +2 -2
  223. package/src/public/operations/specs/discovery.ts +1 -1
  224. package/src/public/operations/specs/modeling.ts +19 -1
  225. package/src/public/operations/specs/mutation-schemas.ts +47 -1
  226. package/src/public/operations/specs/reporting.ts +91 -6
  227. package/src/public/operations/specs/semantic.ts +1 -1
  228. package/src/public/operations/workspace-snapshot.ts +28 -0
  229. package/src/public/schemas/entity.ts +44 -1
  230. package/src/public/skills/init-kibi/SKILL.md +2 -2
  231. package/src/public/skills/kibi-freshness/SKILL.md +2 -2
  232. package/src/public/skills/kibi-traceability/SKILL.md +8 -2
  233. package/src/public/skills/kibi-usage/SKILL.md +12 -6
  234. package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
  235. package/src/public/skills/kibi-usage/resources/logic-ir.md +1 -1
  236. package/src/public/skills/kibi-usage/resources/operation-access.md +1 -1
  237. package/src/public/skills/kibi-usage/resources/workflows.md +19 -2
  238. package/src/public/telemetry-acceptance.ts +859 -0
  239. package/src/public/telemetry-remediation.ts +462 -0
  240. package/src/public/verification-receipt.ts +170 -0
  241. package/src/schemas/entity.schema.json +96 -2
@@ -1,3 +1,4 @@
1
+ import { type VerificationReceipt } from "../public/verification-receipt.js";
1
2
  export interface ExtractedEntity {
2
3
  id: string;
3
4
  type: string;
@@ -11,7 +12,12 @@ export interface ExtractedEntity {
11
12
  priority?: string;
12
13
  severity?: string;
13
14
  text_ref?: string;
15
+ semantic_text?: string;
14
16
  logic_claims?: string[];
17
+ semantic_clauses?: string[];
18
+ semantic_inventory_version?: "kibi.semantic-inventory.v1";
19
+ semantic_source_field?: "semantic_text" | "text_ref" | "title";
20
+ semantic_source_hash?: string;
15
21
  granularity_reason?: string;
16
22
  symbol_kind?: string;
17
23
  symbol_role?: string;
@@ -21,6 +27,7 @@ export interface ExtractedEntity {
21
27
  sourceEndColumn?: number;
22
28
  verification_scope?: "unit" | "integration" | "end_to_end";
23
29
  verification_perspective?: "internal" | "consumer";
30
+ verification_receipts?: readonly VerificationReceipt[];
24
31
  fact_kind?: "subject" | "property_value" | "observation" | "meta" | "predicate_schema" | "predicate" | "rule_schema" | "rule";
25
32
  subject_key?: string;
26
33
  property_key?: string;
@@ -79,6 +86,7 @@ export declare class FrontmatterError extends Error {
79
86
  });
80
87
  toString(): string;
81
88
  }
89
+ export declare function requirementSemanticText(body: string): string;
82
90
  export declare function detectEmbeddedEntities(data: Record<string, unknown>, entityType: string): string[];
83
91
  export declare function extractFromMarkdownString(content: string, filePath: string): ExtractionResult;
84
92
  export declare function extractFromMarkdown(filePath: string): ExtractionResult;
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AAiFA,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,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,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AAC;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;AA+CD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAkBD,wBAAgB,sBAAsB,CAEpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAkDV;AAqYD,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"}
@@ -20,6 +20,7 @@ import { readFileSync } from "node:fs";
20
20
  import Ajv from "ajv";
21
21
  import { load as yamlLoad } from "js-yaml";
22
22
  import { semanticClaimKey } from "../operations/semantic-advisor/clauses.js";
23
+ import { verificationReceiptHistoryErrors, } from "../public/verification-receipt.js";
23
24
  import entitySchema from "../schemas/entity.schema.json" with { type: "json" };
24
25
  // Typed fact field constants for extraction
25
26
  const FACT_STRING_FIELDS = [
@@ -70,6 +71,7 @@ const FACT_ONLY_FIELDS = [
70
71
  const TEST_ENUM_FIELDS = [
71
72
  "verification_scope",
72
73
  "verification_perspective",
74
+ "verification_receipts",
73
75
  ];
74
76
  const ajv = new Ajv({ strict: false, allErrors: true });
75
77
  const validateExtractedEntity = ajv.compile(entitySchema);
@@ -230,6 +232,16 @@ function parseFrontmatter(content) {
230
232
  content: parts.slice(2).join("---"),
231
233
  };
232
234
  }
235
+ // implements REQ-kibi-legacy-migration-preview-v2
236
+ export function requirementSemanticText(body) {
237
+ return body
238
+ .replace(/\r\n?/g, "\n")
239
+ .split("\n")
240
+ .filter((line) => !/^\s{0,3}#{1,6}(?:\s+|$)/.test(line))
241
+ .map((line) => line.replace(/^\s*(?:(?:[-*+]|\d+[.)])\s+|>\s*)/, ""))
242
+ .join("\n")
243
+ .trim();
244
+ }
233
245
  function hasLikelyUnquotedColonInTitle(content) {
234
246
  if (!content.trim().startsWith("---")) {
235
247
  return false;
@@ -294,7 +306,7 @@ data, entityType) {
294
306
  // implements REQ-007, REQ-004
295
307
  function extractFromMarkdownContent(content, filePath) {
296
308
  try {
297
- const { data } = parseFrontmatter(content);
309
+ const { data, content: body } = parseFrontmatter(content);
298
310
  if (content.trim().startsWith("---")) {
299
311
  const parts = content.split("---");
300
312
  if (parts.length < 3) {
@@ -370,11 +382,32 @@ function extractFromMarkdownContent(content, filePath) {
370
382
  entity.priority = data.priority;
371
383
  if (data.severity !== undefined)
372
384
  entity.severity = data.severity;
373
- if (data.text_ref !== undefined)
385
+ if (data.text_ref !== undefined) {
374
386
  entity.text_ref = data.text_ref;
387
+ }
388
+ if (type === "req" && data.semantic_text !== undefined) {
389
+ entity.semantic_text = data.semantic_text;
390
+ }
391
+ else if (type === "req") {
392
+ const semanticText = requirementSemanticText(body);
393
+ if (semanticText)
394
+ entity.semantic_text = semanticText;
395
+ }
375
396
  if (type === "req" && Array.isArray(data.logic_claims)) {
376
397
  entity.logic_claims = data.logic_claims.filter((value) => typeof value === "string");
377
398
  }
399
+ if (type === "req" && Array.isArray(data.semantic_clauses)) {
400
+ entity.semantic_clauses = data.semantic_clauses.filter((value) => typeof value === "string");
401
+ }
402
+ if (type === "req" && data.semantic_inventory_version !== undefined) {
403
+ entity.semantic_inventory_version = data.semantic_inventory_version;
404
+ }
405
+ if (type === "req" && data.semantic_source_field !== undefined) {
406
+ entity.semantic_source_field = data.semantic_source_field;
407
+ }
408
+ if (type === "req" && data.semantic_source_hash !== undefined) {
409
+ entity.semantic_source_hash = data.semantic_source_hash;
410
+ }
378
411
  if (type !== "fact") {
379
412
  const invalidFactField = FACT_ONLY_FIELDS.find((field) => data[field] !== undefined);
380
413
  if (invalidFactField) {
@@ -412,6 +445,40 @@ function extractFromMarkdownContent(content, filePath) {
412
445
  }
413
446
  entity.verification_perspective = data.verification_perspective;
414
447
  }
448
+ if (data.verification_receipts !== undefined) {
449
+ if (!Array.isArray(data.verification_receipts)) {
450
+ throw new FrontmatterError("Invalid verification_receipts; expected an array", filePath, {
451
+ classification: "Invalid Test Verification Receipts",
452
+ hint: "Use append-only kibi.verification-receipt.v1 objects.",
453
+ });
454
+ }
455
+ const normalizedReceipts = data.verification_receipts.map((value) => {
456
+ if (typeof value !== "object" ||
457
+ value === null ||
458
+ Array.isArray(value)) {
459
+ return value;
460
+ }
461
+ return {
462
+ ...value,
463
+ ...(normalizeDateLike(value.started_at) !== undefined
464
+ ? { started_at: normalizeDateLike(value.started_at) }
465
+ : {}),
466
+ ...(normalizeDateLike(value.finished_at) !== undefined
467
+ ? { finished_at: normalizeDateLike(value.finished_at) }
468
+ : {}),
469
+ };
470
+ });
471
+ entity.verification_receipts = normalizedReceipts;
472
+ const errors = verificationReceiptHistoryErrors(entity.id, entity.verification_scope, normalizedReceipts.filter((value) => typeof value === "object" &&
473
+ value !== null &&
474
+ !Array.isArray(value)));
475
+ if (errors.length > 0) {
476
+ throw new FrontmatterError(errors.join("; "), filePath, {
477
+ classification: "Invalid Test Verification Receipts",
478
+ hint: "Bind every receipt to this test and its typed verification_scope, with unique IDs and ordered ISO-8601 timestamps.",
479
+ });
480
+ }
481
+ }
415
482
  }
416
483
  // Add typed fact fields only for fact entities
417
484
  //
@@ -20,6 +20,8 @@ export interface ShardExtractionResult {
20
20
  * @returns Array of extraction results, one per shard file
21
21
  */
22
22
  export declare function extractFromRelationshipShards(relationshipsDir: string): ShardExtractionResult[];
23
+ /** Parse one changed shard. Callers can hash first and skip unchanged files. */
24
+ export declare function extractRelationshipShard(shardPath: string): ShardExtractionResult;
23
25
  /**
24
26
  * Gets the path to the relationships directory for a given KB root.
25
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/extractors/relationships.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC;AAwBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,GACvB,qBAAqB,EAAE,CAyCzB;AAmDD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAAE,GAC/B,qBAAqB,EAAE,CAEzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EAAE,EACtC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAC1B,KAAK,CAAC;IACP,YAAY,EAAE,qBAAqB,CAAC;IACpC,KAAK,EAAE,cAAc,GAAG,YAAY,CAAC;CACtC,CAAC,CAgBD"}
1
+ {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/extractors/relationships.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC;AAwBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,GACvB,qBAAqB,EAAE,CAmBzB;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,GAChB,qBAAqB,CAiBvB;AAmDD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAAE,GAC/B,qBAAqB,EAAE,CAEzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EAAE,EACtC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAC1B,KAAK,CAAC;IACP,YAAY,EAAE,qBAAqB,CAAC;IACpC,KAAK,EAAE,cAAc,GAAG,YAAY,CAAC;CACtC,CAAC,CAgBD"}
@@ -56,27 +56,25 @@ export function extractFromRelationshipShards(relationshipsDir) {
56
56
  continue;
57
57
  }
58
58
  const shardPath = path.join(relationshipsDir, file);
59
- const stats = fs.statSync(shardPath);
60
- if (!stats.isFile()) {
59
+ if (!fs.statSync(shardPath).isFile())
61
60
  continue;
62
- }
63
- try {
64
- const records = readShard(shardPath);
65
- const relationships = records
66
- .map(convertRecordToRelationship)
67
- .filter((r) => r !== null);
68
- results.push({
69
- shardPath,
70
- relationships,
71
- });
72
- }
73
- catch (error) {
74
- // Re-throw with shard path context
75
- throw new Error(`Failed to extract relationships from ${shardPath}: ${error instanceof Error ? error.message : String(error)}`);
76
- }
61
+ results.push(extractRelationshipShard(shardPath));
77
62
  }
78
63
  return results;
79
64
  }
65
+ /** Parse one changed shard. Callers can hash first and skip unchanged files. */
66
+ export function extractRelationshipShard(shardPath) {
67
+ try {
68
+ const records = readShard(shardPath);
69
+ const relationships = records
70
+ .map(convertRecordToRelationship)
71
+ .filter((relationship) => relationship !== null);
72
+ return { shardPath, relationships };
73
+ }
74
+ catch (error) {
75
+ throw new Error(`Failed to extract relationships from ${shardPath}: ${error instanceof Error ? error.message : String(error)}`);
76
+ }
77
+ }
80
78
  /**
81
79
  * Converts a RelationshipRecord to an ExtractedRelationship.
82
80
  * Returns null if the record is invalid.
@@ -1 +1 @@
1
- {"version":3,"file":"logic-modeling.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/logic-modeling.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAIjB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,Q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AAO,CAAC,CAAC,CAAC;CACpD;AAUD,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,CAsHtB"}
@@ -1,6 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { logicSemanticKey, utf8Span, validateLogicIr, } from "../../logic/ir.js";
3
- import { semanticClaimKey } from "../semantic-advisor/clauses.js";
3
+ import { normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
4
+ import { semanticSourceHash } from "../semantic-advisor/shared.js";
4
5
  function shortId(value) {
5
6
  return createHash("sha256")
6
7
  .update(value)
@@ -20,12 +21,14 @@ export function buildLogicApplyPlan(input) {
20
21
  !validation.renderedProlog) {
21
22
  throw new Error(`Logic IR validation failed: ${validation.errors.join("; ")}`);
22
23
  }
23
- const claimText = input.claimText?.trim() || input.text.trim();
24
+ const sourceText = input.claimText?.trim() || input.text.trim();
25
+ const claimText = normalizeSemanticClause(sourceText);
24
26
  const claimKey = input.claimKey || semanticClaimKey(claimText);
25
27
  const semanticKey = logicSemanticKey(validation.normalized);
26
28
  const schemaId = validation.normalized.ruleSchemaId ?? "FACT-RULE-SCHEMA-LOGIC-V1";
27
29
  const ruleId = logicRuleFactId(semanticKey);
28
- const span = utf8Span(input.text, 0, input.text.length);
30
+ const claimStart = input.text.indexOf(claimText);
31
+ const span = utf8Span(input.text, claimStart >= 0 ? claimStart : 0, claimStart >= 0 ? claimStart + claimText.length : claimText.length);
29
32
  const logicClaims = Array.from(new Set([...(input.existingLogicClaims ?? []), claimKey]));
30
33
  const schemaPlan = input.logic.ruleSchemaId
31
34
  ? []
@@ -85,13 +88,19 @@ export function buildLogicApplyPlan(input) {
85
88
  title: claimText.split(/[.!?]/, 1)[0] || "Typed logical requirement",
86
89
  status: "open",
87
90
  source: input.source,
88
- text_ref: claimText,
91
+ semantic_text: input.text.trim(),
89
92
  logic_claims: logicClaims,
93
+ semantic_clauses: [claimText],
94
+ semantic_inventory_version: "kibi.semantic-inventory.v1",
95
+ semantic_source_field: "semantic_text",
96
+ semantic_source_hash: semanticSourceHash(input.text.trim()),
90
97
  semantic_inventory: [
91
98
  {
92
99
  claim_key: claimKey,
93
100
  claim_text: claimText,
94
- role: "normative",
101
+ role: /\b(?:must|shall|should|required|requires?)\b/i.test(claimText)
102
+ ? "normative"
103
+ : "descriptive",
95
104
  status: "modeled",
96
105
  span,
97
106
  semantic_key: semanticKey,
@@ -1 +1 @@
1
- {"version":3,"file":"model-requirement.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/model-requirement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAIjF,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAMhC,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GACxB,CAAC;AAEF,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBxB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,oBAAoB,EAC1B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,CAAC,CA4IjC;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAEjC"}
1
+ {"version":3,"file":"model-requirement.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/model-requirement.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAQjF,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAMhC,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GACxB,CAAC;AAEF,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBxB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,oBAAoB,EAC1B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,CAAC,CAsKjC;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAEjC"}
@@ -2,7 +2,8 @@ import { readFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { buildStrictWriteSet } from "../../public/check-types.js";
4
4
  import { getSchemaVersionStatus } from "../../public/schema-version.js";
5
- import { semanticClaimKey } from "../semantic-advisor/clauses.js";
5
+ import { normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
6
+ import { semanticSourceHash } from "../semantic-advisor/shared.js";
6
7
  import { buildLogicApplyPlan } from "./logic-modeling.js";
7
8
  import { strictWriteSetToApplyPlan, writeSetPrimaryEntityId, } from "./requirement-applyplan.js";
8
9
  import { estimateNormativeSignalConfidence, extractRequirementClaim, } from "./requirement-modeler.js";
@@ -108,9 +109,33 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
108
109
  };
109
110
  }
110
111
  if (step.type === "req") {
112
+ const claimText = extracted.statement.trim();
113
+ const normalizedClaimText = normalizeSemanticClause(claimText);
111
114
  return {
112
115
  ...step,
113
- properties: { ...properties, logic_claims: logicClaims },
116
+ properties: {
117
+ ...properties,
118
+ semantic_text: claimText,
119
+ logic_claims: logicClaims,
120
+ semantic_clauses: [claimText],
121
+ semantic_inventory_version: "kibi.semantic-inventory.v1",
122
+ semantic_source_field: "semantic_text",
123
+ semantic_source_hash: semanticSourceHash(claimText),
124
+ semantic_inventory: [
125
+ {
126
+ claim_key: claimKey,
127
+ claim_text: normalizedClaimText,
128
+ role: /\b(?:must|shall|should|required|requires?)\b/i.test(claimText)
129
+ ? "normative"
130
+ : "descriptive",
131
+ status: "modeled",
132
+ span: {
133
+ start: 0,
134
+ end: Buffer.byteLength(normalizedClaimText, "utf8"),
135
+ },
136
+ },
137
+ ],
138
+ },
114
139
  };
115
140
  }
116
141
  return step;
@@ -1,5 +1,5 @@
1
1
  import type { PredicateSchemaCandidate, PredicateSuggestion, SuggestPredicatesArgs } from "./predicate-types.js";
2
- export declare function buildSuggestion(schema: PredicateSchemaCandidate, text: string, subject: string, score: number): PredicateSuggestion;
2
+ export declare function buildSuggestion(schema: PredicateSchemaCandidate, text: string, subject: string, score: number, argumentBindings?: Readonly<Record<string, string>>, polarityHint?: "assert" | "deny"): PredicateSuggestion;
3
3
  export declare function buildPredicateApplyPlan(suggestion: PredicateSuggestion, args: SuggestPredicatesArgs): Array<Record<string, unknown>>;
4
4
  export declare function buildRelationshipPlan(factId: string | undefined, requirementId: string | undefined, claimText?: string, existingLogicClaims?: readonly string[]): Record<string, unknown> | null;
5
5
  export declare function buildGapApplyPlan(text: string, args: SuggestPredicatesArgs): Array<Record<string, unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,mBAAmB,CAuBrB;AAGD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAgChC;AAGD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAwBhC;AAGD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+BhC"}
1
+ {"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,EACvD,YAAY,CAAC,EAAE,QAAQ,GAAG,MAAM,GAC/B,mBAAmB,CAmCrB;AAGD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAiChC;AAGD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAwBhC;AAGD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+BhC"}
@@ -3,22 +3,32 @@ import { inferArgs } from "./predicate-inference.js";
3
3
  import { schemaForCandidate } from "./predicate-loader.js";
4
4
  import { hashId } from "./predicate-utils.js";
5
5
  // implements REQ-mcp-suggest-predicates
6
- export function buildSuggestion(schema, text, subject, score) {
7
- const predicateArgs = inferArgs(schema, text, subject);
6
+ export function buildSuggestion(schema, text, subject, score, argumentBindings = {}, polarityHint) {
7
+ const inferredArgs = inferArgs(schema, text, subject);
8
+ const predicateArgs = schema.argument_names.map((name, index) => {
9
+ const exactBinding = argumentBindings[name];
10
+ return typeof exactBinding === "string" && exactBinding.trim().length > 0
11
+ ? exactBinding.trim()
12
+ : (inferredArgs[index] ?? "unknown");
13
+ });
14
+ const unboundArguments = schema.argument_names.filter((_name, index) => predicateArgs[index] === "unknown");
8
15
  const canonicalKey = `${schema.predicate_name}(${predicateArgs.join(",")})`;
9
16
  // Permission-style inference carries the deontic decision as its final
10
17
  // argument. Preserve that polarity in the typed suggestion instead of
11
18
  // silently turning a prohibition into an assertion.
12
- const polarity = predicateArgs.at(-1) === "deny" ||
13
- /\b(?:must\s+not|shall\s+not|never|cannot|can't|forbidden|prohibited)\b/i.test(text)
14
- ? "deny"
15
- : "assert";
19
+ const polarity = polarityHint ??
20
+ (predicateArgs.at(-1) === "deny" ||
21
+ /\b(?:must\s+not|shall\s+not|never|cannot|can't|forbidden|prohibited)\b/i.test(text)
22
+ ? "deny"
23
+ : "assert");
16
24
  return {
17
25
  id: hashId("SUGGEST", [schema.id, canonicalKey, text]),
18
26
  predicate_name: schema.predicate_name,
19
27
  predicate_args: predicateArgs,
20
28
  canonical_key: canonicalKey,
21
29
  polarity,
30
+ binding_status: unboundArguments.length === 0 ? "complete" : "incomplete",
31
+ unbound_arguments: unboundArguments,
22
32
  score,
23
33
  rationale: `Matched ${schema.predicate_name} because the prose overlaps with ${schema.tags.join(", ")} cues.`,
24
34
  schema: schemaForCandidate(schema),
@@ -26,6 +36,8 @@ export function buildSuggestion(schema, text, subject, score) {
26
36
  }
27
37
  // implements REQ-mcp-suggest-predicates
28
38
  export function buildPredicateApplyPlan(suggestion, args) {
39
+ if (suggestion.binding_status !== "complete")
40
+ return [];
29
41
  const claimKey = semanticClaimKey(args.text);
30
42
  const factId = hashId("FACT-PRED", [
31
43
  args.requirementId ?? "",
@@ -1 +1 @@
1
- {"version":3,"file":"predicate-inference.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-inference.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EASL,YAAY,EAKb,MAAM,sBAAsB,CAAC;AAG9B,wBAAgB,SAAS,CACvB,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CA0JV;AAGD,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"predicate-inference.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-inference.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EASL,YAAY,EAIb,MAAM,sBAAsB,CAAC;AAG9B,wBAAgB,SAAS,CACvB,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAiJV;AAGD,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { inferAuditEventRuleArgs, inferAvailabilitySlaArgs, inferConsentRuleArgs, inferDataResidencyRuleArgs, inferDependencyRuleArgs, inferEscalationRuleArgs, inferExceptionRuleArgs, inferGuardArgs, inferIdempotencyRuleArgs, inferLifecycleRuleArgs, inferMutualExclusionArgs, inferNotificationRouteArgs, inferOwnershipRuleArgs, inferPermissionRuleArgs, inferRetryPolicyArgs, } from "./predicate-inference-1.js";
2
2
  import { inferAbsenceRequirementArgs, inferAbstractionBoundaryRuleArgs, inferBatchOperationRuleArgs, inferBuildConstraintArgs, inferCodingStandardRuleArgs, inferConflictResolutionRuleArgs, inferConsistencyRuleArgs, inferEnvironmentSafetyRuleArgs, inferFallbackRuleArgs, inferMigrationBoundaryRuleArgs, inferOfflineBehaviorRuleArgs, inferOrderedStrategyRuleArgs, inferPlatformConsistencyRuleArgs, inferPreservationRuleArgs, inferRefreshPolicyRuleArgs, inferReleaseGateRuleArgs, inferSchemaInvariantRuleArgs, inferSecurityConfigurationRuleArgs, } from "./predicate-inference-2.js";
3
3
  import { inferConditionalBehaviorArgs, inferDefaultValueArgs, inferDocumentationStandardRuleArgs, inferEnforcementLocationRuleArgs, inferRateLimitArgs, inferReconciliationRuleArgs, inferScopedAuthorizationRuleArgs, inferStateMembershipArgs, inferStateTransitionArgs, inferTemporalOrderArgs, inferThrottlePolicyRuleArgs, inferUniquenessArgs, inferVisualLayoutRuleArgs, inferWarmupPolicyRuleArgs, } from "./predicate-inference-3.js";
4
- import { inferDuration, inferDurationUnit, inferEvent, inferGate, inferNumber, inferOperator, inferResource, inferScope, inferSubject, inferTrigger, inferUnit, normalizePredicateToken, slug, } from "./predicate-utils.js";
4
+ import { inferDuration, inferDurationUnit, inferEvent, inferGate, inferNumber, inferOperator, inferResource, inferScope, inferSubject, inferTrigger, inferUnit, slug, } from "./predicate-utils.js";
5
5
  // implements REQ-mcp-suggest-predicates
6
6
  export function inferArgs(schema, text, subject) {
7
7
  const lower = text.toLowerCase();
@@ -141,22 +141,10 @@ export function inferArgs(schema, text, subject) {
141
141
  case "rate_limit":
142
142
  return inferRateLimitArgs(text);
143
143
  default:
144
- return schema.argument_names.map((name) => {
145
- if (name === "subject")
146
- return subject;
147
- const normalized = normalizePredicateToken(name);
148
- const words = normalized.split("_").filter((word) => word.length > 2);
149
- // Project-local schemas often use the exact domain vocabulary in
150
- // their ordered argument names. Reuse that declared value when the
151
- // complete name (or all meaningful words) occurs in the claim; keep
152
- // genuinely unbound arguments explicit instead of guessing.
153
- const phrase = words.join(" ");
154
- return phrase.length > 0 &&
155
- (lower.includes(phrase) ||
156
- words.every((word) => lower.includes(word)))
157
- ? normalized
158
- : "unknown";
159
- });
144
+ // A schema argument name declares a role, not its ground value. Only
145
+ // the conventional subject slot has a separately reviewed hint;
146
+ // project-local non-subject arguments require exact argumentBindings.
147
+ return schema.argument_names.map((name) => name === "subject" ? subject : "unknown");
160
148
  }
161
149
  }
162
150
  // implements REQ-mcp-suggest-predicates
@@ -27,7 +27,7 @@ export async function loadExistingPredicateSchemas(prolog, includeExistingSchema
27
27
  return [];
28
28
  }
29
29
  try {
30
- const queryResult = await prolog.query("findall([Id,'fact',Props], (kb_entity(Id, 'fact', Props), member(fact_kind=predicate_schema, Props)), Results)");
30
+ const queryResult = await prolog.query("findall([Id,'fact',Props], (kb:predicate_schema(Id, _Namespace, _Name, _Arity, _ArgumentNames, _ArgumentTypes), kb_entity(Id, 'fact', Props)), Results)");
31
31
  if (!queryResult.success) {
32
32
  throw new Error(queryResult.error || "Query failed with unknown error");
33
33
  }
@@ -26,6 +26,12 @@ export type SuggestPredicatesArgs = Readonly<Record<string, unknown>> & {
26
26
  readonly maxCandidates?: number;
27
27
  readonly minScore?: number;
28
28
  readonly includeExistingSchemas?: boolean;
29
+ /** Exact reviewed schema candidate ID to select instead of lexical ranking. */
30
+ readonly schemaId?: string;
31
+ /** Exact values keyed by the selected predicate schema's argument_names. */
32
+ readonly argumentBindings?: Readonly<Record<string, string>>;
33
+ /** Reviewed polarity override for negation-scope false positives. */
34
+ readonly polarityHint?: PredicatePolarity;
29
35
  /** Existing requirement claim manifest. Relationship guidance merges this list. */
30
36
  readonly existingLogicClaims?: readonly string[];
31
37
  };
@@ -35,6 +41,8 @@ export interface PredicateSuggestion {
35
41
  predicate_args: string[];
36
42
  canonical_key: string;
37
43
  polarity: PredicatePolarity;
44
+ binding_status: "complete" | "incomplete";
45
+ unbound_arguments: string[];
38
46
  score: number;
39
47
  rationale: string;
40
48
  schema: Omit<PredicateSchemaCandidate, "keywords"> & {
@@ -54,7 +62,7 @@ export interface SuggestPredicatesResult {
54
62
  requirementId: string | null;
55
63
  subject: string;
56
64
  candidates: PredicateSuggestion[];
57
- recommendedAction: "apply_requires_predicate" | "record_ontology_gap";
65
+ recommendedAction: "apply_requires_predicate" | "provide_argument_bindings" | "resolve_schema_reference" | "record_ontology_gap";
58
66
  applyPlan: Array<Record<string, unknown>>;
59
67
  relationshipPlan: Record<string, unknown> | null;
60
68
  warnings: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"predicate-types.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAGlD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAGD,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CA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C;IAC1C,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,IAAI,CAAC,wBAAwB,EAAE,UAAU,CAAC,GAAG;QACnD,WAAW,EAAE,mBAAmB,CAAC;KAClC,CAAC;CACH;AAGD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,mBAAmB,EAAE,CAAC;QAClC,iBAAiB,EACb,0BAA0B,GAC1B,2BAA2B,GAC3B,0BAA0B,GAC1B,qBAAqB,CAAC;QAC1B,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACjD,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AAYlD,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAK9B,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CA4ElC;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
1
+ {"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AAYlD,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAK9B,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CA+GlC;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
@@ -15,30 +15,54 @@ export async function handleKbSuggestPredicates(prolog, args) {
15
15
  const subject = inferSubject(text, args.subjectHint);
16
16
  const existingSchemas = await loadExistingPredicateSchemas(prolog, args.includeExistingSchemas ?? true, warnings);
17
17
  const schemas = [...existingSchemas, ...BUILT_IN_PREDICATE_SCHEMAS];
18
- const candidates = schemas
18
+ const selectedSchemas = args.schemaId
19
+ ? schemas.filter((schema) => schema.id === args.schemaId)
20
+ : schemas;
21
+ if (args.schemaId && selectedSchemas.length === 0) {
22
+ warnings.push(`Requested predicate schema ${args.schemaId} is not available. Refresh the KB or correct schemaId before retrying; no ontology-gap or predicate write plan was generated.`);
23
+ }
24
+ const candidates = selectedSchemas
19
25
  .map((schema) => ({ schema, score: scoreSchema(schema, text) }))
20
- .filter((scored) => scored.score >= minScore)
26
+ .filter((scored) => args.schemaId || scored.score >= minScore)
21
27
  .sort((left, right) => {
22
28
  if (right.score !== left.score)
23
29
  return right.score - left.score;
24
30
  return left.schema.predicate_name.localeCompare(right.schema.predicate_name);
25
31
  })
26
32
  .slice(0, maxCandidates)
27
- .map((scored) => buildSuggestion(scored.schema, text, subject, scored.score));
28
- if (candidates.length === 0) {
33
+ .map((scored) => buildSuggestion(scored.schema, text, subject, scored.score, args.argumentBindings, args.polarityHint));
34
+ if (candidates.length === 0 && !args.schemaId) {
29
35
  warnings.push("No predicate candidate met minScore. If this is recurring domain language, create a fact_kind=predicate_schema fact; otherwise keep the generated review:ontology-gap observation. Do not invent unsupported predicate names without a predicate_schema.");
30
36
  }
31
- const recommendedAction = candidates.length > 0 ? "apply_requires_predicate" : "record_ontology_gap";
32
37
  const firstCandidate = candidates[0];
33
- const applyPlan = firstCandidate
34
- ? buildPredicateApplyPlan(firstCandidate, args)
35
- : buildGapApplyPlan(text, args);
36
- const relationshipPlan = firstCandidate
38
+ const bindingsComplete = firstCandidate?.binding_status === "complete";
39
+ if (firstCandidate && !bindingsComplete) {
40
+ warnings.push(`Top predicate candidate ${firstCandidate.predicate_name} has unbound arguments: ${firstCandidate.unbound_arguments.join(", ")}. Supply exact argumentBindings keyed by the schema's argument_names before applying it.`);
41
+ }
42
+ const recommendedAction = !firstCandidate
43
+ ? args.schemaId
44
+ ? "resolve_schema_reference"
45
+ : "record_ontology_gap"
46
+ : bindingsComplete
47
+ ? "apply_requires_predicate"
48
+ : "provide_argument_bindings";
49
+ const applyPlan = !firstCandidate
50
+ ? args.schemaId
51
+ ? []
52
+ : buildGapApplyPlan(text, args)
53
+ : bindingsComplete
54
+ ? buildPredicateApplyPlan(firstCandidate, args)
55
+ : [];
56
+ const relationshipPlan = firstCandidate && bindingsComplete
37
57
  ? buildRelationshipPlan(String(applyPlan[0]?.id ?? ""), args.requirementId, text, args.existingLogicClaims)
38
58
  : null;
39
- const textSummary = candidates.length > 0
59
+ const textSummary = firstCandidate && bindingsComplete
40
60
  ? `Suggested ${candidates.length} predicate candidate(s). Top match: ${candidates[0]?.predicate_name}. Apply structured predicate facts before falling back to prose.`
41
- : "No predicate candidate met the confidence threshold; record an ontology gap instead of silently writing prose.";
61
+ : firstCandidate
62
+ ? `Matched ${firstCandidate.predicate_name}, but exact values are still required for: ${firstCandidate.unbound_arguments.join(", ")}. No apply plan was generated.`
63
+ : args.schemaId
64
+ ? `Requested predicate schema ${args.schemaId} is unavailable. No apply plan was generated.`
65
+ : "No predicate candidate met the confidence threshold; record an ontology gap instead of silently writing prose.";
42
66
  const claimKey = semanticClaimKey(text);
43
67
  const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
44
68
  return {
@@ -17,6 +17,6 @@ export async function recordRelationshipAudits(prolog, relationships) {
17
17
  }
18
18
  }
19
19
  export function buildEntityDeleteAuditGoal(entity) {
20
- const auditEntity = Object.fromEntries(["id", "title", "source", "text_ref"].flatMap((key) => typeof entity[key] === "string" ? [[key, entity[key]]] : []));
20
+ const auditEntity = Object.fromEntries(["id", "title", "source", "text_ref", "semantic_text"].flatMap((key) => typeof entity[key] === "string" ? [[key, entity[key]]] : []));
21
21
  return `kb_retract_entity('${escapeAtom(String(entity.id))}', ${String(entity.type)}, ${buildPropertyList(auditEntity)})`;
22
22
  }
@@ -4,7 +4,7 @@ type TransactionInput = {
4
4
  readonly relationships: readonly RelationshipInput[];
5
5
  readonly skipContradictionCheck: boolean;
6
6
  };
7
- export declare function buildUpsertTransaction(input: TransactionInput): string;
7
+ export declare function buildUpsertCommitGoal(input: TransactionInput): string;
8
8
  export declare function formatUpsertError(entityId: string, raw?: string): string;
9
9
  export {};
10
10
  //# sourceMappingURL=contradictions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CActE;AAGD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CA0BxE"}
1
+ {"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAOrE;AAGD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CA6CxE"}