kibi-cli 2.22.1 → 2.23.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-foundation.d.ts.map +1 -1
- package/dist/cli-register-foundation.js +1 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +51 -3
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +28 -0
- package/dist/commands/migrate.d.ts +10 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +58 -9
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +15 -1
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +37 -35
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +32 -4
- package/dist/operations/bootstrap/activation.d.ts +7 -1
- package/dist/operations/bootstrap/activation.d.ts.map +1 -1
- package/dist/operations/bootstrap/activation.js +27 -2
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +56 -16
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +14 -2
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +6 -2
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +75 -9
- package/dist/operations/bootstrap/types.d.ts +6 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/migration/kb-sources.d.ts +8 -5
- package/dist/operations/migration/kb-sources.d.ts.map +1 -1
- package/dist/operations/migration/kb-sources.js +50 -14
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +11 -2
- package/dist/operations/migration/source-paths.d.ts +18 -1
- package/dist/operations/migration/source-paths.d.ts.map +1 -1
- package/dist/operations/migration/source-paths.js +111 -16
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +22 -7
- package/dist/operations/mutation/requirement-semantics.d.ts +16 -0
- package/dist/operations/mutation/requirement-semantics.d.ts.map +1 -1
- package/dist/operations/mutation/requirement-semantics.js +50 -0
- package/dist/operations/mutation/strict-fact.js +1 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +2 -1
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +22 -2
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +49 -17
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +7 -1
- package/dist/public/impact/diagnostics.d.ts.map +1 -1
- package/dist/public/impact/diagnostics.js +16 -3
- package/dist/public/impact/types.d.ts +2 -0
- package/dist/public/impact/types.d.ts.map +1 -1
- package/dist/public/operations/catalog.d.ts +7 -2
- 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 +10 -3
- package/dist/public/operations/check-helpers.d.ts +10 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +54 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +1 -0
- package/dist/public/operations/discovery-executors.d.ts +18 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +62 -3
- package/dist/public/operations/schema6-check-actions.d.ts +4 -0
- package/dist/public/operations/schema6-check-actions.d.ts.map +1 -1
- package/dist/public/operations/schema6-check-actions.js +39 -2
- package/dist/public/operations/source-path-dangling.d.ts +1 -1
- package/dist/public/operations/source-path-dangling.d.ts.map +1 -1
- package/dist/public/operations/source-path-dangling.js +11 -2
- package/dist/public/operations/specs/composite.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +5 -0
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +5 -0
- package/dist/public/operations/specs/planning.d.ts +1 -1
- package/dist/public/operations/specs/planning.js +1 -1
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +6 -4
- 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 +4 -2
- package/dist/public/skills/kibi-bootstrap/SKILL.md +3 -2
- package/dist/public/skills/kibi-usage/SKILL.md +6 -3
- package/dist/public/skills/kibi-usage/resources/workflows.md +3 -1
- package/dist/search-answer.d.ts +14 -0
- package/dist/search-answer.d.ts.map +1 -1
- package/dist/search-answer.js +42 -4
- package/dist/traceability/git-change-snapshot.d.ts +46 -0
- package/dist/traceability/git-change-snapshot.d.ts.map +1 -1
- package/dist/traceability/git-change-snapshot.js +187 -3
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-diagnostics.js +5 -6
- package/dist/traceability/staged-inventory-drift.d.ts +24 -0
- package/dist/traceability/staged-inventory-drift.d.ts.map +1 -0
- package/dist/traceability/staged-inventory-drift.js +84 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +1 -2
- package/dist/utils/content-freshness.d.ts +9 -0
- package/dist/utils/content-freshness.d.ts.map +1 -1
- package/dist/utils/content-freshness.js +33 -0
- package/dist/utils/merge-driver-setup.d.ts +10 -0
- package/dist/utils/merge-driver-setup.d.ts.map +1 -0
- package/dist/utils/merge-driver-setup.js +69 -0
- package/dist/utils/rule-registry.generated.d.ts +1 -1
- package/dist/utils/rule-registry.generated.js +1 -1
- package/package.json +2 -2
- package/src/public/impact/analyzer.ts +13 -1
- package/src/public/impact/diagnostics.ts +20 -3
- package/src/public/impact/types.ts +2 -0
- package/src/public/operations/check-executor.ts +16 -4
- package/src/public/operations/check-helpers.ts +65 -0
- package/src/public/operations/contracts.ts +1 -0
- package/src/public/operations/discovery-executors.ts +97 -3
- package/src/public/operations/schema6-check-actions.ts +43 -2
- package/src/public/operations/source-path-dangling.ts +12 -2
- package/src/public/operations/specs/discovery.ts +6 -0
- package/src/public/operations/specs/planning.ts +1 -1
- package/src/public/operations/specs/reporting.ts +6 -4
- package/src/public/operations/specs/semantic.ts +4 -2
- package/src/public/skills/kibi-bootstrap/SKILL.md +3 -2
- package/src/public/skills/kibi-usage/SKILL.md +6 -3
- package/src/public/skills/kibi-usage/resources/workflows.md +3 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createBuiltinOntologyPack, detectSignals as detectBuiltinSignals, } from "kibi-plugin-builtin";
|
|
2
|
+
import { InputError } from "../../cli-errors.js";
|
|
2
3
|
import { utf8Span, validateLogicIr, } from "../../logic/ir.js";
|
|
3
4
|
import { logicRuleFactId } from "../modeling/logic-modeling.js";
|
|
4
5
|
import { buildAdvisorResult } from "./analysis-receipt.js";
|
|
@@ -15,12 +16,17 @@ export function stringLogicClaims(value) {
|
|
|
15
16
|
? value.filter((entry) => typeof entry === "string")
|
|
16
17
|
: [];
|
|
17
18
|
}
|
|
19
|
+
// implements REQ-mcp-semantic-advisor-preflight
|
|
18
20
|
function proseOf(payload) {
|
|
19
21
|
const properties = propertiesOf(payload);
|
|
22
|
+
// text_ref is the prose only while semantic_text is unset (the ingestion
|
|
23
|
+
// boundary's fallback); beside semantic_text it is a reference such as
|
|
24
|
+
// "docs/intake.md#batch-4", whose numbers and words are not claims.
|
|
25
|
+
const semanticText = stringValue(properties.semantic_text);
|
|
20
26
|
return [
|
|
21
27
|
properties.title,
|
|
22
28
|
properties.semantic_text,
|
|
23
|
-
properties.text_ref,
|
|
29
|
+
semanticText ? undefined : properties.text_ref,
|
|
24
30
|
properties.description,
|
|
25
31
|
]
|
|
26
32
|
.map(stringValue)
|
|
@@ -540,6 +546,16 @@ function shadowAnalysis(text, interpretations) {
|
|
|
540
546
|
}
|
|
541
547
|
function propositionSpan(text, clause, cursor) {
|
|
542
548
|
const located = locateSourceText(text, clause.text, cursor);
|
|
549
|
+
// A clause the prose does not contain has no source span: it keeps its own
|
|
550
|
+
// text over an empty span (which strict ingestion rejects) instead of an
|
|
551
|
+
// unrelated slice of the prose.
|
|
552
|
+
if (located === null) {
|
|
553
|
+
return {
|
|
554
|
+
span: utf8Span(text, cursor, cursor),
|
|
555
|
+
next: cursor,
|
|
556
|
+
sourceText: clause.text,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
543
559
|
return {
|
|
544
560
|
span: utf8Span(text, located.start, located.end),
|
|
545
561
|
next: Math.max(cursor, located.end),
|
|
@@ -552,23 +568,34 @@ function escapeRegExp(value) {
|
|
|
552
568
|
/**
|
|
553
569
|
* Locate canonical claim text while accepting source-only whitespace layout.
|
|
554
570
|
* The caller receives the authored slice so strict ingestion can compare the
|
|
555
|
-
* span with the claim text without rewriting the source document.
|
|
571
|
+
* span with the claim text without rewriting the source document. The search
|
|
572
|
+
* starts at `cursor` and then retries from the start of the prose; null means
|
|
573
|
+
* the prose does not contain the claim text at all.
|
|
556
574
|
*/
|
|
557
575
|
function locateSourceText(source, claimText, cursor) {
|
|
558
|
-
const
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
576
|
+
const pattern = new RegExp(escapeRegExp(claimText.trim()).replace(/\s+/g, "\\s+"));
|
|
577
|
+
for (const from of cursor > 0 ? [cursor, 0] : [0]) {
|
|
578
|
+
const match = pattern.exec(source.slice(from));
|
|
579
|
+
if (match !== null) {
|
|
580
|
+
const start = from + match.index;
|
|
581
|
+
return { start, end: start + match[0].length };
|
|
582
|
+
}
|
|
563
583
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Caller-supplied clauses split the requirement prose; they never restate
|
|
588
|
+
* it. A clause that does not occur in the prose (apart from whitespace
|
|
589
|
+
* layout, a list marker or closing punctuation) would get a span over
|
|
590
|
+
* unrelated text, so the request is refused naming each such clause.
|
|
591
|
+
*/
|
|
592
|
+
function assertVerbatimClauses(statement, clauses) {
|
|
593
|
+
const missing = clauses
|
|
594
|
+
.filter((clause) => locateSourceText(statement, clause.text, 0) === null)
|
|
595
|
+
.map((clause) => JSON.stringify(clause.text));
|
|
596
|
+
if (missing.length === 0)
|
|
597
|
+
return;
|
|
598
|
+
throw new InputError("VALIDATION_FAILED", `Semantic advisor clauses must be verbatim fragments of the requirement prose (the intent or semantic_text); ${missing.length === 1 ? "this clause does" : "these clauses do"} not occur in it: ${missing.join(", ")}. Copy each clause from the prose unchanged (whitespace may differ), or omit clauses to let Kibi split the prose.`);
|
|
572
599
|
}
|
|
573
600
|
function interpretationResults(interpretations, clauses, statement) {
|
|
574
601
|
if (interpretations === undefined)
|
|
@@ -592,8 +619,11 @@ function interpretationResults(interpretations, clauses, statement) {
|
|
|
592
619
|
errors.push("interpretation span is invalid");
|
|
593
620
|
if (clause && candidate.span) {
|
|
594
621
|
const candidateLocation = locateSourceText(statement, candidate.claim_text, 0);
|
|
595
|
-
const expectedSpan =
|
|
596
|
-
|
|
622
|
+
const expectedSpan = candidateLocation === null
|
|
623
|
+
? null
|
|
624
|
+
: utf8Span(statement, candidateLocation.start, candidateLocation.end);
|
|
625
|
+
if (expectedSpan === null ||
|
|
626
|
+
candidate.span.start !== expectedSpan.start ||
|
|
597
627
|
candidate.span.end !== expectedSpan.end)
|
|
598
628
|
errors.push(`interpretation span for ${candidate.claim_key} does not match the exact UTF-8 proposition span`);
|
|
599
629
|
}
|
|
@@ -690,6 +720,8 @@ export function analyzeSemanticAdvisorInput(input) {
|
|
|
690
720
|
const clauses = statement
|
|
691
721
|
? extractSemanticClauses(statement, input.clauses ?? semanticClausesOf(payload))
|
|
692
722
|
: [];
|
|
723
|
+
if (input.clauses !== undefined)
|
|
724
|
+
assertVerbatimClauses(statement, clauses);
|
|
693
725
|
const rawDeclaredClaims = propertiesOf(payload).logic_claims;
|
|
694
726
|
const declaredClaims = Array.isArray(rawDeclaredClaims)
|
|
695
727
|
? rawDeclaredClaims.filter((value) => typeof value === "string")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAsJlC"}
|
|
@@ -4,6 +4,7 @@ import { analyzeSourceChanges, assertSourceAnalysisGate, } from "../../plugins/s
|
|
|
4
4
|
import { captureStagedSnapshot } from "../../traceability/git-change-snapshot.js";
|
|
5
5
|
import { readSnapshotKnowledge } from "../../traceability/snapshot-knowledge.js";
|
|
6
6
|
import { extractSymbolsFromStagedFileAsync } from "../../traceability/symbol-extract.js";
|
|
7
|
+
import { isTraceabilityRelationshipType } from "../symbol-granularity.js";
|
|
7
8
|
import { createSemanticReviewDiagnostics, createSymbolGranularityDiagnostics, } from "./diagnostics.js";
|
|
8
9
|
import { createImpactManifestLookup, readImpactManifestResults, } from "./manifest.js";
|
|
9
10
|
import { normalizeSourceFile } from "./source-changes.js";
|
|
@@ -90,7 +91,12 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
90
91
|
manifestResults: activeManifestResults,
|
|
91
92
|
symbolsByFile,
|
|
92
93
|
}),
|
|
93
|
-
...createSemanticReviewDiagnostics({
|
|
94
|
+
...createSemanticReviewDiagnostics({
|
|
95
|
+
symbolsByFile,
|
|
96
|
+
linkedSourceFiles: new Set(activeManifestResults
|
|
97
|
+
.filter((result) => result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)))
|
|
98
|
+
.map((result) => result.sourceFile)),
|
|
99
|
+
}),
|
|
94
100
|
];
|
|
95
101
|
const maxDiagnostics = options.maxDiagnostics;
|
|
96
102
|
const cappedDiagnostics = maxDiagnostics !== undefined && maxDiagnostics >= 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAarF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAarF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;AA0FpB,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,EAAE,CAmExB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,oBAAoB,EAAE,CAiCxB;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAIT"}
|
|
@@ -40,6 +40,9 @@ function getGranularSymbolsForSourceFile(sourceFile, options) {
|
|
|
40
40
|
sourceSymbols: sourceSymbols.length > 0 ? sourceSymbols : (changedSymbols ?? []),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
function hasTraceabilityLinks(symbol) {
|
|
44
|
+
return (symbol.relationships ?? []).some((relationship) => isTraceabilityRelationshipType(relationship.type));
|
|
45
|
+
}
|
|
43
46
|
function formatRelationshipTargets(symbol) {
|
|
44
47
|
const targets = [
|
|
45
48
|
...new Set((symbol.relationships ?? [])
|
|
@@ -116,15 +119,25 @@ export function createSemanticReviewDiagnostics(options) {
|
|
|
116
119
|
if (!isChangedBehavioralReviewCandidate(symbol))
|
|
117
120
|
continue;
|
|
118
121
|
const linkedTargets = formatRelationshipTargets(symbol);
|
|
122
|
+
const file = symbol.location.file;
|
|
123
|
+
// In a file no requirement owns at all, the changed behavior has no
|
|
124
|
+
// recorded intent, so the review is "record it", not "compare it with
|
|
125
|
+
// its links". Elsewhere a coarser symbol of the file may still own it.
|
|
126
|
+
const unlinked = !hasTraceabilityLinks(symbol) &&
|
|
127
|
+
!(options.linkedSourceFiles?.has(file) ?? false);
|
|
119
128
|
diagnostics.push({
|
|
120
129
|
id: "symbol_semantic_review_needed",
|
|
121
130
|
severity: "warning",
|
|
122
131
|
blocking: false,
|
|
123
132
|
category: "symbol",
|
|
124
|
-
files: [
|
|
133
|
+
files: [file],
|
|
125
134
|
docs: ["docs/symbol-traceability-taxonomy.md"],
|
|
126
|
-
message:
|
|
127
|
-
|
|
135
|
+
message: unlinked
|
|
136
|
+
? `Changed behavioral symbol ${symbol.name} is in a file no requirement owns, so no recorded intent covers the behavior it has after this change`
|
|
137
|
+
: `Changed behavioral symbol ${symbol.name} needs semantic review against linked Kibi coverage: ${linkedTargets}`,
|
|
138
|
+
suggestion: unlinked
|
|
139
|
+
? `If the change adds or alters behavior, record it with the change: kb_search({query:"<the behavior>", sourceLocations:[{path:"${file}"}]}) for a requirement that already describes it and link ${symbol.name} to it; if none does, kb_upsert a requirement with a scenario and link the symbol with implements. If behavior is unchanged (a refactor, renaming), say so in the final report instead.`
|
|
140
|
+
: `Use kb_search and kb_query for ${file}, then verify that ${linkedTargets} actually describe and test the changed behavior or UI copy. Update Kibi links or requirements/tests while the edit context is fresh.`,
|
|
128
141
|
});
|
|
129
142
|
}
|
|
130
143
|
}
|
|
@@ -32,6 +32,8 @@ export type SymbolGranularityDiagnosticsOptions = {
|
|
|
32
32
|
};
|
|
33
33
|
export type SemanticReviewDiagnosticsOptions = {
|
|
34
34
|
readonly symbolsByFile: SymbolsByFile;
|
|
35
|
+
/** Source files where some manifest symbol carries a traceability link. */
|
|
36
|
+
readonly linkedSourceFiles?: ReadonlySet<string>;
|
|
35
37
|
};
|
|
36
38
|
export type SymbolQualityDiagnosticsOptions = {
|
|
37
39
|
readonly manifestResults: readonly ExtractionResult[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/public/impact/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EACb,QAAQ,GACR,aAAa,GACb,UAAU,GACV,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,eAAe,GACf,MAAM,CAAC;IACX,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE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AM,CAAC;CAC1B,CAAC"}
|
|
@@ -162,6 +162,11 @@ export declare const OPERATION_CATALOG: readonly [{
|
|
|
162
162
|
readonly default: 0;
|
|
163
163
|
readonly description: "Optional zero-based pagination offset. Default: 0. Example: 50 to skip first 50 rows.";
|
|
164
164
|
};
|
|
165
|
+
readonly includeBody: {
|
|
166
|
+
readonly type: "boolean";
|
|
167
|
+
readonly default: false;
|
|
168
|
+
readonly description: "With id only: also return the entity's authored Markdown body (the prose after its front matter) as body {id, path, text}, so a stale statement in it can be corrected; kb_upsert document.body replaces it. Default: false.";
|
|
169
|
+
};
|
|
165
170
|
};
|
|
166
171
|
};
|
|
167
172
|
readonly requiresProlog: true;
|
|
@@ -503,7 +508,7 @@ export declare const OPERATION_CATALOG: readonly [{
|
|
|
503
508
|
readonly items: {
|
|
504
509
|
readonly type: "string";
|
|
505
510
|
};
|
|
506
|
-
readonly description: "Optional complete list of atomic requirement clauses supplied by the caller. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.";
|
|
511
|
+
readonly description: "Optional complete list of atomic requirement clauses supplied by the caller. Each clause must be a verbatim fragment of text (whitespace may differ); a clause that does not occur in text fails the call with VALIDATION_FAILED naming it. Use this for compound prose so every normative clause receives a stable claim key and independent grounding review.";
|
|
507
512
|
};
|
|
508
513
|
readonly interpretations: {
|
|
509
514
|
readonly type: "array";
|
|
@@ -1992,7 +1997,7 @@ export declare const OPERATION_CATALOG: readonly [{
|
|
|
1992
1997
|
readonly minLength: 1;
|
|
1993
1998
|
};
|
|
1994
1999
|
readonly maxItems: 64;
|
|
1995
|
-
readonly description: "Optional complete atomic clause decomposition. Each assertive clause receives independent proposition accounting.";
|
|
2000
|
+
readonly description: "Optional complete atomic clause decomposition. Each clause must be a verbatim fragment of intent (whitespace may differ); a clause that does not occur in intent fails the call with VALIDATION_FAILED naming it. Each assertive clause receives independent proposition accounting.";
|
|
1996
2001
|
};
|
|
1997
2002
|
readonly semanticFacets: {
|
|
1998
2003
|
readonly type: "object";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/public/operations/catalog.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/public/operations/catalog.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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":3,"file":"check-executor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-executor.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"check-executor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-executor.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIL,iBAAiB,EAGjB,iBAAiB,EAGlB,MAAM,oBAAoB,CAAC;AAY5B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AAOvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,6CAA6C,CAAC,EAAE,OAAO,CAAC;IACjE;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAoFF;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,MAAM,GACpB,SAAS,GAAG,IAAI,CAgClB;AAGD,wBAAsB,YAAY,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA+PxC"}
|
|
@@ -3,7 +3,7 @@ import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
|
3
3
|
import { BRANCH_STORE_NOT_COMPILED_RULE, inspectBranchStore, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
|
|
4
4
|
import { collectFullKbQualityDiagnostics } from "../impact-diagnostics.js";
|
|
5
5
|
import { buildStructuredContent, buildSummary, } from "./check-format-shared.js";
|
|
6
|
-
import { analyzeKbCheckImpact, collectQueryPlanSafetyViolations, getEffectiveRules, partitionCheckFindings, qualityDiagnosticsFromImpact, resolveCheckRules, stagedEntityIdStyleDiagnostics, } from "./check-helpers.js";
|
|
6
|
+
import { SCOPED_CHECK_OMITTED_ID, analyzeKbCheckImpact, collectQueryPlanSafetyViolations, getEffectiveRules, partitionCheckFindings, qualityDiagnosticsFromImpact, resolveCheckRules, scopeQualityDiagnosticsToImpact, stagedEntityIdStyleDiagnostics, } from "./check-helpers.js";
|
|
7
7
|
import { collectCheckPolicyViolations } from "./check-policy-rules.js";
|
|
8
8
|
import { collectDecisionFirmnessViolations } from "./decision-firmness.js";
|
|
9
9
|
import { executeStatus } from "./discovery-executors.js";
|
|
@@ -278,12 +278,19 @@ export async function executeCheck(args, context, options = {}) {
|
|
|
278
278
|
now: context.clock(),
|
|
279
279
|
...maxDiagnosticsOption,
|
|
280
280
|
});
|
|
281
|
+
// A check scoped to sourceFiles answers about those files; the KB-wide
|
|
282
|
+
// advisory scan only lists what concerns them.
|
|
283
|
+
const advisoryQualityDiagnostics = impactResult && args.sourceFiles !== undefined && !hasExplicitRules
|
|
284
|
+
? scopeQualityDiagnosticsToImpact(partitioned.qualityDiagnostics, impactResult)
|
|
285
|
+
: partitioned.qualityDiagnostics;
|
|
281
286
|
const qualityDiagnostics = [
|
|
282
|
-
...
|
|
287
|
+
...advisoryQualityDiagnostics,
|
|
283
288
|
...extraQualityDiagnostics,
|
|
284
289
|
];
|
|
285
290
|
const statusPlan = await readStatusMigrationPlan(context);
|
|
286
|
-
const migrationPlan = await migrationPlanForCheck(context, violations,
|
|
291
|
+
const migrationPlan = await migrationPlanForCheck(context, violations,
|
|
292
|
+
// The omitted-findings count is a pointer, not a repair to plan.
|
|
293
|
+
qualityDiagnostics.filter((diagnostic) => diagnostic.id !== SCOPED_CHECK_OMITTED_ID), statusPlan);
|
|
287
294
|
return {
|
|
288
295
|
content: [
|
|
289
296
|
{
|
|
@@ -14,6 +14,16 @@ export declare function partitionCheckFindings(findings: readonly Violation[]):
|
|
|
14
14
|
violations: Violation[];
|
|
15
15
|
qualityDiagnostics: QualityDiagnostic[];
|
|
16
16
|
};
|
|
17
|
+
export declare const SCOPED_CHECK_OMITTED_ID = "scoped_check_omitted_quality";
|
|
18
|
+
/**
|
|
19
|
+
* Advisory rule findings of a check scoped to `sourceFiles` that concern
|
|
20
|
+
* those files: findings on an entity a changed file's symbols link to (or on
|
|
21
|
+
* those symbols) and findings whose source is one of the files. The KB-wide rest (unapproved requirements elsewhere,
|
|
22
|
+
* unrelated scenarios) is reduced to one info diagnostic with per-rule counts,
|
|
23
|
+
* so a check after a small edit answers about that edit; kb_check without
|
|
24
|
+
* sourceFiles still lists every finding.
|
|
25
|
+
*/
|
|
26
|
+
export declare function scopeQualityDiagnosticsToImpact(diagnostics: readonly QualityDiagnostic[], impactResult: ChangedFileImpactResult): QualityDiagnostic[];
|
|
17
27
|
export declare function collectQueryPlanSafetyViolations(): Violation[];
|
|
18
28
|
/**
|
|
19
29
|
* Resolve the rules for one check invocation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-helpers.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-helpers.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,UAAU,EACV,KAAK,SAAS,EACd,iBAAiB,EAGlB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AAEzC;;;;;;;GAOG;AAEH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,GAAG;IACtE,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;CACzC,CA0BA;AAQD,wBAAgB,gCAAgC,IAAI,SAAS,EAAE,CAU9D;AAED;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAC9B,GAAG,CAAC,MAAM,CAAC,CAQb;AAED;;;;GAIG;AAEH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAO1D;AAGD,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,uBAA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,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAO1D;AAGD,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAoB9C;AAED;;;;GAIG;AAEH,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAC/B,SAAS,iBAAiB,EAAE,CAY9B;AAGD,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,uBAAuB,GAAG,SAAS,GAChD,SAAS,iBAAiB,EAAE,CAK9B"}
|
|
@@ -60,6 +60,60 @@ export function partitionCheckFindings(findings) {
|
|
|
60
60
|
}
|
|
61
61
|
return { violations, qualityDiagnostics };
|
|
62
62
|
}
|
|
63
|
+
export const SCOPED_CHECK_OMITTED_ID = "scoped_check_omitted_quality";
|
|
64
|
+
const OMITTED_RULES_SHOWN = 5;
|
|
65
|
+
/**
|
|
66
|
+
* Advisory rule findings of a check scoped to `sourceFiles` that concern
|
|
67
|
+
* those files: findings on an entity a changed file's symbols link to (or on
|
|
68
|
+
* those symbols) and findings whose source is one of the files. The KB-wide rest (unapproved requirements elsewhere,
|
|
69
|
+
* unrelated scenarios) is reduced to one info diagnostic with per-rule counts,
|
|
70
|
+
* so a check after a small edit answers about that edit; kb_check without
|
|
71
|
+
* sourceFiles still lists every finding.
|
|
72
|
+
*/
|
|
73
|
+
// implements REQ-cli-check
|
|
74
|
+
export function scopeQualityDiagnosticsToImpact(diagnostics, impactResult) {
|
|
75
|
+
const normalizePath = (value) => value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
76
|
+
const files = new Set(impactResult.sourceFiles.map(normalizePath));
|
|
77
|
+
const entityIds = new Set();
|
|
78
|
+
for (const linked of impactResult.linkedEntities) {
|
|
79
|
+
entityIds.add(linked.id);
|
|
80
|
+
entityIds.add(linked.sourceSymbolId);
|
|
81
|
+
}
|
|
82
|
+
const inScope = (diagnostic) => (diagnostic.entityId !== undefined && entityIds.has(diagnostic.entityId)) ||
|
|
83
|
+
(diagnostic.source !== undefined &&
|
|
84
|
+
files.has(normalizePath(diagnostic.source))) ||
|
|
85
|
+
(diagnostic.files ?? []).some((file) => files.has(normalizePath(file)));
|
|
86
|
+
const kept = [];
|
|
87
|
+
const omittedByRule = new Map();
|
|
88
|
+
for (const diagnostic of diagnostics) {
|
|
89
|
+
if (inScope(diagnostic)) {
|
|
90
|
+
kept.push(diagnostic);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const rule = diagnostic.id.replace(/^rule\./, "");
|
|
94
|
+
omittedByRule.set(rule, (omittedByRule.get(rule) ?? 0) + 1);
|
|
95
|
+
}
|
|
96
|
+
if (omittedByRule.size === 0)
|
|
97
|
+
return kept;
|
|
98
|
+
const omitted = [...omittedByRule.values()].reduce((a, b) => a + b, 0);
|
|
99
|
+
const rules = [...omittedByRule.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
|
|
100
|
+
const shown = rules
|
|
101
|
+
.slice(0, OMITTED_RULES_SHOWN)
|
|
102
|
+
.map(([rule, count]) => `${rule} ×${count}`);
|
|
103
|
+
if (rules.length > OMITTED_RULES_SHOWN) {
|
|
104
|
+
shown.push(`${rules.length - OMITTED_RULES_SHOWN} more rules`);
|
|
105
|
+
}
|
|
106
|
+
kept.push({
|
|
107
|
+
id: SCOPED_CHECK_OMITTED_ID,
|
|
108
|
+
severity: "info",
|
|
109
|
+
blocking: false,
|
|
110
|
+
category: "integrity",
|
|
111
|
+
message: `This check is scoped to ${files.size} source ${files.size === 1 ? "file" : "files"}; ${omitted} advisory ${omitted === 1 ? "finding" : "findings"} elsewhere in the KB ${omitted === 1 ? "is" : "are"} not listed (${shown.join(", ")}). None of them concerns the checked files.`,
|
|
112
|
+
suggestion: "Run kb_check without sourceFiles for the full KB audit when it matters to the task.",
|
|
113
|
+
evidence: { omitted, byRule: Object.fromEntries(rules) },
|
|
114
|
+
});
|
|
115
|
+
return kept;
|
|
116
|
+
}
|
|
63
117
|
function resolveChecksPlPath() {
|
|
64
118
|
const override = getKbPlPathOverride();
|
|
65
119
|
return path.join(path.dirname(override ?? resolveKbPlPath()), "checks.pl");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/public/operations/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAsZpE;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAMrB;
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/public/operations/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAsZpE;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAMrB;AAqaD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAa3C,CAAC;AAmDF,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAClD,YAAY,EAAE,MAAM,GACnB,IAAI,CAIN;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,SAAS,0BAA0B,EAAE,CAoBvC"}
|
|
@@ -23,6 +23,8 @@ export type QueryInput = {
|
|
|
23
23
|
readonly distinct?: string;
|
|
24
24
|
readonly subjectKey?: string;
|
|
25
25
|
readonly propertyKey?: string;
|
|
26
|
+
/** With `id`: also return the entity's authored Markdown body. */
|
|
27
|
+
readonly includeBody?: boolean;
|
|
26
28
|
};
|
|
27
29
|
/** A ready-to-run follow-up call the query suggests. */
|
|
28
30
|
export type QueryNextCall = Readonly<{
|
|
@@ -53,7 +55,23 @@ export type QueryPayload = {
|
|
|
53
55
|
readonly factQuery?: FactQueryPayload;
|
|
54
56
|
/** Present when an empty answer came from a store never compiled for this branch. */
|
|
55
57
|
readonly branchStore?: SearchBranchStoreNotice;
|
|
58
|
+
/** Present when `includeBody` was requested for an `id`. */
|
|
59
|
+
readonly body?: QueryBody;
|
|
56
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* The authored Markdown body of the entity a kb_query `id` names: the text
|
|
63
|
+
* after its front matter, which kb_upsert `document.body` replaces. `text` is
|
|
64
|
+
* null when the entity has no readable authored document (a symbol, or a
|
|
65
|
+
* source that is not a workspace Markdown file).
|
|
66
|
+
*/
|
|
67
|
+
export type QueryBody = Readonly<{
|
|
68
|
+
id: string;
|
|
69
|
+
path: string | null;
|
|
70
|
+
text: string | null;
|
|
71
|
+
truncated?: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
/** Bodies longer than this are cut; the file itself stays the full record. */
|
|
74
|
+
export declare const QUERY_BODY_MAX_CHARS = 32000;
|
|
57
75
|
export declare const FACT_KINDS: readonly ["subject", "property_value", "predicate", "predicate_schema", "observation", "meta", "rule", "rule_schema"];
|
|
58
76
|
export type SearchInput = {
|
|
59
77
|
readonly query: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,yBAAyB,EACzB,KAAK,qBAAqB,EAM3B,MAAM,6BAA6B,CAAC;AAWrC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,QAA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B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAmVzC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { compilerFingerprintReason } from "../../commands/sync/cache.js";
|
|
3
4
|
import { effectiveFirmness } from "../../decision-firmness.js";
|
|
@@ -11,9 +12,12 @@ import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
|
11
12
|
import { BRANCH_STORE_NOT_COMPILED, branchStoreReason, inspectBranchStore, storeLockJournalReason, storeLockTakeoverReason, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
|
|
12
13
|
import { confirmSourceNewerReasons } from "../../utils/content-freshness.js";
|
|
13
14
|
import { loadSearchCandidates, paginateResults, queryEntitiesViaQuery, reloadFullEntities, validateEntityType, } from "./discovery-entities.js";
|
|
15
|
+
import { readAuthoredEntity } from "./entity-context.js";
|
|
14
16
|
import { buildActionsFromStatus, readMigrationConfigStatus, } from "./migration-plan.js";
|
|
15
17
|
import { OperationJsonDecodeError, runOperationJsonQuery, toPrologAtom, } from "./prolog-json.js";
|
|
16
18
|
import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
|
|
19
|
+
/** Bodies longer than this are cut; the file itself stays the full record. */
|
|
20
|
+
export const QUERY_BODY_MAX_CHARS = 32_000;
|
|
17
21
|
export const FACT_KINDS = [
|
|
18
22
|
"subject",
|
|
19
23
|
"property_value",
|
|
@@ -419,6 +423,9 @@ export async function executeQuery(input, context) {
|
|
|
419
423
|
const { type, id, tags, sourceFile, limit = 100, offset = 0 } = input;
|
|
420
424
|
try {
|
|
421
425
|
validateEntityType(type);
|
|
426
|
+
if (input.includeBody === true && (id === undefined || id === "")) {
|
|
427
|
+
throw new Error("includeBody needs id: it returns the authored body of one entity. Pass the entity's id.");
|
|
428
|
+
}
|
|
422
429
|
if (hasTypedFactFilters(input)) {
|
|
423
430
|
return await executeFactQuery(input, context, limit, offset);
|
|
424
431
|
}
|
|
@@ -459,12 +466,18 @@ export async function executeQuery(input, context) {
|
|
|
459
466
|
return `${entityId} (${String(entity.title ?? "")}, status=${String(entity.status ?? "")})`;
|
|
460
467
|
})
|
|
461
468
|
.join(", ")}`;
|
|
469
|
+
const body = input.includeBody === true && id !== undefined
|
|
470
|
+
? await readQueryBody(id, paginated.find((entity) => entity.id === id), context)
|
|
471
|
+
: undefined;
|
|
462
472
|
return {
|
|
463
|
-
content: [
|
|
473
|
+
content: [
|
|
474
|
+
{ type: "text", text: body ? `${text}\n${queryBodyText(body)}` : text },
|
|
475
|
+
],
|
|
464
476
|
structuredContent: {
|
|
465
477
|
entities: paginated,
|
|
466
478
|
count: indexedPage.count,
|
|
467
479
|
...(storeNotice ? { branchStore: storeNotice } : {}),
|
|
480
|
+
...(body ? { body } : {}),
|
|
468
481
|
},
|
|
469
482
|
};
|
|
470
483
|
}
|
|
@@ -473,6 +486,48 @@ export async function executeQuery(input, context) {
|
|
|
473
486
|
throw new Error(`Query execution failed: ${message}`);
|
|
474
487
|
}
|
|
475
488
|
}
|
|
489
|
+
// The body is read from the entity's authored document inside the
|
|
490
|
+
// workspace, the same file kb_upsert rewrites; nothing outside it is read.
|
|
491
|
+
// implements REQ-kibi-operation-interface-parity
|
|
492
|
+
async function readQueryBody(id, entity, context) {
|
|
493
|
+
const source = typeof entity?.source === "string" ? entity.source : "";
|
|
494
|
+
const relative = source.split("#", 1)[0]?.trim() ?? "";
|
|
495
|
+
const root = path.resolve(context.workspaceRoot);
|
|
496
|
+
const resolved = path.resolve(root, relative);
|
|
497
|
+
if (!relative.endsWith(".md") || !resolved.startsWith(root + path.sep)) {
|
|
498
|
+
return { id, path: null, text: null };
|
|
499
|
+
}
|
|
500
|
+
const bodyPath = path.relative(root, resolved).split(path.sep).join("/");
|
|
501
|
+
let raw;
|
|
502
|
+
try {
|
|
503
|
+
raw = String(context.fs
|
|
504
|
+
? await context.fs.readFile(resolved)
|
|
505
|
+
: await readFile(resolved, "utf8"));
|
|
506
|
+
}
|
|
507
|
+
catch {
|
|
508
|
+
return { id, path: bodyPath, text: null };
|
|
509
|
+
}
|
|
510
|
+
const authored = readAuthoredEntity(raw, bodyPath)?.body;
|
|
511
|
+
if (authored === undefined || authored === null) {
|
|
512
|
+
return { id, path: bodyPath, text: null };
|
|
513
|
+
}
|
|
514
|
+
return authored.length > QUERY_BODY_MAX_CHARS
|
|
515
|
+
? {
|
|
516
|
+
id,
|
|
517
|
+
path: bodyPath,
|
|
518
|
+
text: authored.slice(0, QUERY_BODY_MAX_CHARS),
|
|
519
|
+
truncated: true,
|
|
520
|
+
}
|
|
521
|
+
: { id, path: bodyPath, text: authored };
|
|
522
|
+
}
|
|
523
|
+
function queryBodyText(body) {
|
|
524
|
+
if (body.text === null) {
|
|
525
|
+
return body.path === null
|
|
526
|
+
? `No authored document for ${body.id}, so there is no body to return.`
|
|
527
|
+
: `The authored document ${body.path} of ${body.id} could not be read.`;
|
|
528
|
+
}
|
|
529
|
+
return `Body of ${body.id} (${body.path}${body.truncated ? `, first ${QUERY_BODY_MAX_CHARS} characters` : ""}; replace it with kb_upsert document.body):\n${body.text}`;
|
|
530
|
+
}
|
|
476
531
|
/**
|
|
477
532
|
* Identifying metadata a caller needs to decide which hits to open.
|
|
478
533
|
*
|
|
@@ -512,6 +567,10 @@ async function projectMatches(prolog, matches, fields) {
|
|
|
512
567
|
? reloadFullEntities(prolog, matches)
|
|
513
568
|
: matches.map(summarizeMatch);
|
|
514
569
|
}
|
|
570
|
+
// A question about contradictions is answered by the check, not by the
|
|
571
|
+
// entities that happen to mention the word.
|
|
572
|
+
const CONTRADICTION_QUESTION = /\b(contradict\w*|conflict\w*|inconsisten\w*)\b/i;
|
|
573
|
+
const CONTRADICTION_HINT = ' Search only finds entities that mention a conflict. Whether current requirements contradict each other is decided by kb_check with rules ["domain-contradictions"]; what a proposed rule would conflict with, by kb_model mode predicates (decisionConflicts) on its text or a kb_upsert dryRun.';
|
|
515
574
|
export async function executeSearch(input, context) {
|
|
516
575
|
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
|
517
576
|
const { query, type, limit = 10, offset = 0, rankingMode = "intent-v1", semanticFacets, sourceLocations, minScore, fields = "summary", answer, } = input;
|
|
@@ -559,11 +618,11 @@ export async function executeSearch(input, context) {
|
|
|
559
618
|
// governing list is never read as the top match's requirement.
|
|
560
619
|
const topUngoverned = answerLayer?.ungoverned.find((entry) => entry.rank === 1);
|
|
561
620
|
const text = `${intentResult.matches.length === 0
|
|
562
|
-
? `No intent search results for '${trimmedQuery}' (abstained).`
|
|
621
|
+
? `No intent search results for '${trimmedQuery}' (abstained). No entity shares enough of the question's words: ask again in the words and language the KB is written in, or pass sourceLocations.`
|
|
563
622
|
: `Found ${intentResult.matches.length} intent search results for '${trimmedQuery}'${intentResult.analysis.ambiguous ? " (top matches are close; confirm before relying on one)" : ""}. Top: ${paginated
|
|
564
623
|
.slice(0, 5)
|
|
565
624
|
.map((match) => String(match.entity.id ?? ""))
|
|
566
|
-
.join(", ")}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}${topUngoverned ? ` (the top match ${topUngoverned.id} is linked to no requirement)` : ""}.`}${storeNote}`;
|
|
625
|
+
.join(", ")}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}${topUngoverned ? ` (the top match ${topUngoverned.id} is linked to no requirement)` : ""}.`}${CONTRADICTION_QUESTION.test(trimmedQuery) ? CONTRADICTION_HINT : ""}${storeNote}`;
|
|
567
626
|
return {
|
|
568
627
|
content: [{ type: "text", text }],
|
|
569
628
|
structuredContent: {
|
|
@@ -64,6 +64,8 @@ export declare function supersessionCycleReviewActionInput(cycle: {
|
|
|
64
64
|
export type SourcePathRewriteInput = Readonly<{
|
|
65
65
|
entityId: string;
|
|
66
66
|
file: string;
|
|
67
|
+
/** The field rewritten; absent means `source`. */
|
|
68
|
+
field?: "text_ref";
|
|
67
69
|
from: string;
|
|
68
70
|
to: string;
|
|
69
71
|
}>;
|
|
@@ -88,6 +90,8 @@ export declare function sourcePathRewriteActionInput(input: Readonly<{
|
|
|
88
90
|
*/
|
|
89
91
|
export declare function sourcePathReviewActionInput(source: {
|
|
90
92
|
entityId: string;
|
|
93
|
+
/** The field to repair; absent means `source`. */
|
|
94
|
+
field?: "text_ref";
|
|
91
95
|
value: unknown;
|
|
92
96
|
file?: string;
|
|
93
97
|
reason?: string;
|