kibi-cli 0.17.0 → 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/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/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +58 -1
- 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 +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +69 -2
- 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 +6 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +240 -61
- 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-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 +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/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 +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/kibi-traceability/SKILL.md +7 -1
- package/dist/public/skills/kibi-usage/SKILL.md +10 -4
- 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/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/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 +30 -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 +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/repair-plan.ts +562 -0
- package/src/public/operations/runtime-types.ts +8 -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/kibi-traceability/SKILL.md +7 -1
- package/src/public/skills/kibi-usage/SKILL.md +10 -4
- 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/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-json-command.d.ts","sourceRoot":"","sources":["../src/cli-json-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-json-command.d.ts","sourceRoot":"","sources":["../src/cli-json-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,8BAA8B,CAAC;AAItC,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS;QAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;KACpC,EAAE,CAAC;CACL,CAAC;AA0CF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC,IAAI,CAAC,CAyGf;AAaD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0B/D"}
|
package/dist/cli-json-command.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { InputError } from "./cli-errors.js";
|
|
2
2
|
import { loadInput } from "./cli-input.js";
|
|
3
3
|
import { executeOperation as executeProtocolOperation } from "./cli-protocol.js";
|
|
4
|
+
import { prepareOperationInput } from "./cli-validate.js";
|
|
5
|
+
import { appendCliDiagnosticUsage } from "./public/diagnostic-usage.js";
|
|
4
6
|
import { getSpec, listSpecs, } from "./public/operations/index.js";
|
|
5
7
|
import { createCliRuntime } from "./runtime/cli-runtime.js";
|
|
6
8
|
function writeInputError(error) {
|
|
@@ -21,11 +23,42 @@ function findInputConflicts(invocation) {
|
|
|
21
23
|
.map(({ name }) => name);
|
|
22
24
|
return [...positionalConflicts, ...optionConflicts];
|
|
23
25
|
}
|
|
26
|
+
function diagnosticModeEnabled(command) {
|
|
27
|
+
return (process.env.KIBI_CLI_DIAGNOSTIC_MODE === "1" ||
|
|
28
|
+
process.argv.includes("--diagnostic-mode") ||
|
|
29
|
+
command.optsWithGlobals().diagnosticMode === true);
|
|
30
|
+
}
|
|
31
|
+
function structuredResult(stdout) {
|
|
32
|
+
if (stdout === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(stdout);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
24
41
|
// implements REQ-kibi-operation-interface-parity
|
|
25
42
|
export async function runJsonInvocation(invocation) {
|
|
43
|
+
const startedAt = new Date();
|
|
44
|
+
const diagnostic = diagnosticModeEnabled(invocation.command);
|
|
45
|
+
const workspaceRoot = process.cwd();
|
|
46
|
+
const spec = getSpec(invocation.operationName);
|
|
26
47
|
const conflicts = findInputConflicts(invocation);
|
|
27
48
|
if (conflicts.length > 0) {
|
|
28
|
-
|
|
49
|
+
const error = new InputError("CONFLICTING_INPUT", `--input cannot be combined with: ${conflicts.join(", ")}`);
|
|
50
|
+
if (diagnostic) {
|
|
51
|
+
appendCliDiagnosticUsage({
|
|
52
|
+
workspaceRoot,
|
|
53
|
+
tool: invocation.operationName,
|
|
54
|
+
businessArgs: {},
|
|
55
|
+
telemetry: null,
|
|
56
|
+
startedAt,
|
|
57
|
+
status: "error",
|
|
58
|
+
error: error.detail,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
writeInputError(error);
|
|
29
62
|
return;
|
|
30
63
|
}
|
|
31
64
|
let input;
|
|
@@ -37,23 +70,66 @@ export async function runJsonInvocation(invocation) {
|
|
|
37
70
|
}
|
|
38
71
|
catch (error) {
|
|
39
72
|
if (error instanceof InputError) {
|
|
73
|
+
if (diagnostic) {
|
|
74
|
+
appendCliDiagnosticUsage({
|
|
75
|
+
workspaceRoot,
|
|
76
|
+
tool: invocation.operationName,
|
|
77
|
+
businessArgs: {},
|
|
78
|
+
telemetry: null,
|
|
79
|
+
startedAt,
|
|
80
|
+
status: "error",
|
|
81
|
+
error: error.detail,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
40
84
|
writeInputError(error);
|
|
41
85
|
return;
|
|
42
86
|
}
|
|
43
87
|
throw error;
|
|
44
88
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
89
|
+
const prepared = prepareOperationInput(input, spec.businessInputSchema);
|
|
90
|
+
const businessArgs = prepared.valid ? prepared.businessInput : {};
|
|
91
|
+
const telemetry = prepared.valid ? (prepared.telemetry ?? null) : null;
|
|
47
92
|
const runtime = createCliRuntime({ workspaceRoot });
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
await
|
|
93
|
+
let result;
|
|
94
|
+
try {
|
|
95
|
+
const context = await runtime.open(spec, { workspaceRoot });
|
|
96
|
+
result = await executeProtocolOperation(invocation.operationName, input, context);
|
|
97
|
+
if (result.exitCode === 0 && spec.effects.includes("kb-write")) {
|
|
98
|
+
await runtime.afterSuccess(spec, context);
|
|
99
|
+
}
|
|
100
|
+
await runtime.close(context, {
|
|
101
|
+
status: "success",
|
|
102
|
+
result,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (diagnostic) {
|
|
107
|
+
appendCliDiagnosticUsage({
|
|
108
|
+
workspaceRoot,
|
|
109
|
+
tool: invocation.operationName,
|
|
110
|
+
businessArgs,
|
|
111
|
+
telemetry,
|
|
112
|
+
startedAt,
|
|
113
|
+
status: "error",
|
|
114
|
+
error: error instanceof Error ? error.message : String(error),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
if (diagnostic) {
|
|
120
|
+
appendCliDiagnosticUsage({
|
|
121
|
+
workspaceRoot,
|
|
122
|
+
tool: invocation.operationName,
|
|
123
|
+
businessArgs,
|
|
124
|
+
telemetry,
|
|
125
|
+
startedAt,
|
|
126
|
+
status: result.exitCode === 0 ? "success" : "error",
|
|
127
|
+
result: structuredResult(result.stdout),
|
|
128
|
+
...(result.exitCode === 0 || result.stderr === undefined
|
|
129
|
+
? {}
|
|
130
|
+
: { error: result.stderr.trim() }),
|
|
131
|
+
});
|
|
52
132
|
}
|
|
53
|
-
await runtime.close(context, {
|
|
54
|
-
status: "success",
|
|
55
|
-
result,
|
|
56
|
-
});
|
|
57
133
|
if (result.stdout !== undefined) {
|
|
58
134
|
process.stdout.write(result.stdout);
|
|
59
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-register-maintenance.d.ts","sourceRoot":"","sources":["../src/cli-register-maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-register-maintenance.d.ts","sourceRoot":"","sources":["../src/cli-register-maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsDlE"}
|
|
@@ -3,6 +3,7 @@ import { branchEnsureCommand } from "./commands/branch.js";
|
|
|
3
3
|
import { doctorCommand } from "./commands/doctor.js";
|
|
4
4
|
import { gcCommand } from "./commands/gc.js";
|
|
5
5
|
import { usageMetricsCommand } from "./commands/usage-metrics.js";
|
|
6
|
+
import { usageRemediationCommand } from "./commands/usage-remediation.js";
|
|
6
7
|
// implements REQ-kibi-operation-interface-parity
|
|
7
8
|
export function registerMaintenanceCommands(program) {
|
|
8
9
|
program
|
|
@@ -22,7 +23,14 @@ export function registerMaintenanceCommands(program) {
|
|
|
22
23
|
.description("Report usage and quality metrics from .kb/usage.log")
|
|
23
24
|
.option("--format <format>", "Output format: json|table", "table")
|
|
24
25
|
.option("--limit <n>", "Limit top zero-result source files", "10")
|
|
26
|
+
.option("--require-acceptance", "Exit non-zero unless the telemetry acceptance report passes")
|
|
25
27
|
.action(withExitCode(async (options) => usageMetricsCommand(options)));
|
|
28
|
+
program
|
|
29
|
+
.command("usage-remediation")
|
|
30
|
+
.description("Enumerate exact diagnostic events and report-level evidence gaps requiring repair")
|
|
31
|
+
.option("--format <format>", "Output format: json|table", "table")
|
|
32
|
+
.option("--limit <n>", "Limit rendered table rows", "50")
|
|
33
|
+
.action(withExitCode(async (options) => usageRemediationCommand(options)));
|
|
26
34
|
program
|
|
27
35
|
.command("branch")
|
|
28
36
|
.description("Manage branch KBs")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-register-reporting.d.ts","sourceRoot":"","sources":["../src/cli-register-reporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"cli-register-reporting.d.ts","sourceRoot":"","sources":["../src/cli-register-reporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgJhE"}
|
|
@@ -41,6 +41,11 @@ export function registerReportingCommands(program) {
|
|
|
41
41
|
.option("--no-include-transitive", "Disable transitive symbol coverage")
|
|
42
42
|
.option("--limit <n>", "Limit results", "100")
|
|
43
43
|
.option("--offset <n>", "Skip results", "0")
|
|
44
|
+
.option("--include-migration-preview", "Include one read-only legacy semantic migration preview batch", false)
|
|
45
|
+
.option("--migration-limit <n>", "Maximum migration preview batches (1-10)", "1")
|
|
46
|
+
.option("--migration-offset <n>", "Skip ready semantic-inventory migration batches", "0")
|
|
47
|
+
.option("--migration-predicate-limit <n>", "Maximum ranked predicate schemas per proposition", "5")
|
|
48
|
+
.option("--migration-predicate-min-score <score>", "Minimum predicate schema rank score", "0.35")
|
|
44
49
|
.option("--format <format>", "Output format: json|table", "table")
|
|
45
50
|
.action(async (options, command) => {
|
|
46
51
|
if (options.input !== undefined) {
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmBtD,wBAAgB,YAAY,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmBtD,wBAAgB,YAAY,IAAI,OAAO,CAgBtC;AAGD,wBAAsB,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAgB3C"}
|
package/dist/cli.js
CHANGED
|
@@ -40,7 +40,8 @@ export function buildProgram() {
|
|
|
40
40
|
const program = new Command()
|
|
41
41
|
.name("kibi")
|
|
42
42
|
.description("Prolog-based project knowledge base")
|
|
43
|
-
.version(packageVersion(packageJson))
|
|
43
|
+
.version(packageVersion(packageJson))
|
|
44
|
+
.option("--diagnostic-mode", "Append diagnostic usage evidence for public JSON operations");
|
|
44
45
|
registerFoundationCommands(program);
|
|
45
46
|
registerReportingCommands(program);
|
|
46
47
|
registerMaintenanceCommands(program);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregated-checks.d.ts","sourceRoot":"","sources":["../../src/commands/aggregated-checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregated-checks.d.ts","sourceRoot":"","sources":["../../src/commands/aggregated-checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAW5C;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EACpC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,EAClC,UAAU,UAAQ,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CAwDtB"}
|
|
@@ -50,6 +50,7 @@ export async function runAggregatedChecks(prolog, rulesAllowlist, requireAdr = f
|
|
|
50
50
|
description: v.description,
|
|
51
51
|
...(v.suggestion ? { suggestion: v.suggestion } : {}),
|
|
52
52
|
...(v.source ? { source: v.source } : {}),
|
|
53
|
+
...(v.evidence ? { evidence: v.evidence } : {}),
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -5,6 +5,11 @@ interface CoverageOptions {
|
|
|
5
5
|
includeTransitive?: boolean;
|
|
6
6
|
limit?: string;
|
|
7
7
|
offset?: string;
|
|
8
|
+
includeMigrationPreview?: boolean;
|
|
9
|
+
migrationLimit?: string;
|
|
10
|
+
migrationOffset?: string;
|
|
11
|
+
migrationPredicateLimit?: string;
|
|
12
|
+
migrationPredicateMinScore?: string;
|
|
8
13
|
format?: "json" | "table";
|
|
9
14
|
}
|
|
10
15
|
export declare function coverageCommand(options: CoverageOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/commands/coverage.ts"],"names":[],"mappings":"AAMA,UAAU,eAAe;IACvB,EAAE,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/commands/coverage.ts"],"names":[],"mappings":"AAMA,UAAU,eAAe;IACvB,EAAE,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA6B7E"}
|
|
@@ -14,6 +14,11 @@ export async function coverageCommand(options) {
|
|
|
14
14
|
includeTransitive: options.includeTransitive ?? true,
|
|
15
15
|
limit: Number.parseInt(options.limit || "100", 10),
|
|
16
16
|
offset: Number.parseInt(options.offset || "0", 10),
|
|
17
|
+
includeMigrationPreview: options.includeMigrationPreview ?? false,
|
|
18
|
+
migrationLimit: Number.parseInt(options.migrationLimit || "1", 10),
|
|
19
|
+
migrationOffset: Number.parseInt(options.migrationOffset || "0", 10),
|
|
20
|
+
migrationPredicateLimit: Number.parseInt(options.migrationPredicateLimit || "5", 10),
|
|
21
|
+
migrationPredicateMinScore: Number.parseFloat(options.migrationPredicateMinScore || "0.35"),
|
|
17
22
|
});
|
|
18
23
|
printDiscoveryResult(options.format, result.structuredContent, result.content[0]?.text ?? "Coverage summary unavailable.");
|
|
19
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-table.d.ts","sourceRoot":"","sources":["../../src/commands/discovery-table.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAmCvE;AA4ED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACzC,MAAM,
|
|
1
|
+
{"version":3,"file":"discovery-table.d.ts","sourceRoot":"","sources":["../../src/commands/discovery-table.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAmCvE;AA4ED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACzC,MAAM,CA4ER"}
|
|
@@ -101,12 +101,14 @@ export function renderCoverageTable(payload) {
|
|
|
101
101
|
"Priority",
|
|
102
102
|
"Coverage",
|
|
103
103
|
"Depth",
|
|
104
|
+
"Proof",
|
|
104
105
|
"Scen",
|
|
105
106
|
"Tests",
|
|
106
107
|
"Symbols",
|
|
107
|
-
"
|
|
108
|
+
"Structural gaps",
|
|
109
|
+
"Proof gaps",
|
|
108
110
|
],
|
|
109
|
-
colWidths: [20, 12, 12, 18,
|
|
111
|
+
colWidths: [20, 12, 12, 18, 36, 12, 8, 8, 10, 24, 36],
|
|
110
112
|
wordWrap: true,
|
|
111
113
|
})
|
|
112
114
|
: new Table({
|
|
@@ -123,23 +125,112 @@ export function renderCoverageTable(payload) {
|
|
|
123
125
|
stringifyCell(item.priority),
|
|
124
126
|
stringifyCell(item.coverageStatus),
|
|
125
127
|
stringifyCell(item.coverageDepth),
|
|
128
|
+
stringifyCell(item.proofStatus),
|
|
126
129
|
stringifyCell(item.scenarioCount),
|
|
127
130
|
stringifyCell(item.testCount),
|
|
128
131
|
stringifyCell(item.transitiveSymbolCount),
|
|
129
132
|
joinCells(item.gaps),
|
|
133
|
+
joinCells(item.proofGaps),
|
|
130
134
|
]);
|
|
131
135
|
}
|
|
132
136
|
else {
|
|
133
137
|
table.push([
|
|
134
138
|
stringifyCell(item.id),
|
|
135
|
-
stringifyCell(item.type),
|
|
139
|
+
stringifyCell(item.traceabilityRole ?? item.type),
|
|
136
140
|
stringifyCell(item.coverageStatus),
|
|
137
|
-
`req=${stringifyCell(item.directRequirementCount)}
|
|
141
|
+
`req=${stringifyCell(item.directRequirementCount)} covered=${stringifyCell(item.testCount)} executable=${stringifyCell(item.executableTestCount)} count=${stringifyCell(item.count)}`,
|
|
138
142
|
joinCells(item.gaps),
|
|
139
143
|
]);
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
|
-
|
|
146
|
+
const sections = [summaryTable.toString(), table.toString()];
|
|
147
|
+
const repairPlan = fieldsFrom(payload.repairPlan);
|
|
148
|
+
if (typeof repairPlan.version === "string") {
|
|
149
|
+
sections.push(renderRepairPlanTable(repairPlan));
|
|
150
|
+
}
|
|
151
|
+
const legacyMigrationPlan = fieldsFrom(payload.legacyMigrationPlan);
|
|
152
|
+
if (typeof legacyMigrationPlan.version === "string") {
|
|
153
|
+
sections.push(renderLegacyMigrationPlanTable(legacyMigrationPlan));
|
|
154
|
+
}
|
|
155
|
+
return sections.join("\n\n");
|
|
156
|
+
}
|
|
157
|
+
function renderLegacyMigrationPlanTable(plan) {
|
|
158
|
+
const scope = fieldsFrom(plan.scope);
|
|
159
|
+
const summary = fieldsFrom(plan.summary);
|
|
160
|
+
const batches = Array.isArray(plan.batches) ? plan.batches : [];
|
|
161
|
+
const summaryTable = new Table({
|
|
162
|
+
head: ["Legacy migration preview", "Value"],
|
|
163
|
+
colWidths: [28, 72],
|
|
164
|
+
wordWrap: true,
|
|
165
|
+
});
|
|
166
|
+
summaryTable.push(["Plan ID", stringifyCell(plan.planId)], ["Status", stringifyCell(plan.status)], ["Repair scope complete", stringifyCell(scope.repairPlanComplete)], ["Candidate requirements", stringifyCell(scope.candidateRequirements)], ["Selected requirements", stringifyCell(scope.selectedRequirements)], ["Next offset", stringifyCell(scope.nextOffset)], ["Propositions", stringifyCell(summary.propositionCount)], ["Unresolved", stringifyCell(summary.unresolvedPropositionCount)]);
|
|
167
|
+
const batchTable = new Table({
|
|
168
|
+
head: [
|
|
169
|
+
"Requirement",
|
|
170
|
+
"State",
|
|
171
|
+
"Source binding",
|
|
172
|
+
"Claims",
|
|
173
|
+
"Predicate candidates",
|
|
174
|
+
"Diagnostics",
|
|
175
|
+
],
|
|
176
|
+
colWidths: [24, 18, 18, 10, 20, 46],
|
|
177
|
+
wordWrap: true,
|
|
178
|
+
});
|
|
179
|
+
for (const rawBatch of batches) {
|
|
180
|
+
const batch = fieldsFrom(rawBatch);
|
|
181
|
+
const sourceBinding = fieldsFrom(batch.sourceBinding);
|
|
182
|
+
const propositions = Array.isArray(batch.propositions)
|
|
183
|
+
? batch.propositions
|
|
184
|
+
: [];
|
|
185
|
+
const candidateCount = propositions.reduce((count, proposition) => {
|
|
186
|
+
const candidates = fieldsFrom(proposition).predicateCandidates;
|
|
187
|
+
return count + (Array.isArray(candidates) ? candidates.length : 0);
|
|
188
|
+
}, 0);
|
|
189
|
+
batchTable.push([
|
|
190
|
+
stringifyCell(batch.requirementId),
|
|
191
|
+
stringifyCell(batch.state),
|
|
192
|
+
stringifyCell(sourceBinding.status),
|
|
193
|
+
propositions.length,
|
|
194
|
+
candidateCount,
|
|
195
|
+
joinCells(batch.diagnostics),
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
return [summaryTable.toString(), batchTable.toString()].join("\n\n");
|
|
199
|
+
}
|
|
200
|
+
function renderRepairPlanTable(repairPlan) {
|
|
201
|
+
const scope = fieldsFrom(repairPlan.scope);
|
|
202
|
+
const summary = fieldsFrom(repairPlan.summary);
|
|
203
|
+
const batches = Array.isArray(repairPlan.batches) ? repairPlan.batches : [];
|
|
204
|
+
const displayedBatches = batches.slice(0, 25);
|
|
205
|
+
const summaryTable = new Table({
|
|
206
|
+
head: ["Repair plan", "Value"],
|
|
207
|
+
colWidths: [24, 72],
|
|
208
|
+
wordWrap: true,
|
|
209
|
+
});
|
|
210
|
+
summaryTable.push(["Plan ID", stringifyCell(repairPlan.planId)], ["Status", stringifyCell(repairPlan.status)], ["Complete scope", stringifyCell(scope.complete)], ["Requirements", stringifyCell(summary.requirementCount)], ["Repairs", stringifyCell(summary.repairCount)], ["Batches", stringifyCell(summary.batchCount)]);
|
|
211
|
+
const batchTable = new Table({
|
|
212
|
+
head: ["Order", "Requirement", "Phase", "State", "Depends on", "Gaps"],
|
|
213
|
+
colWidths: [8, 24, 24, 10, 28, 32],
|
|
214
|
+
wordWrap: true,
|
|
215
|
+
});
|
|
216
|
+
for (const rawBatch of displayedBatches) {
|
|
217
|
+
const batch = fieldsFrom(rawBatch);
|
|
218
|
+
const repairs = Array.isArray(batch.repairs) ? batch.repairs : [];
|
|
219
|
+
batchTable.push([
|
|
220
|
+
stringifyCell(batch.order),
|
|
221
|
+
stringifyCell(batch.requirementId),
|
|
222
|
+
stringifyCell(batch.phase),
|
|
223
|
+
stringifyCell(batch.state),
|
|
224
|
+
joinCells(batch.dependsOn),
|
|
225
|
+
repairs
|
|
226
|
+
.map((repair) => stringifyCell(fieldsFrom(repair).gap))
|
|
227
|
+
.join(", ") || "-",
|
|
228
|
+
]);
|
|
229
|
+
}
|
|
230
|
+
const suffix = displayedBatches.length < batches.length
|
|
231
|
+
? `\nShowing ${displayedBatches.length} of ${batches.length} repair batches; use --format json for the complete plan.`
|
|
232
|
+
: "";
|
|
233
|
+
return [summaryTable.toString(), batchTable.toString()].join("\n\n") + suffix;
|
|
143
234
|
}
|
|
144
235
|
function renderGraphTable(payload) {
|
|
145
236
|
const nodes = Array.isArray(payload.nodes) ? payload.nodes : [];
|
|
@@ -11,6 +11,8 @@ export type SyncCache = {
|
|
|
11
11
|
version: number;
|
|
12
12
|
hashes: Record<string, string>;
|
|
13
13
|
seenAt: Record<string, string>;
|
|
14
|
+
semanticHashes: Record<string, string>;
|
|
15
|
+
semanticContracts: Record<string, boolean>;
|
|
14
16
|
};
|
|
15
17
|
export declare const SYNC_CACHE_VERSION = 1;
|
|
16
18
|
export declare const SYNC_CACHE_TTL_MS: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/cache.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7E,UAAU,aAAa;IACrB,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,aAAa,EAAE,OAAO,aAAa,CAAC;CACrC;AAaD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/cache.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7E,UAAU,aAAa;IACrB,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,aAAa,EAAE,OAAO,aAAa,CAAC;CACrC;AAaD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAE1D,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,QAAQ,CAEtB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,MAAM,CAIR;AAED,wBAAgB,aAAa,CAE3B,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,SAAS,CA0CX;AAED,wBAAgB,cAAc,CAE5B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,EAChB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,IAAI,CAaN;AAED,wBAAgB,aAAa,CAE3B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,IAAI,CASN"}
|
|
@@ -49,6 +49,8 @@ cachePath, deps) {
|
|
|
49
49
|
version: SYNC_CACHE_VERSION,
|
|
50
50
|
hashes: {},
|
|
51
51
|
seenAt: {},
|
|
52
|
+
semanticHashes: {},
|
|
53
|
+
semanticContracts: {},
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
try {
|
|
@@ -58,12 +60,16 @@ cachePath, deps) {
|
|
|
58
60
|
version: SYNC_CACHE_VERSION,
|
|
59
61
|
hashes: {},
|
|
60
62
|
seenAt: {},
|
|
63
|
+
semanticHashes: {},
|
|
64
|
+
semanticContracts: {},
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
67
|
return {
|
|
64
68
|
version: SYNC_CACHE_VERSION,
|
|
65
69
|
hashes: parsed.hashes ?? {},
|
|
66
70
|
seenAt: parsed.seenAt ?? {},
|
|
71
|
+
semanticHashes: parsed.semanticHashes ?? {},
|
|
72
|
+
semanticContracts: parsed.semanticContracts ?? {},
|
|
67
73
|
};
|
|
68
74
|
}
|
|
69
75
|
catch {
|
|
@@ -71,6 +77,8 @@ cachePath, deps) {
|
|
|
71
77
|
version: SYNC_CACHE_VERSION,
|
|
72
78
|
hashes: {},
|
|
73
79
|
seenAt: {},
|
|
80
|
+
semanticHashes: {},
|
|
81
|
+
semanticContracts: {},
|
|
74
82
|
};
|
|
75
83
|
}
|
|
76
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/persistence.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/persistence.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAgHrD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAmCD,wBAAsB,eAAe,CAEnC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GACrB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAwKvD;AA6BD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,kBAAkB,EAAE,qBAAqB,EAAE,GAC1C,OAAO,CAAC;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CA+K7D"}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import * as path from "node:path";
|
|
19
19
|
import { toPrologAtom, toPrologString } from "../../prolog/codec.js";
|
|
20
|
+
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
21
|
+
import { appendOnlyVerificationReceiptHistoryErrors } from "../../public/verification-receipt.js";
|
|
20
22
|
// Field categorization for typed fact serialization
|
|
21
23
|
// NOTE: base entity fields (status, owner, priority, severity) are NOT listed here —
|
|
22
24
|
// they are emitted in the base props block above. Only fact-specific atom fields go here.
|
|
@@ -141,6 +143,7 @@ export async function persistEntities(
|
|
|
141
143
|
prolog, results, entityIds) {
|
|
142
144
|
let entityCount = 0;
|
|
143
145
|
let kbModified = false;
|
|
146
|
+
const existingEntityIds = new Set();
|
|
144
147
|
// Query existing entity IDs to include unchanged entities
|
|
145
148
|
const existingIdsResult = await prolog.query("findall(Id, kb_entity(Id, _, _), ExistingIds)");
|
|
146
149
|
if (existingIdsResult.success && existingIdsResult.bindings?.ExistingIds) {
|
|
@@ -149,8 +152,10 @@ prolog, results, entityIds) {
|
|
|
149
152
|
if (cleaned) {
|
|
150
153
|
for (const atom of cleaned.split(",")) {
|
|
151
154
|
const id = atom.trim().replace(/^'|'$/g, "");
|
|
152
|
-
if (id)
|
|
155
|
+
if (id) {
|
|
153
156
|
entityIds.add(id);
|
|
157
|
+
existingEntityIds.add(id);
|
|
158
|
+
}
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
161
|
}
|
|
@@ -159,6 +164,24 @@ prolog, results, entityIds) {
|
|
|
159
164
|
}
|
|
160
165
|
for (const { entity, sourceFile } of results) {
|
|
161
166
|
try {
|
|
167
|
+
if (entity.type === "test" && existingEntityIds.has(entity.id)) {
|
|
168
|
+
const existing = await loadEntities(prolog, {
|
|
169
|
+
id: entity.id,
|
|
170
|
+
type: "test",
|
|
171
|
+
});
|
|
172
|
+
const previous = Array.isArray(existing[0]?.verification_receipts)
|
|
173
|
+
? existing[0].verification_receipts.filter((receipt) => receipt !== null &&
|
|
174
|
+
typeof receipt === "object" &&
|
|
175
|
+
!Array.isArray(receipt))
|
|
176
|
+
: [];
|
|
177
|
+
const next = Array.isArray(entity.verification_receipts)
|
|
178
|
+
? entity.verification_receipts
|
|
179
|
+
: undefined;
|
|
180
|
+
const receiptErrors = appendOnlyVerificationReceiptHistoryErrors(previous, next);
|
|
181
|
+
if (receiptErrors.length > 0) {
|
|
182
|
+
throw new Error(receiptErrors.join("; "));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
162
185
|
const props = [
|
|
163
186
|
`id=${toPrologAtom(entity.id)}`,
|
|
164
187
|
`title=${toPrologString(entity.title)}`,
|
|
@@ -179,14 +202,45 @@ prolog, results, entityIds) {
|
|
|
179
202
|
props.push(`severity=${toPrologAtom(entity.severity)}`);
|
|
180
203
|
if (entity.text_ref)
|
|
181
204
|
props.push(`text_ref=${toPrologString(entity.text_ref)}`);
|
|
205
|
+
if (entity.type === "req" && entity.semantic_text) {
|
|
206
|
+
props.push(`semantic_text=${toPrologString(entity.semantic_text)}`);
|
|
207
|
+
}
|
|
182
208
|
if (entity.type === "req" && entity.logic_claims) {
|
|
183
209
|
props.push(`logic_claims=[${entity.logic_claims.map(toPrologAtom).join(",")}]`);
|
|
184
210
|
}
|
|
211
|
+
if (entity.type === "req" && entity.semantic_clauses) {
|
|
212
|
+
props.push(`semantic_clauses=[${entity.semantic_clauses.map(toPrologString).join(",")}]`);
|
|
213
|
+
}
|
|
214
|
+
if (entity.type === "req" && entity.semantic_inventory_version) {
|
|
215
|
+
props.push(`semantic_inventory_version=${toPrologString(entity.semantic_inventory_version)}`);
|
|
216
|
+
}
|
|
217
|
+
if (entity.type === "req" && entity.semantic_source_field) {
|
|
218
|
+
props.push(`semantic_source_field=${toPrologString(entity.semantic_source_field)}`);
|
|
219
|
+
}
|
|
220
|
+
if (entity.type === "req" && entity.semantic_source_hash) {
|
|
221
|
+
props.push(`semantic_source_hash=${toPrologString(entity.semantic_source_hash)}`);
|
|
222
|
+
}
|
|
185
223
|
if (entity.type === "req" && entity.semantic_inventory) {
|
|
186
224
|
props.push(`semantic_inventory=${toPrologString(JSON.stringify(entity.semantic_inventory))}`);
|
|
187
225
|
}
|
|
188
226
|
if (sourceFile)
|
|
189
227
|
props.push(`sourceFile=${toPrologString(sourceFile)}`);
|
|
228
|
+
if (entity.type === "symbol") {
|
|
229
|
+
if (entity.symbol_role)
|
|
230
|
+
props.push(`symbol_role=${toPrologAtom(entity.symbol_role)}`);
|
|
231
|
+
if (entity.granularity_reason)
|
|
232
|
+
props.push(`granularity_reason=${toPrologAtom(entity.granularity_reason)}`);
|
|
233
|
+
for (const key of [
|
|
234
|
+
"sourceLine",
|
|
235
|
+
"sourceColumn",
|
|
236
|
+
"sourceEndLine",
|
|
237
|
+
"sourceEndColumn",
|
|
238
|
+
]) {
|
|
239
|
+
const value = entity[key];
|
|
240
|
+
if (typeof value === "number")
|
|
241
|
+
props.push(`${key}=${value}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
190
244
|
// Add typed fact fields for fact entities
|
|
191
245
|
if (entity.type === "fact") {
|
|
192
246
|
const factFields = serializeTypedFactFields(entity);
|
|
@@ -199,6 +253,9 @@ prolog, results, entityIds) {
|
|
|
199
253
|
if (entity.verification_perspective !== undefined) {
|
|
200
254
|
props.push(`verification_perspective=${toPrologAtom(entity.verification_perspective)}`);
|
|
201
255
|
}
|
|
256
|
+
if (entity.verification_receipts !== undefined) {
|
|
257
|
+
props.push(`verification_receipts=${toPrologString(JSON.stringify(entity.verification_receipts))}`);
|
|
258
|
+
}
|
|
202
259
|
}
|
|
203
260
|
const propsList = `[${props.join(", ")}]`;
|
|
204
261
|
const goal = `kb_assert_entity(${entity.type}, ${propsList})`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiBjE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA4B7C,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAGD,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,yBAAyB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,kBAAkB;IAC1B,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3E,UAAU,CAAC,EAAE,CACX,OAAO,EAAE,yBAAyB,GAAG;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,KACzD,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,aAAa,CAAC;CAChE;AAGD,wBAAsB,WAAW,CAC/B,OAAO,GAAE;IACP,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,CAAC,EAAE,OAAO,CAAC;CAC/B,EACN,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,UAAU,CAAC,CAsfrB;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|