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.
- package/dist/cli-json-command.d.ts +1 -2
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +88 -44
- package/dist/cli-operation-loader.d.ts +3 -0
- package/dist/cli-operation-loader.d.ts.map +1 -0
- package/dist/cli-operation-loader.js +58 -0
- package/dist/cli-operation-metadata.d.ts +82 -0
- package/dist/cli-operation-metadata.d.ts.map +1 -0
- package/dist/cli-operation-metadata.js +106 -0
- package/dist/cli-protocol.d.ts +1 -1
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +4 -3
- package/dist/cli-register-foundation.d.ts.map +1 -1
- package/dist/cli-register-foundation.js +14 -17
- package/dist/cli-register-json.d.ts +3 -0
- package/dist/cli-register-json.d.ts.map +1 -0
- package/dist/cli-register-json.js +35 -0
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +41 -8
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +18 -14
- package/dist/cli-register-skills.d.ts.map +1 -1
- package/dist/cli-register-skills.js +8 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -2
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +1 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +30 -12
- package/dist/commands/coverage.d.ts +5 -0
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +6 -1
- package/dist/commands/discovery-shared.d.ts +2 -1
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +35 -13
- package/dist/commands/discovery-table.d.ts.map +1 -1
- package/dist/commands/discovery-table.js +96 -5
- package/dist/commands/engine.d.ts +8 -0
- package/dist/commands/engine.d.ts.map +1 -0
- package/dist/commands/engine.js +100 -0
- package/dist/commands/gaps.js +1 -1
- package/dist/commands/graph.js +1 -1
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +3 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +3 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +2 -1
- package/dist/commands/sync/cache.d.ts +12 -0
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +38 -1
- package/dist/commands/sync/persistence.d.ts +10 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +276 -43
- package/dist/commands/sync/staging.d.ts +10 -1
- package/dist/commands/sync/staging.d.ts.map +1 -1
- package/dist/commands/sync/staging.js +84 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +521 -27
- package/dist/commands/usage-metrics.d.ts +66 -2
- package/dist/commands/usage-metrics.d.ts.map +1 -1
- package/dist/commands/usage-metrics.js +34 -24
- package/dist/commands/usage-remediation.d.ts +9 -0
- package/dist/commands/usage-remediation.d.ts.map +1 -0
- package/dist/commands/usage-remediation.js +52 -0
- package/dist/engine-daemon.d.ts +3 -0
- package/dist/engine-daemon.d.ts.map +1 -0
- package/dist/engine-daemon.js +34 -0
- package/dist/engine.d.ts +63 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +1256 -0
- package/dist/extractors/markdown.d.ts +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +69 -2
- package/dist/extractors/relationships.d.ts +2 -0
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +15 -17
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +14 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +27 -2
- package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +18 -6
- package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-inference.js +5 -17
- package/dist/operations/modeling/predicate-loader.js +1 -1
- package/dist/operations/modeling/predicate-types.d.ts +9 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +35 -11
- package/dist/operations/mutation/audit.js +1 -1
- package/dist/operations/mutation/contradictions.d.ts +1 -1
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +23 -18
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +6 -3
- package/dist/operations/mutation/upsert.d.ts +3 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +51 -12
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +18 -2
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +8 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +76 -61
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +7 -7
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
- package/dist/operations/semantic-advisor/shared.d.ts +8 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/shared.js +37 -3
- package/dist/operations/semantic-advisor/types.d.ts +5 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +9 -2
- package/dist/prolog.d.ts +14 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +279 -69
- package/dist/public/diagnostic-usage.d.ts +17 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -0
- package/dist/public/diagnostic-usage.js +152 -0
- package/dist/public/distribution-parity.d.ts +90 -0
- package/dist/public/distribution-parity.d.ts.map +1 -0
- package/dist/public/distribution-parity.js +367 -0
- package/dist/public/impact/full-kb-quality.d.ts +2 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +53 -1
- package/dist/public/impact-diagnostics.d.ts +2 -0
- package/dist/public/impact-diagnostics.d.ts.map +1 -1
- package/dist/public/impact-diagnostics.js +1 -0
- package/dist/public/operations/catalog.d.ts +151 -6
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +4 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +3 -2
- package/dist/public/operations/discovery-executors.d.ts +6 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +58 -5
- package/dist/public/operations/index.d.ts +4 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +4 -0
- package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
- package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
- package/dist/public/operations/legacy-migration-plan.js +409 -0
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +90 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +14 -4
- package/dist/public/operations/repair-plan.d.ts +184 -0
- package/dist/public/operations/repair-plan.d.ts.map +1 -0
- package/dist/public/operations/repair-plan.js +397 -0
- package/dist/public/operations/runtime-types.d.ts +38 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check.d.ts +2 -2
- package/dist/public/operations/specs/check.js +2 -2
- package/dist/public/operations/specs/discovery.d.ts +1 -1
- package/dist/public/operations/specs/discovery.js +1 -1
- package/dist/public/operations/specs/modeling.d.ts +19 -1
- package/dist/public/operations/specs/modeling.d.ts.map +1 -1
- package/dist/public/operations/specs/modeling.js +16 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +96 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +40 -1
- package/dist/public/operations/specs/reporting.d.ts +42 -1
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +70 -6
- package/dist/public/operations/specs/semantic.js +1 -1
- package/dist/public/operations/specs/upsert.d.ts +96 -1
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/workspace-snapshot.d.ts +10 -0
- package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
- package/dist/public/operations/workspace-snapshot.js +20 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +43 -1
- package/dist/public/skills/init-kibi/SKILL.md +2 -2
- package/dist/public/skills/kibi-freshness/SKILL.md +2 -2
- package/dist/public/skills/kibi-traceability/SKILL.md +8 -2
- package/dist/public/skills/kibi-usage/SKILL.md +12 -6
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +1 -1
- package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/dist/public/skills/kibi-usage/resources/workflows.md +19 -2
- package/dist/public/telemetry-acceptance.d.ts +89 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -0
- package/dist/public/telemetry-acceptance.js +597 -0
- package/dist/public/telemetry-remediation.d.ts +33 -0
- package/dist/public/telemetry-remediation.d.ts.map +1 -0
- package/dist/public/telemetry-remediation.js +257 -0
- package/dist/public/verification-receipt.d.ts +75 -0
- package/dist/public/verification-receipt.d.ts.map +1 -0
- package/dist/public/verification-receipt.js +129 -0
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +33 -37
- package/dist/schemas/entity.schema.json +96 -2
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +36 -3
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/rule-registry.d.ts +2 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/package.json +36 -4
- package/src/public/diagnostic-usage.ts +206 -0
- package/src/public/distribution-parity.ts +580 -0
- package/src/public/impact/full-kb-quality.ts +74 -1
- package/src/public/impact-diagnostics.ts +16 -0
- package/src/public/operations/check-executor.ts +4 -0
- package/src/public/operations/discovery-entities.ts +3 -2
- package/src/public/operations/discovery-executors.ts +68 -5
- package/src/public/operations/index.ts +4 -0
- package/src/public/operations/legacy-migration-plan.ts +688 -0
- package/src/public/operations/node-ports.ts +109 -0
- package/src/public/operations/prolog-json.ts +15 -3
- package/src/public/operations/repair-plan.ts +562 -0
- package/src/public/operations/runtime-types.ts +47 -0
- package/src/public/operations/specs/check.ts +2 -2
- package/src/public/operations/specs/discovery.ts +1 -1
- package/src/public/operations/specs/modeling.ts +19 -1
- package/src/public/operations/specs/mutation-schemas.ts +47 -1
- package/src/public/operations/specs/reporting.ts +91 -6
- package/src/public/operations/specs/semantic.ts +1 -1
- package/src/public/operations/workspace-snapshot.ts +28 -0
- package/src/public/schemas/entity.ts +44 -1
- package/src/public/skills/init-kibi/SKILL.md +2 -2
- package/src/public/skills/kibi-freshness/SKILL.md +2 -2
- package/src/public/skills/kibi-traceability/SKILL.md +8 -2
- package/src/public/skills/kibi-usage/SKILL.md +12 -6
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/src/public/skills/kibi-usage/resources/logic-ir.md +1 -1
- package/src/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/src/public/skills/kibi-usage/resources/workflows.md +19 -2
- package/src/public/telemetry-acceptance.ts +859 -0
- package/src/public/telemetry-remediation.ts +462 -0
- package/src/public/verification-receipt.ts +170 -0
- 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":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,mCAAmC,CAAC;AA4D3C,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,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,4BAA4B,CAAC;IAC1D,qBAAqB,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,OAAO,CAAC;IAC/D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,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E,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,
|
|
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
|
-
|
|
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;
|
|
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;AAO3B,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,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,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
|
|
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
|
|
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
|
-
|
|
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:
|
|
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;
|
|
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: {
|
|
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,
|
|
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
|
|
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 =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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], (
|
|
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,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AAGD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CA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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,
|
|
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
|
|
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
|
|
34
|
-
|
|
35
|
-
:
|
|
36
|
-
|
|
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 =
|
|
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
|
-
:
|
|
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
|
|
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,
|
|
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"}
|