kibi-cli 2.0.0 → 2.1.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-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +25 -1
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +6 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/commands/check-generated.d.ts +7 -0
- package/dist/commands/check-generated.d.ts.map +1 -0
- package/dist/commands/check-generated.js +192 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +3 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +122 -1
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +3 -1
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +13 -7
- package/dist/commands/proof-explain.d.ts +10 -0
- package/dist/commands/proof-explain.d.ts.map +1 -0
- package/dist/commands/proof-explain.js +45 -0
- package/dist/commands/proof-impact.d.ts +7 -0
- package/dist/commands/proof-impact.d.ts.map +1 -0
- package/dist/commands/proof-impact.js +39 -0
- package/dist/commands/proof-migrate-legacy.js +1 -1
- package/dist/commands/proof-prune.js +1 -1
- package/dist/commands/prove.js +4 -4
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +17 -2
- package/dist/commands/sync/manifest.d.ts +1 -0
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +18 -16
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +6 -0
- package/dist/engine.d.ts +3 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +134 -61
- package/dist/env/bootstrap.d.ts +84 -0
- package/dist/env/bootstrap.d.ts.map +1 -0
- package/dist/env/bootstrap.js +310 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +1 -1
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +19 -0
- package/dist/extractors/symbols-coordinator.d.ts +8 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +40 -0
- package/dist/extractors/symbols-ts.d.ts +8 -19
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +33 -503
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +4 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +4 -0
- package/dist/operations/modeling/suggest-predicates.d.ts +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +30 -3
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +9 -87
- package/dist/operations/planning/compile-intent.d.ts +49 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +63 -3
- package/dist/operations/proof/baseline-diff.d.ts +41 -0
- package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
- package/dist/operations/proof/baseline-diff.js +153 -0
- package/dist/operations/proof/explain.d.ts +75 -0
- package/dist/operations/proof/explain.d.ts.map +1 -0
- package/dist/operations/proof/explain.js +294 -0
- package/dist/operations/proof/impact.d.ts +45 -0
- package/dist/operations/proof/impact.d.ts.map +1 -0
- package/dist/operations/proof/impact.js +118 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +44 -3
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
- package/dist/operations/proof/migrate-legacy-receipts.js +21 -17
- package/dist/operations/proof/prune-receipts.js +1 -1
- package/dist/operations/proof/receipt-document.js +2 -2
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +18 -67
- package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
- package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
- package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
- package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
- package/dist/operations/semantic-advisor/types.d.ts +1 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/plugins/compose-ontology-packs.d.ts +51 -0
- package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
- package/dist/plugins/compose-ontology-packs.js +257 -0
- package/dist/plugins/compose-semantic-classifier.d.ts +42 -0
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
- package/dist/plugins/compose-semantic-classifier.js +211 -0
- package/dist/plugins/external-allowlist.d.ts +10 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -0
- package/dist/plugins/external-allowlist.js +16 -0
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +33 -0
- package/dist/plugins/load-plugin.d.ts +19 -0
- package/dist/plugins/load-plugin.d.ts.map +1 -0
- package/dist/plugins/load-plugin.js +59 -0
- package/dist/plugins/project-config.d.ts +28 -0
- package/dist/plugins/project-config.d.ts.map +1 -0
- package/dist/plugins/project-config.js +90 -0
- package/dist/plugins/registry.d.ts +93 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +338 -0
- package/dist/plugins/resolve-package.d.ts +47 -0
- package/dist/plugins/resolve-package.d.ts.map +1 -0
- package/dist/plugins/resolve-package.js +262 -0
- package/dist/plugins/source-analysis-service.d.ts +44 -0
- package/dist/plugins/source-analysis-service.d.ts.map +1 -0
- package/dist/plugins/source-analysis-service.js +232 -0
- package/dist/prolog/janitor.d.ts.map +1 -1
- package/dist/prolog/janitor.js +1 -1
- package/dist/prolog/store-lock.d.ts +1 -1
- package/dist/prolog/store-lock.d.ts.map +1 -1
- package/dist/proof/inspect.js +1 -1
- package/dist/proof/producers/playwright-case-id.js +2 -2
- package/dist/proof/producers/playwright-reporter.js +4 -4
- package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
- package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/public/extractors/symbols-coordinator.js +1 -1
- package/dist/public/impact/analyzer.d.ts +1 -1
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +6 -4
- package/dist/public/operations/catalog.d.ts +4 -1
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +1 -1
- package/dist/public/operations/check-helpers.d.ts +1 -1
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +1 -1
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +35 -12
- package/dist/public/operations/discovery-entities.d.ts +12 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +34 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +23 -18
- package/dist/public/operations/prolog-json.d.ts +1 -1
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +7 -7
- package/dist/public/operations/runtime-types.d.ts +16 -1
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +2 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +3 -0
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +3 -0
- package/dist/public/operations/specs/proof.js +1 -1
- package/dist/public/operations/specs/reporting.d.ts +1 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +2 -2
- package/dist/public/operations/specs/semantic.d.ts +1 -1
- package/dist/public/operations/specs/semantic.d.ts.map +1 -1
- package/dist/public/operations/specs/semantic.js +54 -4
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +3 -1
- package/dist/public/operations/types.d.ts +5 -0
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/proof-protocol.js +4 -4
- package/dist/public/skills/kibi-usage/SKILL.md +4 -1
- package/dist/public/skills/kibi-usage/resources/proof.md +45 -0
- package/dist/public/symbol-granularity.d.ts +1 -1
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.generated.d.ts.map +1 -1
- package/dist/public/symbol-granularity.generated.js +38 -5
- package/dist/report/html-report.css +1239 -281
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +18 -0
- package/dist/traceability/symbol-extract.d.ts +24 -7
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +64 -208
- package/dist/utils/rule-registry.generated.d.ts +5 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +6 -0
- package/package.json +14 -11
- package/src/public/extractors/symbols-coordinator.ts +1 -0
- package/src/public/impact/analyzer.ts +15 -12
- package/src/public/operations/check-executor.ts +1 -1
- package/src/public/operations/check-helpers.ts +2 -2
- package/src/public/operations/contracts.ts +40 -12
- package/src/public/operations/discovery-entities.ts +46 -0
- package/src/public/operations/discovery-executors.ts +39 -26
- package/src/public/operations/prolog-json.ts +13 -5
- package/src/public/operations/runtime-types.ts +21 -2
- package/src/public/operations/specs/check-rules.generated.ts +2 -1
- package/src/public/operations/specs/discovery.ts +3 -0
- package/src/public/operations/specs/proof.ts +1 -1
- package/src/public/operations/specs/reporting.ts +2 -2
- package/src/public/operations/specs/semantic.ts +79 -17
- package/src/public/operations/symbol-repair-plan.ts +3 -4
- package/src/public/operations/types.ts +5 -0
- package/src/public/proof-fingerprint.ts +1 -1
- package/src/public/proof-protocol-types.d.ts +1 -1
- package/src/public/proof-protocol.ts +4 -4
- package/src/public/skills/kibi-usage/SKILL.md +4 -1
- package/src/public/skills/kibi-usage/resources/proof.md +45 -0
- package/src/public/symbol-granularity.generated.ts +45 -12
- package/src/public/symbol-granularity.ts +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
|
|
2
2
|
import { semanticClaimKey } from "../semantic-advisor/clauses.js";
|
|
3
|
+
import { composeOntologyCatalogForOperation } from "../semantic-advisor/plugin-orchestration.js";
|
|
3
4
|
import { STRONG_APPLICABILITY_SCORE, WEAK_CANDIDATE_MARGIN, evaluateSemanticApplicability, } from "./predicate-applicability.js";
|
|
4
5
|
import { buildGapApplyPlan, buildPredicateApplyPlan, buildPredicateSchemaDraft, buildRelationshipPlan, buildSuggestion, } from "./predicate-applyplan.js";
|
|
5
6
|
import { BUILT_IN_PREDICATE_SCHEMAS } from "./predicate-catalog.js";
|
|
@@ -89,6 +90,20 @@ function uniqueSchemas(schemas) {
|
|
|
89
90
|
return true;
|
|
90
91
|
});
|
|
91
92
|
}
|
|
93
|
+
function ontologyPackSchemasToCandidates(schemas) {
|
|
94
|
+
return schemas.map((schema) => ({
|
|
95
|
+
id: schema.schemaId,
|
|
96
|
+
predicate_name: schema.predicateName,
|
|
97
|
+
title: schema.title ?? schema.predicateName,
|
|
98
|
+
description: schema.description ?? schema.predicateName,
|
|
99
|
+
argument_names: [...schema.argumentNames],
|
|
100
|
+
argument_types: [...schema.argumentTypes],
|
|
101
|
+
keywords: [schema.predicateName, ...(schema.aliases ?? [])],
|
|
102
|
+
...(schema.aliases ? { aliases: [...schema.aliases] } : {}),
|
|
103
|
+
examples: [],
|
|
104
|
+
tags: ["ontology-pack"],
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
92
107
|
export function compareEligibleByApplicabilityThenName(left, right) {
|
|
93
108
|
if (right.applicability_score !== left.applicability_score)
|
|
94
109
|
return right.applicability_score - left.applicability_score;
|
|
@@ -129,7 +144,7 @@ function withMarginRejection(candidates) {
|
|
|
129
144
|
});
|
|
130
145
|
}
|
|
131
146
|
// implements REQ-mcp-suggest-predicates
|
|
132
|
-
export async function handleKbSuggestPredicates(prolog, args) {
|
|
147
|
+
export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
133
148
|
const text = normalizeText(args.text);
|
|
134
149
|
const subject = inferSubject(text, args.subjectHint);
|
|
135
150
|
const propositions = analyzeInputPropositions(text);
|
|
@@ -144,9 +159,21 @@ export async function handleKbSuggestPredicates(prolog, args) {
|
|
|
144
159
|
const minScore = clampScore(args.minScore ?? DEFAULT_MIN_SCORE);
|
|
145
160
|
const warnings = [];
|
|
146
161
|
const existingSchemas = await loadExistingPredicateSchemas(prolog, args.includeExistingSchemas ?? true, warnings);
|
|
162
|
+
const composedCatalog = await composeOntologyCatalogForOperation(context, "kb_suggest_predicates");
|
|
163
|
+
const packSchemas = composedCatalog
|
|
164
|
+
? ontologyPackSchemasToCandidates(composedCatalog.schemas)
|
|
165
|
+
: [];
|
|
166
|
+
// When ontology resolution is in replace mode and the replace pack
|
|
167
|
+
// successfully supplied its catalog, do not silently re-append the builtin
|
|
168
|
+
// *provider* catalog. Persisted/project KB schemas remain available.
|
|
169
|
+
const includeBuiltinProviderCatalog = !(composedCatalog?.replaced === true);
|
|
170
|
+
if (composedCatalog?.diagnostics?.length) {
|
|
171
|
+
warnings.push(...composedCatalog.diagnostics);
|
|
172
|
+
}
|
|
147
173
|
const schemas = uniqueSchemas([
|
|
148
174
|
...existingSchemas,
|
|
149
|
-
...BUILT_IN_PREDICATE_SCHEMAS,
|
|
175
|
+
...(includeBuiltinProviderCatalog ? BUILT_IN_PREDICATE_SCHEMAS : []),
|
|
176
|
+
...packSchemas,
|
|
150
177
|
]);
|
|
151
178
|
const selectedSchemas = args.schemaId
|
|
152
179
|
? schemas.filter((schema) => schema.id === args.schemaId)
|
|
@@ -255,5 +282,5 @@ export async function handleKbSuggestPredicates(prolog, args) {
|
|
|
255
282
|
};
|
|
256
283
|
}
|
|
257
284
|
export async function executeSuggestPredicates(args, context) {
|
|
258
|
-
return handleKbSuggestPredicates(context.prolog ?? null, args);
|
|
285
|
+
return handleKbSuggestPredicates(context.prolog ?? null, args, context);
|
|
259
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAWjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAWjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA2BpD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAuCf"}
|
|
@@ -1,96 +1,18 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { collectGranularityCandidates } from "kibi-plugin-builtin";
|
|
3
3
|
import { ALLOWED_GRANULARITY_REASONS_PROSE, getBehavioralSymbolNames, getNonBehavioralSymbolNames, inferSymbolRole, isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../../public/symbol-granularity.js";
|
|
4
|
-
function scriptKind(filePath) {
|
|
5
|
-
const extension = path.extname(filePath).toLowerCase();
|
|
6
|
-
if (extension === ".tsx")
|
|
7
|
-
return ScriptKind.TSX;
|
|
8
|
-
if ([".ts", ".mts", ".cts"].includes(extension))
|
|
9
|
-
return ScriptKind.TS;
|
|
10
|
-
if (extension === ".jsx")
|
|
11
|
-
return ScriptKind.JSX;
|
|
12
|
-
return ScriptKind.JS;
|
|
13
|
-
}
|
|
14
4
|
function candidate(name, kind) {
|
|
15
5
|
return { name, kind, role: inferSymbolRole(kind) };
|
|
16
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Granularity candidates must include bare unique method names (parity with
|
|
9
|
+
* the pre-plugin `collectGranularityCandidates` behavior). The extractor
|
|
10
|
+
* symbol list alone is too narrow and rejects previously-valid upserts.
|
|
11
|
+
*/
|
|
17
12
|
function candidates(filePath, content) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
overwrite: true,
|
|
22
|
-
scriptKind: scriptKind(filePath),
|
|
23
|
-
});
|
|
24
|
-
const found = [];
|
|
25
|
-
const methodCounts = new Map();
|
|
26
|
-
const bareMethods = new Map();
|
|
27
|
-
for (const fn of source.getFunctions()) {
|
|
28
|
-
const name = fn.getName();
|
|
29
|
-
if (fn.isExported() && name)
|
|
30
|
-
found.push(candidate(name, "function"));
|
|
31
|
-
}
|
|
32
|
-
for (const cls of source.getClasses()) {
|
|
33
|
-
if (!cls.isExported())
|
|
34
|
-
continue;
|
|
35
|
-
const className = cls.getName();
|
|
36
|
-
if (className)
|
|
37
|
-
found.push(candidate(className, "class"));
|
|
38
|
-
for (const method of cls.getMethods()) {
|
|
39
|
-
if (isPrivateClassMember(method))
|
|
40
|
-
continue;
|
|
41
|
-
const name = method.getName();
|
|
42
|
-
if (className)
|
|
43
|
-
found.push(candidate(`${className}.${name}`, "method"));
|
|
44
|
-
bareMethods.set(name, candidate(name, "method"));
|
|
45
|
-
methodCounts.set(name, (methodCounts.get(name) ?? 0) + 1);
|
|
46
|
-
}
|
|
47
|
-
for (const property of cls.getProperties()) {
|
|
48
|
-
if (isPrivateClassMember(property))
|
|
49
|
-
continue;
|
|
50
|
-
const name = property.getName();
|
|
51
|
-
if (className)
|
|
52
|
-
found.push(candidate(`${className}.${name}`, "property"));
|
|
53
|
-
}
|
|
54
|
-
for (const accessor of [
|
|
55
|
-
...cls.getGetAccessors(),
|
|
56
|
-
...cls.getSetAccessors(),
|
|
57
|
-
]) {
|
|
58
|
-
if (isPrivateClassMember(accessor))
|
|
59
|
-
continue;
|
|
60
|
-
const name = accessor.getName();
|
|
61
|
-
if (className)
|
|
62
|
-
found.push(candidate(`${className}.${name}`, "accessor"));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
for (const [name, count] of methodCounts) {
|
|
66
|
-
const method = bareMethods.get(name);
|
|
67
|
-
if (count === 1 && method)
|
|
68
|
-
found.push(method);
|
|
69
|
-
}
|
|
70
|
-
for (const item of source.getInterfaces()) {
|
|
71
|
-
if (item.isExported())
|
|
72
|
-
found.push(candidate(item.getName(), "interface"));
|
|
73
|
-
}
|
|
74
|
-
for (const item of source.getTypeAliases()) {
|
|
75
|
-
if (item.isExported())
|
|
76
|
-
found.push(candidate(item.getName(), "type"));
|
|
77
|
-
}
|
|
78
|
-
for (const item of source.getEnums()) {
|
|
79
|
-
if (item.isExported())
|
|
80
|
-
found.push(candidate(item.getName(), "enum"));
|
|
81
|
-
}
|
|
82
|
-
for (const statement of source.getVariableStatements()) {
|
|
83
|
-
if (!statement.isExported())
|
|
84
|
-
continue;
|
|
85
|
-
for (const declaration of statement.getDeclarations()) {
|
|
86
|
-
found.push(candidate(declaration.getName(), "variable"));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return found.sort((left, right) => left.name.localeCompare(right.name));
|
|
90
|
-
}
|
|
91
|
-
function isPrivateClassMember(member) {
|
|
92
|
-
return (member.hasModifier(SyntaxKind.PrivateKeyword) ||
|
|
93
|
-
member.getName().startsWith("#"));
|
|
13
|
+
return collectGranularityCandidates(filePath, content)
|
|
14
|
+
.map((item) => candidate(item.name, item.kind))
|
|
15
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
94
16
|
}
|
|
95
17
|
function summarized(names) {
|
|
96
18
|
const shown = names.slice(0, 10);
|
|
@@ -90,6 +90,55 @@ export type CompilePlanV1 = Readonly<{
|
|
|
90
90
|
steps: readonly PlanStep[];
|
|
91
91
|
sourceWrites: readonly SourceWritePlan[];
|
|
92
92
|
diagnostics: readonly string[];
|
|
93
|
+
/** Bounded replace/augment/shadow provenance; never changes canonical steps. */
|
|
94
|
+
capabilityPlugins?: Readonly<{
|
|
95
|
+
stamps: readonly {
|
|
96
|
+
pluginId: string;
|
|
97
|
+
pluginVersion: string;
|
|
98
|
+
capability: string;
|
|
99
|
+
mode: string;
|
|
100
|
+
external: boolean;
|
|
101
|
+
network: boolean;
|
|
102
|
+
metered: boolean;
|
|
103
|
+
fallbackUsed?: boolean;
|
|
104
|
+
model?: string;
|
|
105
|
+
}[];
|
|
106
|
+
classification: Readonly<{
|
|
107
|
+
fallbackUsed: boolean;
|
|
108
|
+
decisions: readonly {
|
|
109
|
+
claimKey: string;
|
|
110
|
+
lane: string;
|
|
111
|
+
confidence: number;
|
|
112
|
+
}[];
|
|
113
|
+
shadowComparisons: readonly {
|
|
114
|
+
pluginId: string;
|
|
115
|
+
pluginVersion: string;
|
|
116
|
+
capability: string;
|
|
117
|
+
mode: string;
|
|
118
|
+
external: boolean;
|
|
119
|
+
network: boolean;
|
|
120
|
+
metered: boolean;
|
|
121
|
+
fallbackUsed?: boolean;
|
|
122
|
+
model?: string;
|
|
123
|
+
decisions: readonly {
|
|
124
|
+
claimKey: string;
|
|
125
|
+
lane: string;
|
|
126
|
+
confidence: number;
|
|
127
|
+
}[];
|
|
128
|
+
}[];
|
|
129
|
+
}> | null;
|
|
130
|
+
ontology: Readonly<{
|
|
131
|
+
replaced: boolean;
|
|
132
|
+
matchCount: number;
|
|
133
|
+
shadowMatchCount: number;
|
|
134
|
+
shadowMatches: readonly {
|
|
135
|
+
packId: string;
|
|
136
|
+
schemaId: string;
|
|
137
|
+
predicateName: string;
|
|
138
|
+
confidence: number;
|
|
139
|
+
}[];
|
|
140
|
+
}>;
|
|
141
|
+
}>;
|
|
93
142
|
}>;
|
|
94
143
|
export type SourceWritePlan = Readonly<{
|
|
95
144
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-intent.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/compile-intent.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile-intent.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/compile-intent.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,kBA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AAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AA0eH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,aAAa,CAAC;CAClC,CAAC,CAyWD"}
|
|
@@ -2,11 +2,12 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { dump as dumpYaml } from "js-yaml";
|
|
4
4
|
import { executeIntentSearch, } from "../../intent-search.js";
|
|
5
|
+
import { publicCapabilityStamp } from "../../plugins/compose-semantic-classifier.js";
|
|
5
6
|
import { normalizeEntityId, parseTriples } from "../../prolog/codec.js";
|
|
6
7
|
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
7
8
|
import { executeStatus } from "../../public/operations/discovery-executors.js";
|
|
8
9
|
import { configuredSourceTarget } from "../mutation/source-authoring.js";
|
|
9
|
-
import {
|
|
10
|
+
import { analyzeSemanticAdvisorInputWithPlugins } from "../semantic-advisor/plugin-orchestration.js";
|
|
10
11
|
import { canonicalize } from "../semantic-advisor/shared.js";
|
|
11
12
|
// implements REQ-kibi-change-to-proof-plan-compiler
|
|
12
13
|
export const COMPILE_PLAN_VERSION = "kibi.compile-plan.v1";
|
|
@@ -471,7 +472,7 @@ export async function executeCompileIntent(args, context) {
|
|
|
471
472
|
const source = text(args.sourceLocations?.[0]?.path) ||
|
|
472
473
|
text(existingEntity.source) ||
|
|
473
474
|
"mcp://kibi/compile-intent";
|
|
474
|
-
const
|
|
475
|
+
const orchestrated = await analyzeSemanticAdvisorInputWithPlugins({
|
|
475
476
|
payload: {
|
|
476
477
|
type: "req",
|
|
477
478
|
id: requirementId,
|
|
@@ -486,9 +487,65 @@ export async function executeCompileIntent(args, context) {
|
|
|
486
487
|
},
|
|
487
488
|
},
|
|
488
489
|
...(args.clauses ? { clauses: args.clauses } : {}),
|
|
489
|
-
...(args.interpretations
|
|
490
|
+
...(args.interpretations
|
|
491
|
+
? { interpretations: args.interpretations }
|
|
492
|
+
: {}),
|
|
493
|
+
}, {
|
|
494
|
+
operationName: "kb_compile_intent",
|
|
495
|
+
...(context.ensurePlugins
|
|
496
|
+
? { ensurePlugins: context.ensurePlugins }
|
|
497
|
+
: {}),
|
|
490
498
|
});
|
|
499
|
+
const advisor = orchestrated.analysis;
|
|
491
500
|
diagnostics.push(...advisor.warnings);
|
|
501
|
+
if (orchestrated.stamps.length > 0) {
|
|
502
|
+
diagnostics.push(`Capability plugins consulted: ${orchestrated.stamps
|
|
503
|
+
.map((stamp) => `${stamp.pluginId}/${stamp.capability}`)
|
|
504
|
+
.join(", ")}.`);
|
|
505
|
+
}
|
|
506
|
+
const semanticShadowCount = orchestrated.classification?.shadowComparisons.length ?? 0;
|
|
507
|
+
if (semanticShadowCount > 0) {
|
|
508
|
+
diagnostics.push(`Semantic classifier shadow comparisons observed (${semanticShadowCount}); canonical compile plan unchanged.`);
|
|
509
|
+
}
|
|
510
|
+
if (orchestrated.ontologyShadowMatches.length > 0) {
|
|
511
|
+
diagnostics.push(`Ontology pack shadow matches observed (${orchestrated.ontologyShadowMatches.length}); canonical compile plan unchanged.`);
|
|
512
|
+
}
|
|
513
|
+
const capabilityPlugins = orchestrated.stamps.length > 0 ||
|
|
514
|
+
semanticShadowCount > 0 ||
|
|
515
|
+
orchestrated.ontologyShadowMatches.length > 0
|
|
516
|
+
? {
|
|
517
|
+
stamps: orchestrated.stamps.map((stamp) => publicCapabilityStamp(stamp)),
|
|
518
|
+
classification: orchestrated.classification
|
|
519
|
+
? {
|
|
520
|
+
fallbackUsed: orchestrated.classification.fallbackUsed,
|
|
521
|
+
decisions: orchestrated.classification.decisions.map((decision) => ({
|
|
522
|
+
claimKey: decision.claimKey,
|
|
523
|
+
lane: decision.lane,
|
|
524
|
+
confidence: decision.confidence,
|
|
525
|
+
})),
|
|
526
|
+
shadowComparisons: orchestrated.classification.shadowComparisons.map((comparison) => ({
|
|
527
|
+
...publicCapabilityStamp(comparison.stamp),
|
|
528
|
+
decisions: comparison.decisions.map((decision) => ({
|
|
529
|
+
claimKey: decision.claimKey,
|
|
530
|
+
lane: decision.lane,
|
|
531
|
+
confidence: decision.confidence,
|
|
532
|
+
})),
|
|
533
|
+
})),
|
|
534
|
+
}
|
|
535
|
+
: null,
|
|
536
|
+
ontology: {
|
|
537
|
+
replaced: orchestrated.ontologyCatalog?.replaced ?? false,
|
|
538
|
+
matchCount: orchestrated.ontologyMatches.length,
|
|
539
|
+
shadowMatchCount: orchestrated.ontologyShadowMatches.length,
|
|
540
|
+
shadowMatches: orchestrated.ontologyShadowMatches.map((candidate) => ({
|
|
541
|
+
packId: candidate.packId,
|
|
542
|
+
schemaId: candidate.schemaId,
|
|
543
|
+
predicateName: candidate.predicateName,
|
|
544
|
+
confidence: candidate.confidence,
|
|
545
|
+
})),
|
|
546
|
+
},
|
|
547
|
+
}
|
|
548
|
+
: undefined;
|
|
492
549
|
const suggestionByClaim = new Map(advisor.receipt.suggestions.map((suggestion) => [
|
|
493
550
|
suggestion.claim_key,
|
|
494
551
|
suggestion,
|
|
@@ -602,8 +659,11 @@ export async function executeCompileIntent(args, context) {
|
|
|
602
659
|
sourceWrites,
|
|
603
660
|
diagnostics,
|
|
604
661
|
};
|
|
662
|
+
// Shadow/provenance metadata is returned for observation but must not enter
|
|
663
|
+
// planHash — shadow providers never affect canonical apply identity.
|
|
605
664
|
const plan = {
|
|
606
665
|
...planBody,
|
|
666
|
+
...(capabilityPlugins ? { capabilityPlugins } : {}),
|
|
607
667
|
planHash: compilePlanHash(planBody),
|
|
608
668
|
};
|
|
609
669
|
return {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const PROOF_BASELINE_VERSION = "kibi.proof-baseline.v2";
|
|
2
|
+
export type RequirementFingerprint = {
|
|
3
|
+
readonly proofStatus: string;
|
|
4
|
+
readonly gaps: readonly string[];
|
|
5
|
+
readonly uncoveredSymbols: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export type RequirementFingerprints = Readonly<Record<string, RequirementFingerprint>>;
|
|
8
|
+
export type CoverageRowLike = {
|
|
9
|
+
readonly id?: unknown;
|
|
10
|
+
readonly proofStatus?: unknown;
|
|
11
|
+
readonly proofGaps?: unknown;
|
|
12
|
+
readonly proofStages?: {
|
|
13
|
+
readonly productionSymbols?: {
|
|
14
|
+
readonly uncoveredSymbols?: unknown;
|
|
15
|
+
readonly explanations?: unknown;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type FingerprintChange = {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly kind: "added" | "removed" | "changed";
|
|
22
|
+
readonly before?: RequirementFingerprint;
|
|
23
|
+
readonly after?: RequirementFingerprint;
|
|
24
|
+
};
|
|
25
|
+
export declare function fingerprintRequirements(rows: readonly CoverageRowLike[]): RequirementFingerprints;
|
|
26
|
+
export declare function diffFingerprints(baseline: RequirementFingerprints | undefined, current: RequirementFingerprints): FingerprintChange[];
|
|
27
|
+
type ExplanationLike = {
|
|
28
|
+
readonly symbolId?: unknown;
|
|
29
|
+
readonly reason?: unknown;
|
|
30
|
+
readonly coverageCandidates?: unknown;
|
|
31
|
+
};
|
|
32
|
+
export declare function explanationsForRequirement(rows: readonly CoverageRowLike[], requirementId: string): readonly ExplanationLike[];
|
|
33
|
+
export declare function renderRequirementDiffs(changes: readonly FingerprintChange[], rows?: readonly CoverageRowLike[]): string;
|
|
34
|
+
export declare function parseSpawnJson(result: {
|
|
35
|
+
readonly error?: unknown;
|
|
36
|
+
readonly status?: number | null;
|
|
37
|
+
readonly stdout?: string | null;
|
|
38
|
+
readonly stderr?: string | null;
|
|
39
|
+
}): unknown;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=baseline-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseline-diff.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/baseline-diff.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAC5C,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CACvC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE;QACrB,QAAQ,CAAC,iBAAiB,CAAC,EAAE;YAC3B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;YACpC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;SACjC,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,CAAC;CACzC,CAAC;AAUF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,eAAe,EAAE,GAC/B,uBAAuB,CAgBzB;AAGD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,uBAAuB,GAAG,SAAS,EAC7C,OAAO,EAAE,uBAAuB,GAC/B,iBAAiB,EAAE,CA4BrB;AASD,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,aAAa,EAAE,MAAM,GACpB,SAAS,eAAe,EAAE,CAM5B;AAgBD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,IAAI,GAAE,SAAS,eAAe,EAAO,GACpC,MAAM,CAwDR;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,GAAG,OAAO,CAYV"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
*/
|
|
10
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
11
|
+
export const PROOF_BASELINE_VERSION = "kibi.proof-baseline.v2";
|
|
12
|
+
function asStringArray(value) {
|
|
13
|
+
if (!Array.isArray(value))
|
|
14
|
+
return [];
|
|
15
|
+
return value
|
|
16
|
+
.map((item) => (typeof item === "string" ? item : String(item)))
|
|
17
|
+
.sort();
|
|
18
|
+
}
|
|
19
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
20
|
+
export function fingerprintRequirements(rows) {
|
|
21
|
+
const requirements = {};
|
|
22
|
+
for (const row of rows) {
|
|
23
|
+
const id = typeof row.id === "string" ? row.id : "";
|
|
24
|
+
const proofStatus = typeof row.proofStatus === "string" ? row.proofStatus : "";
|
|
25
|
+
if (id === "" || proofStatus === "not_applicable")
|
|
26
|
+
continue;
|
|
27
|
+
requirements[id] = {
|
|
28
|
+
proofStatus,
|
|
29
|
+
gaps: asStringArray(row.proofGaps),
|
|
30
|
+
uncoveredSymbols: asStringArray(row.proofStages?.productionSymbols?.uncoveredSymbols),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return requirements;
|
|
34
|
+
}
|
|
35
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
36
|
+
export function diffFingerprints(baseline, current) {
|
|
37
|
+
const before = baseline ?? {};
|
|
38
|
+
const ids = [
|
|
39
|
+
...new Set([...Object.keys(before), ...Object.keys(current)]),
|
|
40
|
+
].sort();
|
|
41
|
+
const changes = [];
|
|
42
|
+
for (const id of ids) {
|
|
43
|
+
const left = before[id];
|
|
44
|
+
const right = current[id];
|
|
45
|
+
if (left === undefined && right !== undefined) {
|
|
46
|
+
changes.push({ id, kind: "added", after: right });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (left !== undefined && right === undefined) {
|
|
50
|
+
changes.push({ id, kind: "removed", before: left });
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (left === undefined || right === undefined)
|
|
54
|
+
continue;
|
|
55
|
+
if (left.proofStatus !== right.proofStatus ||
|
|
56
|
+
JSON.stringify(left.gaps) !== JSON.stringify(right.gaps) ||
|
|
57
|
+
JSON.stringify(left.uncoveredSymbols) !==
|
|
58
|
+
JSON.stringify(right.uncoveredSymbols)) {
|
|
59
|
+
changes.push({ id, kind: "changed", before: left, after: right });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return changes;
|
|
63
|
+
}
|
|
64
|
+
export function explanationsForRequirement(rows, requirementId) {
|
|
65
|
+
const row = rows.find((item) => item.id === requirementId);
|
|
66
|
+
const explanations = row?.proofStages?.productionSymbols?.explanations;
|
|
67
|
+
return Array.isArray(explanations)
|
|
68
|
+
? explanations
|
|
69
|
+
: [];
|
|
70
|
+
}
|
|
71
|
+
function renderCandidate(candidate) {
|
|
72
|
+
const testId = typeof candidate.testId === "string" ? candidate.testId : "?";
|
|
73
|
+
const reason = typeof candidate.reason === "string" ? candidate.reason : "";
|
|
74
|
+
const secondaries = Array.isArray(candidate.secondaryReasons)
|
|
75
|
+
? candidate.secondaryReasons.filter((item) => typeof item === "string")
|
|
76
|
+
: [];
|
|
77
|
+
const secondaryText = secondaries.length > 0 ? ` secondary=${secondaries.join(",")}` : "";
|
|
78
|
+
return ` covered_by ${testId}: ${reason}${secondaryText}`;
|
|
79
|
+
}
|
|
80
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
81
|
+
export function renderRequirementDiffs(changes, rows = []) {
|
|
82
|
+
if (changes.length === 0)
|
|
83
|
+
return "";
|
|
84
|
+
const lines = [
|
|
85
|
+
"Requirement fingerprint diffs vs committed proof/baseline.json:",
|
|
86
|
+
];
|
|
87
|
+
for (const change of changes) {
|
|
88
|
+
if (change.kind === "added" && change.after) {
|
|
89
|
+
lines.push(` ${change.id}: added (${change.after.proofStatus}; gaps=${change.after.gaps.join(",") || "none"})`);
|
|
90
|
+
}
|
|
91
|
+
else if (change.kind === "removed" && change.before) {
|
|
92
|
+
lines.push(` ${change.id}: removed (was ${change.before.proofStatus})`);
|
|
93
|
+
}
|
|
94
|
+
else if (change.kind === "changed" && change.before && change.after) {
|
|
95
|
+
if (change.before.proofStatus !== change.after.proofStatus) {
|
|
96
|
+
lines.push(` ${change.id}: ${change.before.proofStatus} -> ${change.after.proofStatus}`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
lines.push(` ${change.id}: fingerprint changed`);
|
|
100
|
+
}
|
|
101
|
+
const beforeGaps = new Set(change.before.gaps);
|
|
102
|
+
const afterGaps = new Set(change.after.gaps);
|
|
103
|
+
for (const gap of change.after.gaps) {
|
|
104
|
+
if (!beforeGaps.has(gap))
|
|
105
|
+
lines.push(` gap added: ${gap}`);
|
|
106
|
+
}
|
|
107
|
+
for (const gap of change.before.gaps) {
|
|
108
|
+
if (!afterGaps.has(gap))
|
|
109
|
+
lines.push(` gap removed: ${gap}`);
|
|
110
|
+
}
|
|
111
|
+
const beforeSymbols = new Set(change.before.uncoveredSymbols);
|
|
112
|
+
const afterSymbols = new Set(change.after.uncoveredSymbols);
|
|
113
|
+
for (const symbol of change.after.uncoveredSymbols) {
|
|
114
|
+
if (!beforeSymbols.has(symbol))
|
|
115
|
+
lines.push(` uncovered symbol added: ${symbol}`);
|
|
116
|
+
}
|
|
117
|
+
for (const symbol of change.before.uncoveredSymbols) {
|
|
118
|
+
if (!afterSymbols.has(symbol))
|
|
119
|
+
lines.push(` uncovered symbol removed: ${symbol}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const explanations = explanationsForRequirement(rows, change.id);
|
|
123
|
+
for (const explanation of explanations) {
|
|
124
|
+
const symbolId = typeof explanation.symbolId === "string" ? explanation.symbolId : "";
|
|
125
|
+
const reason = typeof explanation.reason === "string" ? explanation.reason : "";
|
|
126
|
+
if (symbolId !== "")
|
|
127
|
+
lines.push(` ${symbolId}: ${reason}`);
|
|
128
|
+
const candidates = Array.isArray(explanation.coverageCandidates)
|
|
129
|
+
? explanation.coverageCandidates
|
|
130
|
+
: [];
|
|
131
|
+
for (const candidate of candidates) {
|
|
132
|
+
if (candidate && typeof candidate === "object")
|
|
133
|
+
lines.push(renderCandidate(candidate));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return `${lines.join("\n")}\n`;
|
|
138
|
+
}
|
|
139
|
+
export function parseSpawnJson(result) {
|
|
140
|
+
if (result.error)
|
|
141
|
+
throw result.error;
|
|
142
|
+
const text = `${result.stdout ?? ""}`.trim();
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(text);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
const detail = `${result.stderr || result.stdout || ""}`.trim();
|
|
148
|
+
if (result.status !== 0 && result.status !== null) {
|
|
149
|
+
throw new Error(detail || String(error));
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
|
+
export type ProofExplainKind = "requirement" | "symbol";
|
|
3
|
+
export type ProofResolutionRef = {
|
|
4
|
+
readonly id?: string;
|
|
5
|
+
readonly sourceFile?: string;
|
|
6
|
+
readonly path?: string;
|
|
7
|
+
readonly role?: string;
|
|
8
|
+
readonly exists?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ProofCoverageCandidate = {
|
|
11
|
+
readonly testId: string;
|
|
12
|
+
readonly relationship: string;
|
|
13
|
+
readonly qualifies: boolean;
|
|
14
|
+
readonly reason: string;
|
|
15
|
+
readonly reasonText?: string;
|
|
16
|
+
readonly secondaryReasons: readonly string[];
|
|
17
|
+
readonly scope?: string;
|
|
18
|
+
readonly receiptState?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ProofExplainTestBlock = {
|
|
21
|
+
readonly testId: string;
|
|
22
|
+
readonly requiredProofs: readonly ProofResolutionRef[];
|
|
23
|
+
readonly executableFor: readonly ProofResolutionRef[];
|
|
24
|
+
};
|
|
25
|
+
export type ProofExplainSymbolBlock = {
|
|
26
|
+
readonly symbolId: string;
|
|
27
|
+
readonly classification: string;
|
|
28
|
+
readonly status: string;
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
readonly reasonText?: string;
|
|
31
|
+
readonly coverageCandidates: readonly ProofCoverageCandidate[];
|
|
32
|
+
};
|
|
33
|
+
export type RequirementProofExplainView = {
|
|
34
|
+
readonly kind: "requirement";
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly proofVersion: string;
|
|
37
|
+
readonly proofStatus: string;
|
|
38
|
+
readonly proofGaps: readonly string[];
|
|
39
|
+
readonly scenarios: readonly {
|
|
40
|
+
id: string;
|
|
41
|
+
tests: readonly string[];
|
|
42
|
+
}[];
|
|
43
|
+
readonly tests: readonly ProofExplainTestBlock[];
|
|
44
|
+
readonly productionSymbols: readonly ProofExplainSymbolBlock[];
|
|
45
|
+
readonly structuralSymbols: readonly ProofExplainSymbolBlock[];
|
|
46
|
+
};
|
|
47
|
+
export type SymbolProofExplainView = {
|
|
48
|
+
readonly kind: "symbol";
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly role: string;
|
|
51
|
+
readonly executableTest: boolean;
|
|
52
|
+
readonly implementingRequirements: readonly string[];
|
|
53
|
+
readonly executableFor: readonly string[];
|
|
54
|
+
readonly coveredBy: readonly string[];
|
|
55
|
+
readonly proofs: readonly RequirementProofExplainView[];
|
|
56
|
+
};
|
|
57
|
+
export type ProofExplainView = RequirementProofExplainView | SymbolProofExplainView;
|
|
58
|
+
export declare function projectRequirementExplain(proof: Record<string, unknown>): RequirementProofExplainView;
|
|
59
|
+
export declare function projectSymbolExplain(payload: Record<string, unknown>): SymbolProofExplainView;
|
|
60
|
+
export declare function renderProofExplain(view: ProofExplainView): string;
|
|
61
|
+
export declare function classifyExplainTarget(id: string | undefined, options: {
|
|
62
|
+
requirement?: string;
|
|
63
|
+
symbol?: string;
|
|
64
|
+
}): {
|
|
65
|
+
kind: ProofExplainKind;
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
export declare function executeProofExplain(target: {
|
|
69
|
+
kind: ProofExplainKind;
|
|
70
|
+
id: string;
|
|
71
|
+
}, context: OperationContext): Promise<{
|
|
72
|
+
view: ProofExplainView;
|
|
73
|
+
payload: Record<string, unknown>;
|
|
74
|
+
}>;
|
|
75
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/explain.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAQlD,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,QAAQ,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC,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