kibi-cli 0.16.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +87 -11
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +8 -0
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +5 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- 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 +1 -1
- package/dist/commands/coverage.d.ts +5 -0
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +5 -0
- package/dist/commands/discovery-table.d.ts.map +1 -1
- package/dist/commands/discovery-table.js +96 -5
- package/dist/commands/sync/cache.d.ts +2 -0
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +8 -0
- package/dist/commands/sync/manifest.d.ts +12 -1
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +22 -5
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +76 -2
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +72 -15
- 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/extractors/markdown.d.ts +17 -1
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +81 -2
- package/dist/logic/ir.d.ts +112 -0
- package/dist/logic/ir.d.ts.map +1 -0
- package/dist/logic/ir.js +729 -0
- package/dist/operations/modeling/logic-modeling.d.ts +22 -0
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -0
- package/dist/operations/modeling/logic-modeling.js +120 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +83 -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 +29 -4
- package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-inference.js +3 -0
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +7 -1
- package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-ranker.js +40 -2
- package/dist/operations/modeling/predicate-types.d.ts +12 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/requirement-types.d.ts +12 -0
- package/dist/operations/modeling/requirement-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/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +8 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +6 -0
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +68 -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 +2 -2
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +30 -16
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +464 -27
- 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/observation-plan.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/observation-plan.js +15 -3
- package/dist/operations/semantic-advisor/shared.d.ts +9 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/shared.js +38 -4
- package/dist/operations/semantic-advisor/types.d.ts +66 -1
- 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 +19 -2
- package/dist/prolog.d.ts +6 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +247 -63
- 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 +235 -11
- 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-executors.d.ts +6 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +18 -2
- package/dist/public/operations/index.d.ts +5 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +5 -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/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 +7 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check.d.ts +3 -3
- package/dist/public/operations/specs/check.d.ts.map +1 -1
- package/dist/public/operations/specs/check.js +5 -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 +35 -1
- package/dist/public/operations/specs/modeling.d.ts.map +1 -1
- package/dist/public/operations/specs/modeling.js +32 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +133 -3
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +67 -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.d.ts +30 -2
- package/dist/public/operations/specs/semantic.d.ts.map +1 -1
- package/dist/public/operations/specs/semantic.js +35 -3
- package/dist/public/operations/specs/upsert.d.ts +133 -3
- 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 +332 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skills/kibi-traceability/SKILL.md +7 -1
- package/dist/public/skills/kibi-usage/SKILL.md +44 -12
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +12 -2
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/dist/public/skills/kibi-usage/resources/operation-access.md +19 -19
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +40 -8
- package/dist/public/symbol-granularity.d.ts +9 -0
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.js +16 -0
- 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/schemas/entity.schema.json +401 -4
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-diagnostics.js +17 -10
- package/dist/traceability/staged-impact-contract.js +1 -1
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +28 -10
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +49 -3
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.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/dist/utils/rule-registry.js +18 -0
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.js +1 -1
- package/package.json +34 -2
- 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-executors.ts +24 -2
- package/src/public/operations/index.ts +5 -0
- package/src/public/operations/legacy-migration-plan.ts +688 -0
- package/src/public/operations/node-ports.ts +109 -0
- package/src/public/operations/repair-plan.ts +562 -0
- package/src/public/operations/runtime-types.ts +8 -0
- package/src/public/operations/specs/check.ts +5 -2
- package/src/public/operations/specs/discovery.ts +1 -1
- package/src/public/operations/specs/modeling.ts +39 -1
- package/src/public/operations/specs/mutation-schemas.ts +77 -1
- package/src/public/operations/specs/reporting.ts +91 -6
- package/src/public/operations/specs/semantic.ts +42 -3
- package/src/public/operations/workspace-snapshot.ts +28 -0
- package/src/public/schemas/entity.ts +340 -1
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skills/kibi-traceability/SKILL.md +7 -1
- package/src/public/skills/kibi-usage/SKILL.md +44 -12
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +12 -2
- package/src/public/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/src/public/skills/kibi-usage/resources/operation-access.md +19 -19
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +40 -8
- package/src/public/symbol-granularity.ts +25 -0
- 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 +401 -4
- package/src/schemas/relationship.schema.json +1 -0
|
@@ -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 = [
|
|
@@ -39,11 +40,18 @@ const FACT_STRING_FIELDS = [
|
|
|
39
40
|
"claim_text",
|
|
40
41
|
"predicate_name",
|
|
41
42
|
"predicate_namespace",
|
|
43
|
+
"rule_ir",
|
|
44
|
+
"rule_hash",
|
|
45
|
+
"rule_schema_id",
|
|
46
|
+
"rule_name",
|
|
47
|
+
"semantic_key",
|
|
42
48
|
];
|
|
43
49
|
const FACT_NUMBER_FIELDS = [
|
|
44
50
|
"value_int",
|
|
45
51
|
"value_number",
|
|
46
52
|
"predicate_arity",
|
|
53
|
+
"claim_span_start",
|
|
54
|
+
"claim_span_end",
|
|
47
55
|
];
|
|
48
56
|
const FACT_BOOLEAN_FIELDS = ["value_bool", "closed_world"];
|
|
49
57
|
const FACT_STRING_ARRAY_FIELDS = [
|
|
@@ -63,6 +71,7 @@ const FACT_ONLY_FIELDS = [
|
|
|
63
71
|
const TEST_ENUM_FIELDS = [
|
|
64
72
|
"verification_scope",
|
|
65
73
|
"verification_perspective",
|
|
74
|
+
"verification_receipts",
|
|
66
75
|
];
|
|
67
76
|
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
68
77
|
const validateExtractedEntity = ajv.compile(entitySchema);
|
|
@@ -88,6 +97,7 @@ const VALID_RELATIONSHIP_TYPES = new Set([
|
|
|
88
97
|
"constrains",
|
|
89
98
|
"requires_property",
|
|
90
99
|
"requires_predicate",
|
|
100
|
+
"requires_rule",
|
|
91
101
|
"guards",
|
|
92
102
|
"publishes",
|
|
93
103
|
"consumes",
|
|
@@ -108,6 +118,7 @@ const VALID_RELATIONSHIP_DIRECTIONS = [
|
|
|
108
118
|
{ type: "constrains", from: "req", to: "fact" },
|
|
109
119
|
{ type: "requires_property", from: "req", to: "fact" },
|
|
110
120
|
{ type: "requires_predicate", from: "req", to: "fact" },
|
|
121
|
+
{ type: "requires_rule", from: "req", to: "fact" },
|
|
111
122
|
{ type: "guards", from: "flag", to: "symbol" },
|
|
112
123
|
{ type: "guards", from: "flag", to: "event" },
|
|
113
124
|
{ type: "guards", from: "flag", to: "req" },
|
|
@@ -221,6 +232,16 @@ function parseFrontmatter(content) {
|
|
|
221
232
|
content: parts.slice(2).join("---"),
|
|
222
233
|
};
|
|
223
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
|
+
}
|
|
224
245
|
function hasLikelyUnquotedColonInTitle(content) {
|
|
225
246
|
if (!content.trim().startsWith("---")) {
|
|
226
247
|
return false;
|
|
@@ -285,7 +306,7 @@ data, entityType) {
|
|
|
285
306
|
// implements REQ-007, REQ-004
|
|
286
307
|
function extractFromMarkdownContent(content, filePath) {
|
|
287
308
|
try {
|
|
288
|
-
const { data } = parseFrontmatter(content);
|
|
309
|
+
const { data, content: body } = parseFrontmatter(content);
|
|
289
310
|
if (content.trim().startsWith("---")) {
|
|
290
311
|
const parts = content.split("---");
|
|
291
312
|
if (parts.length < 3) {
|
|
@@ -361,11 +382,32 @@ function extractFromMarkdownContent(content, filePath) {
|
|
|
361
382
|
entity.priority = data.priority;
|
|
362
383
|
if (data.severity !== undefined)
|
|
363
384
|
entity.severity = data.severity;
|
|
364
|
-
if (data.text_ref !== undefined)
|
|
385
|
+
if (data.text_ref !== undefined) {
|
|
365
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
|
+
}
|
|
366
396
|
if (type === "req" && Array.isArray(data.logic_claims)) {
|
|
367
397
|
entity.logic_claims = data.logic_claims.filter((value) => typeof value === "string");
|
|
368
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
|
+
}
|
|
369
411
|
if (type !== "fact") {
|
|
370
412
|
const invalidFactField = FACT_ONLY_FIELDS.find((field) => data[field] !== undefined);
|
|
371
413
|
if (invalidFactField) {
|
|
@@ -403,6 +445,40 @@ function extractFromMarkdownContent(content, filePath) {
|
|
|
403
445
|
}
|
|
404
446
|
entity.verification_perspective = data.verification_perspective;
|
|
405
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
|
+
}
|
|
406
482
|
}
|
|
407
483
|
// Add typed fact fields only for fact entities
|
|
408
484
|
//
|
|
@@ -444,6 +520,9 @@ function extractFromMarkdownContent(content, filePath) {
|
|
|
444
520
|
}
|
|
445
521
|
}
|
|
446
522
|
}
|
|
523
|
+
if (type === "req" && Array.isArray(data.semantic_inventory)) {
|
|
524
|
+
entity.semantic_inventory = data.semantic_inventory.filter((value) => isObjectRecord(value));
|
|
525
|
+
}
|
|
447
526
|
if (!validateExtractedEntity(entity)) {
|
|
448
527
|
const messages = (validateExtractedEntity.errors || [])
|
|
449
528
|
.map((e) => `${e.instancePath || "root"}: ${e.message}`)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** The only serialized logic language accepted by Kibi. */
|
|
2
|
+
export declare const LOGIC_IR_VERSION: "kibi.logic.v1";
|
|
3
|
+
export declare const LOGIC_RULE_MAX_DEPTH = 16;
|
|
4
|
+
export declare const LOGIC_RULE_MAX_ATOMS = 64;
|
|
5
|
+
export declare const LOGIC_RULE_MAX_VARIABLES = 32;
|
|
6
|
+
export type LogicModality = "assert" | "deny" | "oblige" | "permit" | "forbid";
|
|
7
|
+
export type LogicRuleKind = "atom" | "rule" | "constraint";
|
|
8
|
+
export type LogicVariableQuantifier = "forall" | "exists";
|
|
9
|
+
export type LogicTerm = {
|
|
10
|
+
readonly kind: "var";
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly type: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "const";
|
|
15
|
+
readonly value: string;
|
|
16
|
+
readonly type?: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "number";
|
|
19
|
+
readonly value: number;
|
|
20
|
+
readonly unit?: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "duration";
|
|
23
|
+
readonly value: number;
|
|
24
|
+
readonly unit: "ms" | "s" | "m" | "h" | "d" | "w";
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "timestamp";
|
|
27
|
+
readonly value: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "interval";
|
|
30
|
+
readonly start: string;
|
|
31
|
+
readonly end: string;
|
|
32
|
+
};
|
|
33
|
+
export interface LogicAtom {
|
|
34
|
+
readonly kind: "atom";
|
|
35
|
+
readonly namespace?: string;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly args: readonly LogicTerm[];
|
|
38
|
+
/** Explicit positive/negative information. This is not negation-as-failure. */
|
|
39
|
+
readonly polarity?: "positive" | "negative";
|
|
40
|
+
/** Required when the atom is used beneath `not`. */
|
|
41
|
+
readonly closedWorld?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export type LogicExpression = LogicAtom | {
|
|
44
|
+
readonly kind: "all";
|
|
45
|
+
readonly items: readonly LogicExpression[];
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "any";
|
|
48
|
+
readonly items: readonly LogicExpression[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: "not";
|
|
51
|
+
readonly item: LogicAtom;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "compare";
|
|
54
|
+
readonly operator: "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
|
|
55
|
+
readonly left: LogicTerm;
|
|
56
|
+
readonly right: LogicTerm;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "count";
|
|
59
|
+
readonly atom: LogicAtom;
|
|
60
|
+
readonly operator: "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
|
|
61
|
+
readonly value: number;
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "temporal";
|
|
64
|
+
readonly relation: "before" | "after" | "during" | "overlaps" | "starts" | "finishes";
|
|
65
|
+
readonly left: LogicTerm;
|
|
66
|
+
readonly right: LogicTerm;
|
|
67
|
+
};
|
|
68
|
+
export interface LogicVariable {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly type: string;
|
|
71
|
+
readonly quantifier?: LogicVariableQuantifier;
|
|
72
|
+
}
|
|
73
|
+
export interface LogicScope {
|
|
74
|
+
readonly authority?: string;
|
|
75
|
+
readonly name?: string;
|
|
76
|
+
readonly tags?: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
export interface LogicRuleIR {
|
|
79
|
+
readonly version: typeof LOGIC_IR_VERSION;
|
|
80
|
+
readonly kind: LogicRuleKind;
|
|
81
|
+
readonly modality: LogicModality;
|
|
82
|
+
readonly head?: LogicAtom;
|
|
83
|
+
readonly body?: LogicExpression;
|
|
84
|
+
readonly variables?: readonly LogicVariable[];
|
|
85
|
+
readonly exceptions?: readonly LogicExpression[];
|
|
86
|
+
readonly scope?: LogicScope;
|
|
87
|
+
readonly validFrom?: string;
|
|
88
|
+
readonly validTo?: string;
|
|
89
|
+
readonly ruleSchemaId?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface LogicValidationResult {
|
|
92
|
+
readonly valid: boolean;
|
|
93
|
+
readonly errors: readonly string[];
|
|
94
|
+
readonly warnings: readonly string[];
|
|
95
|
+
readonly normalized?: LogicRuleIR;
|
|
96
|
+
readonly canonicalJson?: string;
|
|
97
|
+
readonly ruleHash?: string;
|
|
98
|
+
readonly semanticKey?: string;
|
|
99
|
+
readonly renderedProlog?: string;
|
|
100
|
+
}
|
|
101
|
+
/** Canonical JSON is the persistence and semantic-identity boundary. */
|
|
102
|
+
export declare function canonicalLogicJson(ir: LogicRuleIR): string;
|
|
103
|
+
export declare function logicRuleHash(ir: LogicRuleIR): string;
|
|
104
|
+
export declare function logicSemanticKey(ir: LogicRuleIR): string;
|
|
105
|
+
/** Rendered output is an audit preview only; it is never evaluated as source. */
|
|
106
|
+
export declare function renderLogicProlog(ir: LogicRuleIR): string;
|
|
107
|
+
export declare function validateLogicIr(input: unknown): LogicValidationResult;
|
|
108
|
+
export declare function utf8Span(text: string, start: number, end: number): {
|
|
109
|
+
readonly start: number;
|
|
110
|
+
readonly end: number;
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=ir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../src/logic/ir.ts"],"names":[],"mappings":"AAGA,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,EAAG,eAAwB,CAAC;AACzD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,wBA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