kibi-cli 0.8.0 → 0.10.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.d.ts.map +1 -1
- package/dist/cli.js +11 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +229 -4
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +11 -14
- package/dist/commands/migrate.d.ts +9 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +183 -0
- package/dist/commands/sync/manifest.d.ts +8 -2
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +56 -11
- package/dist/commands/sync.d.ts +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +9 -7
- package/dist/extractors/manifest.d.ts +30 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +60 -7
- package/dist/extractors/symbol-coordinates.d.ts +15 -0
- package/dist/extractors/symbol-coordinates.d.ts.map +1 -0
- package/dist/extractors/symbol-coordinates.js +83 -0
- package/dist/public/check-types.d.ts +3 -1
- package/dist/public/check-types.d.ts.map +1 -1
- package/dist/public/check-types.js +1 -0
- package/dist/public/extractors/manifest.d.ts +1 -1
- package/dist/public/extractors/manifest.d.ts.map +1 -1
- package/dist/public/extractors/manifest.js +1 -1
- package/dist/public/ignore-policy.d.ts +10 -0
- package/dist/public/ignore-policy.d.ts.map +1 -0
- package/dist/public/ignore-policy.js +219 -0
- package/dist/public/schema-version.d.ts +3 -0
- package/dist/public/schema-version.d.ts.map +1 -0
- package/dist/public/schema-version.js +1 -0
- package/dist/traceability/evidence-model.d.ts +142 -0
- package/dist/traceability/evidence-model.d.ts.map +1 -0
- package/dist/traceability/evidence-model.js +70 -0
- package/dist/traceability/git-staged.d.ts +1 -0
- package/dist/traceability/git-staged.d.ts.map +1 -1
- package/dist/traceability/git-staged.js +28 -3
- package/dist/traceability/staged-diagnostics.d.ts +25 -0
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -0
- package/dist/traceability/staged-diagnostics.js +67 -0
- package/dist/traceability/staged-impact-contract.d.ts +57 -0
- package/dist/traceability/staged-impact-contract.d.ts.map +1 -0
- package/dist/traceability/staged-impact-contract.js +202 -0
- package/dist/traceability/staged-symbols-manifest.d.ts +23 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -0
- package/dist/traceability/staged-symbols-manifest.js +269 -0
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +33 -9
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +35 -22
- package/dist/utils/manifest-paths.d.ts +8 -0
- package/dist/utils/manifest-paths.d.ts.map +1 -0
- package/dist/utils/manifest-paths.js +62 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.js +6 -0
- package/dist/utils/schema-version.d.ts +14 -0
- package/dist/utils/schema-version.d.ts.map +1 -0
- package/dist/utils/schema-version.js +59 -0
- package/dist/utils/strict-modeling.d.ts +64 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -0
- package/dist/utils/strict-modeling.js +371 -0
- package/package.json +13 -3
- package/schema/config.json +8 -1
- package/src/public/check-types.ts +15 -1
- package/src/public/extractors/manifest.ts +2 -0
- package/src/public/ignore-policy.ts +229 -0
- package/src/public/schema-version.ts +6 -0
package/dist/utils/config.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { existsSync, readFileSync } from "node:fs";
|
|
19
19
|
import * as path from "node:path";
|
|
20
20
|
import { DEFAULT_CHECKS_CONFIG, } from "./rule-registry.js";
|
|
21
|
+
import { LATEST_KB_SCHEMA_VERSION } from "./schema-version.js";
|
|
21
22
|
/**
|
|
22
23
|
* Default configuration values for new repositories.
|
|
23
24
|
*/
|
|
@@ -41,6 +42,7 @@ const DEFAULT_BRIEFS_CONFIG = {
|
|
|
41
42
|
// implements REQ-003
|
|
42
43
|
export const DEFAULT_CONFIG = {
|
|
43
44
|
$schema: "https://raw.githubusercontent.com/Looted/kibi/master/packages/cli/schema/config.json",
|
|
45
|
+
schemaVersion: LATEST_KB_SCHEMA_VERSION,
|
|
44
46
|
paths: {
|
|
45
47
|
requirements: "documentation/requirements",
|
|
46
48
|
scenarios: "documentation/scenarios",
|
|
@@ -85,6 +87,27 @@ function mergeBriefsConfig(userBriefs) {
|
|
|
85
87
|
},
|
|
86
88
|
};
|
|
87
89
|
}
|
|
90
|
+
function readUserConfig(configPath) {
|
|
91
|
+
if (!existsSync(configPath)) {
|
|
92
|
+
return {
|
|
93
|
+
userConfig: {},
|
|
94
|
+
useDefaultSchemaVersion: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const content = readFileSync(configPath, "utf8");
|
|
99
|
+
return {
|
|
100
|
+
userConfig: JSON.parse(content),
|
|
101
|
+
useDefaultSchemaVersion: false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return {
|
|
106
|
+
userConfig: {},
|
|
107
|
+
useDefaultSchemaVersion: true,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
88
111
|
/**
|
|
89
112
|
* Load and parse the Kibi configuration from .kb/config.json.
|
|
90
113
|
* Falls back to DEFAULT_CONFIG if the file doesn't exist or is invalid.
|
|
@@ -95,22 +118,17 @@ function mergeBriefsConfig(userBriefs) {
|
|
|
95
118
|
export function loadConfig(cwd = process.cwd()) {
|
|
96
119
|
// implements REQ-003
|
|
97
120
|
const configPath = path.join(cwd, ".kb/config.json");
|
|
98
|
-
|
|
99
|
-
if (existsSync(configPath)) {
|
|
100
|
-
try {
|
|
101
|
-
const content = readFileSync(configPath, "utf8");
|
|
102
|
-
userConfig = JSON.parse(content);
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
// Invalid config, use defaults
|
|
106
|
-
userConfig = {};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
121
|
+
const { userConfig, useDefaultSchemaVersion } = readUserConfig(configPath);
|
|
109
122
|
return {
|
|
110
123
|
paths: {
|
|
111
124
|
...DEFAULT_CONFIG.paths,
|
|
112
125
|
...userConfig.paths,
|
|
113
126
|
},
|
|
127
|
+
...((userConfig.schemaVersion !== undefined || useDefaultSchemaVersion)
|
|
128
|
+
? {
|
|
129
|
+
schemaVersion: userConfig.schemaVersion ?? DEFAULT_CONFIG.schemaVersion,
|
|
130
|
+
}
|
|
131
|
+
: {}),
|
|
114
132
|
briefs: mergeBriefsConfig(userConfig.briefs),
|
|
115
133
|
...(userConfig.defaultBranch !== undefined
|
|
116
134
|
? { defaultBranch: userConfig.defaultBranch }
|
|
@@ -140,22 +158,17 @@ export function loadConfig(cwd = process.cwd()) {
|
|
|
140
158
|
export function loadSyncConfig(cwd = process.cwd()) {
|
|
141
159
|
// implements REQ-003
|
|
142
160
|
const configPath = path.join(cwd, ".kb/config.json");
|
|
143
|
-
|
|
144
|
-
if (existsSync(configPath)) {
|
|
145
|
-
try {
|
|
146
|
-
const content = readFileSync(configPath, "utf8");
|
|
147
|
-
userConfig = JSON.parse(content);
|
|
148
|
-
}
|
|
149
|
-
catch {
|
|
150
|
-
// Invalid config, use defaults
|
|
151
|
-
userConfig = {};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
161
|
+
const { userConfig, useDefaultSchemaVersion } = readUserConfig(configPath);
|
|
154
162
|
return {
|
|
155
163
|
paths: {
|
|
156
164
|
...DEFAULT_SYNC_PATHS,
|
|
157
165
|
...userConfig.paths,
|
|
158
166
|
},
|
|
167
|
+
...((userConfig.schemaVersion !== undefined || useDefaultSchemaVersion)
|
|
168
|
+
? {
|
|
169
|
+
schemaVersion: userConfig.schemaVersion ?? DEFAULT_CONFIG.schemaVersion,
|
|
170
|
+
}
|
|
171
|
+
: {}),
|
|
159
172
|
briefs: mergeBriefsConfig(userConfig.briefs),
|
|
160
173
|
...(userConfig.defaultBranch !== undefined
|
|
161
174
|
? { defaultBranch: userConfig.defaultBranch }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DEFAULT_SYMBOLS_PATH = "documentation/symbols.yaml";
|
|
2
|
+
export declare const DEFAULT_COORDINATES_PATH = "documentation/symbol-coordinates.yaml";
|
|
3
|
+
export declare function resolveSymbolsManifestPaths(workspaceRoot: string, configPath?: string): {
|
|
4
|
+
symbolsPath: string;
|
|
5
|
+
coordinatesPath: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveSymbolsManifestPath(workspaceRoot: string, configPath?: string): string;
|
|
8
|
+
//# sourceMappingURL=manifest-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-paths.d.ts","sourceRoot":"","sources":["../../src/utils/manifest-paths.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,+BAA+B,CAAC;AACjE,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAuEhF,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,GAClB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CASlD;AAGD,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAER"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
export const DEFAULT_SYMBOLS_PATH = "documentation/symbols.yaml";
|
|
4
|
+
export const DEFAULT_COORDINATES_PATH = "documentation/symbol-coordinates.yaml";
|
|
5
|
+
function isNonEmptyString(value) {
|
|
6
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
7
|
+
}
|
|
8
|
+
function resolveConfigPath(workspaceRoot, configPath) {
|
|
9
|
+
const configuredPath = configPath ?? path.join(workspaceRoot, ".kb", "config.json");
|
|
10
|
+
return path.isAbsolute(configuredPath)
|
|
11
|
+
? configuredPath
|
|
12
|
+
: path.resolve(workspaceRoot, configuredPath);
|
|
13
|
+
}
|
|
14
|
+
function readManifestResolverConfig(workspaceRoot, configPath) {
|
|
15
|
+
const resolvedConfigPath = resolveConfigPath(workspaceRoot, configPath);
|
|
16
|
+
if (!existsSync(resolvedConfigPath)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(readFileSync(resolvedConfigPath, "utf8"));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function resolveConfiguredSymbolsPath(workspaceRoot, configPath) {
|
|
27
|
+
const config = readManifestResolverConfig(workspaceRoot, configPath);
|
|
28
|
+
if (!config) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const configuredPathCandidate = config.paths?.symbols ?? config.symbolsManifest;
|
|
32
|
+
if (!isNonEmptyString(configuredPathCandidate)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return path.isAbsolute(configuredPathCandidate)
|
|
36
|
+
? configuredPathCandidate
|
|
37
|
+
: path.resolve(workspaceRoot, configuredPathCandidate);
|
|
38
|
+
}
|
|
39
|
+
function resolveDefaultSymbolsPath(workspaceRoot) {
|
|
40
|
+
const candidates = [
|
|
41
|
+
path.join(workspaceRoot, DEFAULT_SYMBOLS_PATH),
|
|
42
|
+
path.join(workspaceRoot, "symbols.yaml"),
|
|
43
|
+
path.join(workspaceRoot, "symbols.yml"),
|
|
44
|
+
];
|
|
45
|
+
return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0] ?? path.join(workspaceRoot, DEFAULT_SYMBOLS_PATH);
|
|
46
|
+
}
|
|
47
|
+
function deriveCoordinatesPath(symbolsPath) {
|
|
48
|
+
return path.join(path.dirname(symbolsPath), path.basename(DEFAULT_COORDINATES_PATH));
|
|
49
|
+
}
|
|
50
|
+
// implements REQ-cli-sync
|
|
51
|
+
export function resolveSymbolsManifestPaths(workspaceRoot, configPath) {
|
|
52
|
+
const symbolsPath = resolveConfiguredSymbolsPath(workspaceRoot, configPath) ??
|
|
53
|
+
resolveDefaultSymbolsPath(workspaceRoot);
|
|
54
|
+
return {
|
|
55
|
+
symbolsPath,
|
|
56
|
+
coordinatesPath: deriveCoordinatesPath(symbolsPath),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// implements REQ-cli-sync
|
|
60
|
+
export function resolveSymbolsManifestPath(workspaceRoot, configPath) {
|
|
61
|
+
return resolveSymbolsManifestPaths(workspaceRoot, configPath).symbolsPath;
|
|
62
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-registry.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,cAAc,CAAC;CACnE;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,kBAAkB,EAAE,yBAAyB,CAAC;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,cAAc,
|
|
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,6 +81,12 @@ export const RULES = [
|
|
|
81
81
|
defaultEnabled: false,
|
|
82
82
|
category: "integrity",
|
|
83
83
|
},
|
|
84
|
+
{
|
|
85
|
+
name: "strict-readiness",
|
|
86
|
+
description: "Report strict contradiction-readiness levels for requirements that are still prose-only or otherwise not contradiction-ready",
|
|
87
|
+
defaultEnabled: false,
|
|
88
|
+
category: "integrity",
|
|
89
|
+
},
|
|
84
90
|
];
|
|
85
91
|
/**
|
|
86
92
|
* Set of all rule names for quick lookups.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KbConfig } from "./config.js";
|
|
2
|
+
export declare const LATEST_KB_SCHEMA_VERSION = 1;
|
|
3
|
+
export interface SchemaVersionStatus {
|
|
4
|
+
status: "missing" | "invalid" | "older" | "current" | "newer";
|
|
5
|
+
currentVersion: number | null;
|
|
6
|
+
latestVersion: number;
|
|
7
|
+
needsMigration: boolean;
|
|
8
|
+
warning: string | null;
|
|
9
|
+
}
|
|
10
|
+
type SchemaVersionConfig = Pick<KbConfig, "schemaVersion"> | null | undefined;
|
|
11
|
+
export declare function normalizeSchemaVersion(schemaVersion: number | string | null | undefined): number | null;
|
|
12
|
+
export declare function getSchemaVersionStatus(config?: SchemaVersionConfig): SchemaVersionStatus;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=schema-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-version.d.ts","sourceRoot":"","sources":["../../src/utils/schema-version.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IAC9D,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,KAAK,mBAAmB,GAAG,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAG9E,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAChD,MAAM,GAAG,IAAI,CAgBf;AAGD,wBAAgB,sBAAsB,CACpC,MAAM,CAAC,EAAE,mBAAmB,GAC3B,mBAAmB,CA8CrB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// implements REQ-003
|
|
2
|
+
export const LATEST_KB_SCHEMA_VERSION = 1;
|
|
3
|
+
// implements REQ-003
|
|
4
|
+
export function normalizeSchemaVersion(schemaVersion) {
|
|
5
|
+
if (schemaVersion === undefined || schemaVersion === null) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
if (typeof schemaVersion === "number") {
|
|
9
|
+
return Number.isInteger(schemaVersion) ? schemaVersion : null;
|
|
10
|
+
}
|
|
11
|
+
const trimmed = schemaVersion.trim();
|
|
12
|
+
if (trimmed.length === 0) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const parsed = Number(trimmed);
|
|
16
|
+
return Number.isInteger(parsed) ? parsed : null;
|
|
17
|
+
}
|
|
18
|
+
// implements REQ-003
|
|
19
|
+
export function getSchemaVersionStatus(config) {
|
|
20
|
+
const latestVersion = LATEST_KB_SCHEMA_VERSION;
|
|
21
|
+
const hasSchemaVersion = config !== null && config !== undefined && "schemaVersion" in config;
|
|
22
|
+
const currentVersion = normalizeSchemaVersion(config?.schemaVersion);
|
|
23
|
+
if (currentVersion === null) {
|
|
24
|
+
return {
|
|
25
|
+
status: hasSchemaVersion ? "invalid" : "missing",
|
|
26
|
+
currentVersion: null,
|
|
27
|
+
latestVersion,
|
|
28
|
+
needsMigration: true,
|
|
29
|
+
warning: hasSchemaVersion
|
|
30
|
+
? "KB config schemaVersion is invalid and should be migrated."
|
|
31
|
+
: "KB config schemaVersion is missing; legacy config should be migrated.",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (currentVersion > latestVersion) {
|
|
35
|
+
return {
|
|
36
|
+
status: "newer",
|
|
37
|
+
currentVersion,
|
|
38
|
+
latestVersion,
|
|
39
|
+
needsMigration: false,
|
|
40
|
+
warning: `KB config schemaVersion ${currentVersion} is newer than the latest supported version ${latestVersion}.`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (currentVersion < latestVersion) {
|
|
44
|
+
return {
|
|
45
|
+
status: "older",
|
|
46
|
+
currentVersion,
|
|
47
|
+
latestVersion,
|
|
48
|
+
needsMigration: true,
|
|
49
|
+
warning: `KB config schemaVersion ${currentVersion} is older than the latest version ${latestVersion} and should be migrated.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
status: "current",
|
|
54
|
+
currentVersion,
|
|
55
|
+
latestVersion,
|
|
56
|
+
needsMigration: false,
|
|
57
|
+
warning: null,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type KbConfigPaths } from "./config.js";
|
|
2
|
+
import type { BaseEntity, FactFields } from "../types/entities.js";
|
|
3
|
+
import type { BaseRelationship } from "../types/relationships.js";
|
|
4
|
+
export interface SemanticClaim {
|
|
5
|
+
source: string;
|
|
6
|
+
subjectKey: string;
|
|
7
|
+
propertyKey: string;
|
|
8
|
+
operator: "eq" | "gte" | "lte" | "neq" | "bool" | "polarity";
|
|
9
|
+
value: string | number | boolean;
|
|
10
|
+
confidence: number;
|
|
11
|
+
provenance?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface StrictModelInput {
|
|
14
|
+
claim: SemanticClaim;
|
|
15
|
+
statement: string;
|
|
16
|
+
config?: Pick<{
|
|
17
|
+
paths: KbConfigPaths;
|
|
18
|
+
}, "paths">;
|
|
19
|
+
}
|
|
20
|
+
type EntityProperties = Partial<Omit<BaseEntity, "created_at" | "updated_at"> & FactFields> & {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
status: string;
|
|
24
|
+
source: string;
|
|
25
|
+
};
|
|
26
|
+
export interface EntitySpec<TType extends "req" | "fact" = "req" | "fact", TProperties extends EntityProperties = EntityProperties> {
|
|
27
|
+
type: TType;
|
|
28
|
+
id: string;
|
|
29
|
+
properties: TProperties;
|
|
30
|
+
}
|
|
31
|
+
export type RelationshipSpec = Pick<BaseRelationship, "type" | "from" | "to" | "source" | "confidence">;
|
|
32
|
+
export interface StableRequirementIds {
|
|
33
|
+
stableKey: string;
|
|
34
|
+
reqId: string;
|
|
35
|
+
subjectFactId: string;
|
|
36
|
+
propertyFactId: string;
|
|
37
|
+
observationFactId: string;
|
|
38
|
+
normalizedSource: string;
|
|
39
|
+
normalizedSubjectKey: string;
|
|
40
|
+
normalizedPropertyKey: string;
|
|
41
|
+
normalizedValue: string;
|
|
42
|
+
}
|
|
43
|
+
interface StrictRequirementWriteSet {
|
|
44
|
+
req: EntitySpec<"req">;
|
|
45
|
+
subjectFact: EntitySpec<"fact">;
|
|
46
|
+
propertyFact: EntitySpec<"fact">;
|
|
47
|
+
relationships: RelationshipSpec[];
|
|
48
|
+
isStrict: true;
|
|
49
|
+
confidence: number;
|
|
50
|
+
}
|
|
51
|
+
interface ObservationWriteSet {
|
|
52
|
+
observationFact: EntitySpec<"fact">;
|
|
53
|
+
relationships: RelationshipSpec[];
|
|
54
|
+
isStrict: false;
|
|
55
|
+
confidence: number;
|
|
56
|
+
}
|
|
57
|
+
export type StrictWriteSet = StrictRequirementWriteSet | ObservationWriteSet;
|
|
58
|
+
export declare function normalizeSubjectKey(value: string): string;
|
|
59
|
+
export declare function normalizePropertyKey(value: string): string;
|
|
60
|
+
export declare function buildStableRequirementIds(claim: SemanticClaim): StableRequirementIds;
|
|
61
|
+
export declare function buildStrictWriteSet(input: StrictModelInput): StrictWriteSet;
|
|
62
|
+
export declare function modelRequirementClaims(inputs: ReadonlyArray<StrictModelInput>): StrictWriteSet[];
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=strict-modeling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict-modeling.d.ts","sourceRoot":"","sources":["../../src/utils/strict-modeling.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIlE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;IAC7D,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,IAAI,CAAC;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,EAAE,OAAO,CAAC,CAAC;CAClD;AAED,KAAK,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,GAAG,YAAY,CAAC,GAAG,UAAU,CAAC,GAAG;IAC5F,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,UAAU,CACzB,KAA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