kibi-cli 2.15.0 → 2.17.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-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +13 -0
- package/dist/cli-register-proof.d.ts +6 -0
- package/dist/cli-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +52 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +5 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +83 -4
- package/dist/commands/prove.js +1 -1
- package/dist/operations/modeling/model-requirement.d.ts +5 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +17 -5
- package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applicability.js +7 -1
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +16 -6
- package/dist/operations/modeling/predicate-utils.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-utils.js +2 -3
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +38 -7
- package/dist/operations/planning/migration-refusal.d.ts +14 -0
- package/dist/operations/planning/migration-refusal.d.ts.map +1 -0
- package/dist/operations/planning/migration-refusal.js +17 -0
- package/dist/operations/semantic-advisor/shared.d.ts +7 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/shared.js +22 -3
- package/dist/proof/inspect.d.ts +20 -1
- package/dist/proof/inspect.d.ts.map +1 -1
- package/dist/proof/inspect.js +17 -8
- package/dist/proof/integration-plan.d.ts +58 -0
- package/dist/proof/integration-plan.d.ts.map +1 -0
- package/dist/proof/integration-plan.js +348 -0
- package/dist/proof/integrations.js +1 -1
- package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
- package/dist/public/impact/coverage-depth-quality.js +29 -1
- package/dist/public/operations/catalog.d.ts +2 -2
- package/dist/public/operations/check-executor.d.ts +16 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +80 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +13 -3
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +28 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +23 -3
- 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/composite.d.ts +16 -3
- package/dist/public/operations/specs/composite.d.ts.map +1 -1
- package/dist/public/operations/specs/composite.js +79 -2
- package/dist/public/operations/specs/modeling.d.ts +1 -1
- package/dist/public/operations/specs/modeling.js +1 -1
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -1
- package/dist/public/skills/kibi-usage/SKILL.md +21 -7
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +3 -3
- package/dist/public/skills/kibi-usage/resources/proof.md +34 -4
- package/dist/utils/branch-store.d.ts +32 -0
- package/dist/utils/branch-store.d.ts.map +1 -1
- package/dist/utils/branch-store.js +122 -1
- 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/dist/utils/strict-modeling.d.ts +12 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +12 -1
- package/package.json +2 -2
- package/src/public/impact/coverage-depth-quality.ts +46 -1
- package/src/public/operations/check-executor.ts +105 -0
- package/src/public/operations/discovery-executors.ts +19 -2
- package/src/public/operations/migration-plan.ts +35 -0
- package/src/public/operations/result-envelope.ts +31 -3
- package/src/public/operations/specs/check-rules.generated.ts +2 -1
- package/src/public/operations/specs/composite.ts +110 -11
- package/src/public/operations/specs/modeling.ts +1 -1
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -1
- package/src/public/skills/kibi-usage/SKILL.md +21 -7
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +3 -3
- package/src/public/skills/kibi-usage/resources/proof.md +34 -4
|
@@ -185,10 +185,38 @@ function coverageForRequirement(result, manifestResults, entities) {
|
|
|
185
185
|
scenarioTests,
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Requirement statuses that keep a requirement in the coverage-depth review.
|
|
190
|
+
* `closed` is reviewed only when tagged `implemented` (the documented
|
|
191
|
+
* "done, with evidence" shape); a plain closed, deprecated or superseded
|
|
192
|
+
* requirement is retired history, not a coverage gap.
|
|
193
|
+
*/
|
|
194
|
+
const REVIEWED_REQUIREMENT_STATUSES = new Set([
|
|
195
|
+
"open",
|
|
196
|
+
"in_progress",
|
|
197
|
+
"active",
|
|
198
|
+
"approved",
|
|
199
|
+
]);
|
|
200
|
+
function supersededRequirementIds(manifestResults) {
|
|
201
|
+
return new Set(manifestResults.flatMap((result) => result.entity.type === "req"
|
|
202
|
+
? result.relationships.flatMap((relationship) => relationship.type === "supersedes" ? [relationship.to] : [])
|
|
203
|
+
: []));
|
|
204
|
+
}
|
|
205
|
+
// implements REQ-audit-quality-diagnostics-v1
|
|
206
|
+
function isReviewableRequirement(requirement, superseded) {
|
|
207
|
+
if (superseded.has(requirement.id))
|
|
208
|
+
return false;
|
|
209
|
+
const status = requirement.status.trim().toLowerCase();
|
|
210
|
+
if (REVIEWED_REQUIREMENT_STATUSES.has(status))
|
|
211
|
+
return true;
|
|
212
|
+
return (status === "closed" && (requirement.tags ?? []).includes("implemented"));
|
|
213
|
+
}
|
|
188
214
|
export function createCoverageDepthQualityDiagnostics(manifestResults, proofByRequirement = new Map()) {
|
|
189
215
|
const entities = entitiesById(manifestResults);
|
|
216
|
+
const superseded = supersededRequirementIds(manifestResults);
|
|
190
217
|
return manifestResults
|
|
191
|
-
.filter((result) => result.entity.type === "req"
|
|
218
|
+
.filter((result) => result.entity.type === "req" &&
|
|
219
|
+
isReviewableRequirement(result.entity, superseded))
|
|
192
220
|
.flatMap((result) => {
|
|
193
221
|
const diagnostic = createDiagnostic(coverageForRequirement(result, manifestResults, entities), proofByRequirement.get(result.entity.id));
|
|
194
222
|
return diagnostic === undefined ? [] : [diagnostic];
|
|
@@ -572,7 +572,7 @@ export declare const OPERATION_CATALOG: readonly [{
|
|
|
572
572
|
};
|
|
573
573
|
readonly requirementId: {
|
|
574
574
|
readonly type: "string";
|
|
575
|
-
readonly description: "Optional
|
|
575
|
+
readonly description: "Optional requirement ID. The strict write set updates this requirement instead of minting a REQ-AUTO id, and a typed logic rule attaches its requires_rule relationship to it.";
|
|
576
576
|
};
|
|
577
577
|
readonly claimKey: {
|
|
578
578
|
readonly type: "string";
|
|
@@ -1732,7 +1732,7 @@ export declare const OPERATION_CATALOG: readonly [{
|
|
|
1732
1732
|
readonly type: "string";
|
|
1733
1733
|
readonly enum: readonly string[];
|
|
1734
1734
|
};
|
|
1735
|
-
readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
|
|
1735
|
+
readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
|
|
1736
1736
|
};
|
|
1737
1737
|
readonly sourceFiles: {
|
|
1738
1738
|
readonly type: "array";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Violation } from "../check-types.js";
|
|
1
2
|
import { type CheckDiagnostic, type CheckStructuredContent, buildStructuredContent, buildSummary } from "./check-format-shared.js";
|
|
2
3
|
import { getEffectiveRules, resolveCheckRules } from "./check-helpers.js";
|
|
3
4
|
import type { OperationContext } from "./runtime-types.js";
|
|
@@ -16,6 +17,21 @@ export type { CheckDiagnostic, CheckStructuredContent };
|
|
|
16
17
|
export { buildStructuredContent, buildSummary, getEffectiveRules, resolveCheckRules, };
|
|
17
18
|
export type CheckExecutionOptions = {
|
|
18
19
|
readonly collectFullQualityDiagnosticsForExplicitRules?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The engine reads the current branch's store although the context carries
|
|
22
|
+
* no branch attachment (the `kibi check` engine path). A context with a
|
|
23
|
+
* branch attachment (the CLI and MCP runtimes) implies it; without either,
|
|
24
|
+
* the attached store is unknown (an explicit --kb-path store or an injected
|
|
25
|
+
* test store) and the branch-store compilation check is skipped.
|
|
26
|
+
*/
|
|
27
|
+
readonly branchStoreAttached?: boolean;
|
|
19
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* The one finding for a branch whose store was never compiled while .kb/
|
|
31
|
+
* holds authored sources. Every store-backed rule would read an empty KB
|
|
32
|
+
* (source-relationship-parity alone reports each authored relationship as
|
|
33
|
+
* missing), so kb_check reports this instead of any of them.
|
|
34
|
+
*/
|
|
35
|
+
export declare function uncompiledBranchStoreViolation(context: OperationContext, workspaceRoot: string): Violation | null;
|
|
20
36
|
export declare function executeCheck(args: CheckInput, context: OperationContext, options?: CheckExecutionOptions): Promise<OperationResult<CheckPayload>>;
|
|
21
37
|
//# sourceMappingURL=check-executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-executor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-executor.ts"],"names":[],"mappings":"
|
|
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,sBAAsB,EAC3B,sBAAsB,EACtB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,iBAAiB,EAGjB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAW5B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oB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|
3
|
+
import { BRANCH_STORE_NOT_COMPILED_RULE, inspectBranchStore, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
|
|
2
4
|
import { collectFullKbQualityDiagnostics } from "../impact-diagnostics.js";
|
|
3
5
|
import { buildStructuredContent, buildSummary, } from "./check-format-shared.js";
|
|
4
6
|
import { analyzeKbCheckImpact, collectQueryPlanSafetyViolations, getEffectiveRules, partitionCheckFindings, qualityDiagnosticsFromImpact, resolveCheckRules, stagedEntityIdStyleDiagnostics, } from "./check-helpers.js";
|
|
@@ -51,6 +53,44 @@ async function readStatusMigrationPlan(context) {
|
|
|
51
53
|
throw error;
|
|
52
54
|
}
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The one finding for a branch whose store was never compiled while .kb/
|
|
58
|
+
* holds authored sources. Every store-backed rule would read an empty KB
|
|
59
|
+
* (source-relationship-parity alone reports each authored relationship as
|
|
60
|
+
* missing), so kb_check reports this instead of any of them.
|
|
61
|
+
*/
|
|
62
|
+
// implements REQ-cli-status-pre-first-sync
|
|
63
|
+
export function uncompiledBranchStoreViolation(context, workspaceRoot) {
|
|
64
|
+
let attachment;
|
|
65
|
+
try {
|
|
66
|
+
attachment =
|
|
67
|
+
context.branchAttachment ?? resolveBranchAttachment(workspaceRoot);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if ("error" in attachment)
|
|
73
|
+
return null;
|
|
74
|
+
const store = inspectBranchStore(workspaceRoot, attachment.kbBranch);
|
|
75
|
+
const reason = uncompiledBranchStoreReason(workspaceRoot, store, attachment.kbBranch);
|
|
76
|
+
if (reason === null)
|
|
77
|
+
return null;
|
|
78
|
+
return {
|
|
79
|
+
rule: BRANCH_STORE_NOT_COMPILED_RULE,
|
|
80
|
+
entityId: attachment.kbBranch,
|
|
81
|
+
description: String(reason.detail),
|
|
82
|
+
suggestion: "Run kibi sync to compile this branch's store from the authored .kb/ sources (or apply the branch-store-compile action of the returned migrationPlan with kb_apply_plan), then rerun kb_check. Run kibi init once to install the git hooks that compile a new branch on checkout.",
|
|
83
|
+
source: store.path,
|
|
84
|
+
evidence: {
|
|
85
|
+
store: { state: store.state, path: store.path },
|
|
86
|
+
authoredSources: reason.authoredSources,
|
|
87
|
+
...(reason.generation !== undefined
|
|
88
|
+
? { generation: reason.generation }
|
|
89
|
+
: {}),
|
|
90
|
+
remediation: reason.remediation,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
54
94
|
// implements REQ-kibi-operation-interface-parity, REQ-002
|
|
55
95
|
export async function executeCheck(args, context, options = {}) {
|
|
56
96
|
try {
|
|
@@ -73,6 +113,46 @@ export async function executeCheck(args, context, options = {}) {
|
|
|
73
113
|
const maxDiagnosticsOption = args.maxDiagnostics !== undefined
|
|
74
114
|
? { maxDiagnostics: args.maxDiagnostics }
|
|
75
115
|
: {};
|
|
116
|
+
const uncompiled = context.branchAttachment !== undefined ||
|
|
117
|
+
options.branchStoreAttached === true
|
|
118
|
+
? uncompiledBranchStoreViolation(context, workspaceRoot)
|
|
119
|
+
: null;
|
|
120
|
+
if (uncompiled !== null) {
|
|
121
|
+
const violations = [uncompiled];
|
|
122
|
+
const statusPlan = await readStatusMigrationPlan(context);
|
|
123
|
+
const migrationPlan = await migrationPlanForCheck(context, violations, [], statusPlan);
|
|
124
|
+
return {
|
|
125
|
+
content: [
|
|
126
|
+
{
|
|
127
|
+
type: "text",
|
|
128
|
+
text: buildSummary({
|
|
129
|
+
violations,
|
|
130
|
+
impactResult,
|
|
131
|
+
qualityDiagnostics: [],
|
|
132
|
+
}),
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
structuredContent: buildStructuredContent({
|
|
136
|
+
violations,
|
|
137
|
+
diagnostics: [
|
|
138
|
+
{
|
|
139
|
+
category: "SYNC_ERROR",
|
|
140
|
+
severity: "error",
|
|
141
|
+
message: uncompiled.description,
|
|
142
|
+
...(uncompiled.source !== undefined
|
|
143
|
+
? { file: uncompiled.source }
|
|
144
|
+
: {}),
|
|
145
|
+
...(uncompiled.suggestion !== undefined
|
|
146
|
+
? { suggestion: uncompiled.suggestion }
|
|
147
|
+
: {}),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
qualityDiagnostics: [],
|
|
151
|
+
impactResult,
|
|
152
|
+
migrationPlan,
|
|
153
|
+
}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
76
156
|
if (rulesAllowlist.size === 0) {
|
|
77
157
|
const qualityDiagnostics = hasExplicitRules &&
|
|
78
158
|
options.collectFullQualityDiagnosticsForExplicitRules !== true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAGA,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,
|
|
1
|
+
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAGA,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,EAEL,KAAK,qBAAqB,EAK3B,MAAM,6BAA6B,CAAC;AASrC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EA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U,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACzD,CAAC;CACH,CAAC;AAqBF,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA2CxC;AAmDD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAgHzC;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CA6SzC"}
|
|
@@ -7,7 +7,7 @@ import { SwiplResolutionError } from "../../prolog/swipl-resolver.js";
|
|
|
7
7
|
import { buildSearchAnswer } from "../../search-answer.js";
|
|
8
8
|
import { rankEntities } from "../../search-ranking.js";
|
|
9
9
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
10
|
-
import { branchStoreReason, inspectBranchStore, storeLockJournalReason, } from "../../utils/branch-store.js";
|
|
10
|
+
import { BRANCH_STORE_NOT_COMPILED, branchStoreReason, inspectBranchStore, storeLockJournalReason, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
|
|
11
11
|
import { loadSearchCandidates, paginateResults, queryEntitiesViaQuery, reloadFullEntities, validateEntityType, } from "./discovery-entities.js";
|
|
12
12
|
import { buildActionsFromStatus, readMigrationConfigStatus, } from "./migration-plan.js";
|
|
13
13
|
import { OperationJsonDecodeError, runOperationJsonQuery, } from "./prolog-json.js";
|
|
@@ -273,7 +273,12 @@ export async function executeStatus(_input, context) {
|
|
|
273
273
|
}
|
|
274
274
|
const snapshotEvidence = await readWorkspaceSnapshot(context);
|
|
275
275
|
const existingReasons = payload.staleReasons ?? [];
|
|
276
|
-
|
|
276
|
+
// implements REQ-cli-status-pre-first-sync
|
|
277
|
+
// A missing or empty store beside authored sources gets the one reason
|
|
278
|
+
// whose remediation works (kibi sync); `kibi branch ensure` alone would
|
|
279
|
+
// leave the store empty.
|
|
280
|
+
const storeReason = uncompiledBranchStoreReason(context.workspaceRoot, store, attachment.kbBranch) ?? branchStoreReason(store);
|
|
281
|
+
const storeUncompiled = storeReason?.code === BRANCH_STORE_NOT_COMPILED;
|
|
277
282
|
const lockReason = storeLockJournalReason(store.path);
|
|
278
283
|
const compilerReason = compilerFingerprintReason(store.path);
|
|
279
284
|
const engineReason = engineStatus
|
|
@@ -306,6 +311,11 @@ export async function executeStatus(_input, context) {
|
|
|
306
311
|
// Source hashes can all match while the compilation itself is lossy, so
|
|
307
312
|
// a compiler contract change alone makes the store stale.
|
|
308
313
|
...(compilerReason ? { syncState: "stale", dirty: true } : {}),
|
|
314
|
+
// A missing or empty store has no stale file to report, yet nothing in
|
|
315
|
+
// it is current: the authored sources were never compiled. (A missing
|
|
316
|
+
// store without authored sources, and an unreadable or incomplete one,
|
|
317
|
+
// stay "unknown".)
|
|
318
|
+
...(storeUncompiled ? { syncState: "stale", dirty: true } : {}),
|
|
309
319
|
branchAttachment: attachment,
|
|
310
320
|
branchStore: store,
|
|
311
321
|
...(engineStatus ? { engineStatus } : {}),
|
|
@@ -437,7 +447,7 @@ export async function executeStatus(_input, context) {
|
|
|
437
447
|
content: [
|
|
438
448
|
{
|
|
439
449
|
type: "text",
|
|
440
|
-
text: `Branch ${payload.branch} is ${
|
|
450
|
+
text: `Branch ${payload.branch} is ${enrichedPayload.syncState} (snapshot ${payload.snapshotId}, dirty=${enrichedPayload.dirty}, proofSnapshot=${enrichedPayload.proofSnapshot})${storeUncompiled ? `. Blocking: ${String(storeReason?.detail)} Run kibi sync.` : ""}`,
|
|
441
451
|
},
|
|
442
452
|
],
|
|
443
453
|
structuredContent: statusWithPlan,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../../src/public/operations/migration-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../../src/public/operations/migration-plan.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,sBAAsB,EAAG,wBAAiC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,SAAS,CAAC;AACvD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC1C,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEP,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EACJ,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WAAW,GACX,cAAc,GACd,QAAQ,GACR,UAAU,GACV,OAAO,GACP,SAAS,CAAC;IACd,KAAK,EAAE,oBAAoB,CAAC;IAC5B,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,mBAAmB,CAAC;IAChC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;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IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,GAAG,aAAa,CA+OhB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
+
import { BRANCH_STORE_NOT_COMPILED } from "../../utils/branch-store.js";
|
|
4
5
|
import { legacyConfigExists } from "../../utils/config.js";
|
|
5
6
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
6
7
|
import { getSchemaVersionStatus, normalizeSchemaVersion, } from "../../utils/schema-version.js";
|
|
@@ -537,8 +538,35 @@ export function buildActionsFromStatus(input) {
|
|
|
537
538
|
autoApplicable: configStatus.status !== "newer",
|
|
538
539
|
}));
|
|
539
540
|
}
|
|
541
|
+
// implements REQ-cli-status-pre-first-sync
|
|
542
|
+
// A branch store that was never compiled while .kb/ holds authored sources
|
|
543
|
+
// is fixed only by compiling it: `kibi branch ensure` alone leaves an empty
|
|
544
|
+
// manifest. The compile step runs after the store exists and after any
|
|
545
|
+
// schema migration, so it compiles the migrated sources.
|
|
546
|
+
const uncompiled = (input.staleReasons ?? []).find((reason) => reason.code === BRANCH_STORE_NOT_COMPILED);
|
|
547
|
+
if (uncompiled !== undefined) {
|
|
548
|
+
actions.push(migrationAction({
|
|
549
|
+
id: "branch-store-compile",
|
|
550
|
+
code: BRANCH_STORE_NOT_COMPILED,
|
|
551
|
+
category: "storage",
|
|
552
|
+
safety: "automatic",
|
|
553
|
+
invocation: { kind: "cli", command_argv: ["kibi", "sync"] },
|
|
554
|
+
affectedFiles: [
|
|
555
|
+
typeof store?.path === "string" ? store.path : ".kb/branches",
|
|
556
|
+
],
|
|
557
|
+
evidence: { reason: uncompiled },
|
|
558
|
+
dependsOn: actions
|
|
559
|
+
.map((action) => action.id)
|
|
560
|
+
.filter((id) => id === "branch-store-ensure" || id === "schema-config-upgrade"),
|
|
561
|
+
postconditions: [{ branchStore: "compiled" }],
|
|
562
|
+
autoApplicable: true,
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
540
565
|
for (const reason of input.staleReasons ?? []) {
|
|
541
566
|
const code = typeof reason.code === "string" ? reason.code : "stale_source";
|
|
567
|
+
// Planned above as an automatic compile step, not a review.
|
|
568
|
+
if (code === BRANCH_STORE_NOT_COMPILED)
|
|
569
|
+
continue;
|
|
542
570
|
const file = typeof reason.path === "string" ? reason.path : "";
|
|
543
571
|
actions.push(migrationAction({
|
|
544
572
|
id: `freshness-${code}-${file}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-envelope.d.ts","sourceRoot":"","sources":["../../../src/public/operations/result-envelope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result-envelope.d.ts","sourceRoot":"","sources":["../../../src/public/operations/result-envelope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAoChD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAS/B;AAoFD,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC,GAAG,MAAM,CAET;AAYD,wBAAgB,YAAY,CAAC,CAAC,EAC5B,IAAI,EAAE;IACJ,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC,EACD,IAAI,EAAE,CAAC,EACP,OAAO,GAAE,OAAO,CACd,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,aAAa,GAAG,aAAa,GAAG,OAAO,CAAC,CACxE,GAAG;IACF;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CACzB,GACL,UAAU,CAAC,CAAC,CAAC,CAmDf;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKrD;AAGD,MAAM,WAAW,uBAAuB;IACtC,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,OAAO,GACd,uBAAuB,CAYzB;AAaD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,IAAI,CAKN"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MIGRATION_PLAN_REFUSED } from "../../operations/planning/migration-refusal.js";
|
|
1
2
|
export const KIBI_PROTOCOL_VERSION = 1;
|
|
2
3
|
function record(value) {
|
|
3
4
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -103,14 +104,25 @@ function extraFailedEffects(declared, data) {
|
|
|
103
104
|
export function resultVersion(spec) {
|
|
104
105
|
return spec.resultVersion ?? `kibi.${spec.name}.v1`;
|
|
105
106
|
}
|
|
107
|
+
function refusalDetail(row) {
|
|
108
|
+
const results = Array.isArray(row.actionResults) ? row.actionResults : [];
|
|
109
|
+
const failure = results.find((entry) => record(entry) && entry.outcome === "failed");
|
|
110
|
+
return record(failure) && typeof failure.detail === "string"
|
|
111
|
+
? failure.detail
|
|
112
|
+
: "";
|
|
113
|
+
}
|
|
106
114
|
export function toKibiResult(spec, data, options = {}) {
|
|
107
115
|
const row = record(data) ? data : undefined;
|
|
116
|
+
// A migration plan whose actions were all refused changed nothing: it is
|
|
117
|
+
// an error, not a success that needs reconciliation.
|
|
118
|
+
const migrationRefused = row?.version === "kibi.migration-apply-result.v1" &&
|
|
119
|
+
row.outcome === "refused";
|
|
108
120
|
let status = options.status;
|
|
109
121
|
if (!status) {
|
|
110
122
|
status = "success";
|
|
111
123
|
if (row?.status === "committed_with_repairs")
|
|
112
124
|
status = "committed_with_repairs";
|
|
113
|
-
if (row?.status === "rejected")
|
|
125
|
+
if (row?.status === "rejected" || migrationRefused)
|
|
114
126
|
status = "error";
|
|
115
127
|
}
|
|
116
128
|
const terminalError = row?.status === "rejected"
|
|
@@ -119,9 +131,17 @@ export function toKibiResult(spec, data, options = {}) {
|
|
|
119
131
|
message: "Bootstrap stopped at a deterministic failure. Inspect actionResults for committed actions and re-plan from the current state.",
|
|
120
132
|
retryable: false,
|
|
121
133
|
}
|
|
122
|
-
:
|
|
134
|
+
: migrationRefused
|
|
135
|
+
? {
|
|
136
|
+
code: MIGRATION_PLAN_REFUSED,
|
|
137
|
+
message: `Migration plan refused; nothing was changed. ${refusalDetail(row)}`.trim(),
|
|
138
|
+
retryable: false,
|
|
139
|
+
}
|
|
140
|
+
: undefined;
|
|
123
141
|
const resultError = options.error ?? terminalError;
|
|
124
|
-
const outcome = effectOutcome(status, options
|
|
142
|
+
const outcome = effectOutcome(status, migrationRefused && options.attempted === undefined
|
|
143
|
+
? { ...options, attempted: false }
|
|
144
|
+
: options);
|
|
125
145
|
return {
|
|
126
146
|
kibiProtocol: KIBI_PROTOCOL_VERSION,
|
|
127
147
|
operation: spec.name,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Every selectable kb_check rule name, registry order. */
|
|
2
2
|
export declare const SELECTABLE_RULE_NAMES: readonly string[];
|
|
3
3
|
/** Comma-separated "Allowed:" fragment for the kb_check rules description. */
|
|
4
|
-
export declare const SELECTABLE_RULES_ALLOWED = "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers";
|
|
4
|
+
export declare const SELECTABLE_RULES_ALLOWED = "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers";
|
|
5
5
|
//# sourceMappingURL=check-rules.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-rules.generated.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/check-rules.generated.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"check-rules.generated.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/check-rules.generated.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAgDlD,CAAC;AAGF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,2hCACq/B,CAAC"}
|
|
@@ -14,6 +14,7 @@ export const SELECTABLE_RULE_NAMES = [
|
|
|
14
14
|
"symbol-traceability",
|
|
15
15
|
"no-dangling-refs",
|
|
16
16
|
"source-relationship-parity",
|
|
17
|
+
"branch-store-not-compiled",
|
|
17
18
|
"source-path-dangling",
|
|
18
19
|
"no-cycles",
|
|
19
20
|
"required-fields",
|
|
@@ -58,4 +59,4 @@ export const SELECTABLE_RULE_NAMES = [
|
|
|
58
59
|
];
|
|
59
60
|
// implements REQ-006
|
|
60
61
|
/** Comma-separated "Allowed:" fragment for the kb_check rules description. */
|
|
61
|
-
export const SELECTABLE_RULES_ALLOWED = "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers";
|
|
62
|
+
export const SELECTABLE_RULES_ALLOWED = "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers";
|
|
@@ -12,7 +12,7 @@ export declare const checkSpec: {
|
|
|
12
12
|
readonly type: "string";
|
|
13
13
|
readonly enum: readonly string[];
|
|
14
14
|
};
|
|
15
|
-
readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
|
|
15
|
+
readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
|
|
16
16
|
};
|
|
17
17
|
readonly sourceFiles: {
|
|
18
18
|
readonly type: "array";
|
|
@@ -7,10 +7,23 @@ import type { OperationResult } from "../types.js";
|
|
|
7
7
|
* and the composite tool always agree.
|
|
8
8
|
*/
|
|
9
9
|
type Executor = (input: never, context: OperationContext) => Promise<unknown>;
|
|
10
|
-
|
|
10
|
+
type CompositeRoute = {
|
|
11
|
+
readonly name?: string;
|
|
11
12
|
readonly execute: Executor;
|
|
12
13
|
readonly businessInputSchema: Readonly<Record<string, unknown>>;
|
|
13
|
-
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A composite accepts every route's parameters, so a parameter of another
|
|
17
|
+
* route passes schema validation and the chosen route silently ignores it.
|
|
18
|
+
* Name each one instead, with the parameter this route uses for the same
|
|
19
|
+
* thing when there is one.
|
|
20
|
+
*/
|
|
21
|
+
export declare function foreignParameterWarnings(selector: "action" | "mode", choice: string, routes: Readonly<Record<string, CompositeRoute>>, rest: Readonly<Record<string, unknown>>): Array<{
|
|
22
|
+
parameter: string;
|
|
23
|
+
message: string;
|
|
24
|
+
nextAction: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function dispatchComposite(selector: "action" | "mode", routes: Readonly<Record<string, CompositeRoute>>, input: Readonly<Record<string, unknown>>, context: OperationContext): Promise<OperationResult<Record<string, unknown>>>;
|
|
14
27
|
export declare const SKILL_ROUTES: {
|
|
15
28
|
readonly list: {
|
|
16
29
|
readonly name: "kb_skills_list";
|
|
@@ -212,7 +225,7 @@ export declare const MODEL_ROUTES: {
|
|
|
212
225
|
};
|
|
213
226
|
readonly requirementId: {
|
|
214
227
|
readonly type: "string";
|
|
215
|
-
readonly description: "Optional
|
|
228
|
+
readonly description: "Optional requirement ID. The strict write set updates this requirement instead of minting a REQ-AUTO id, and a typed logic rule attaches its requires_rule relationship to it.";
|
|
216
229
|
};
|
|
217
230
|
readonly claimKey: {
|
|
218
231
|
readonly type: "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composite.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/composite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,aAAa,CAAC;AAMlE;;;;;GAKG;AACH,KAAK,Q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AAE,OAAO,CAAC,CAAC,EACxC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAuEnD;AAGD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIf,CAAC;AAGX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIf,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;CAqBW,CAAC;AAGnC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;CAwBY,CAAC"}
|
|
@@ -11,6 +11,51 @@ function requiredFields(spec) {
|
|
|
11
11
|
const required = spec.businessInputSchema.required;
|
|
12
12
|
return Array.isArray(required) ? required : [];
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Per route, the parameters another route of the same composite owns that
|
|
16
|
+
* mean the same thing here under another name. kb_model mode requirement
|
|
17
|
+
* takes the claim's subject as subjectKey; mode predicates takes it as
|
|
18
|
+
* subjectHint.
|
|
19
|
+
*/
|
|
20
|
+
const EQUIVALENT_PARAMETERS = {
|
|
21
|
+
kb_suggest_predicates: { subjectKey: "subjectHint" },
|
|
22
|
+
kb_model_requirement: { subjectHint: "subjectKey" },
|
|
23
|
+
};
|
|
24
|
+
/** Routed operations whose `warnings` are `{ kind, message, nextAction }`. */
|
|
25
|
+
const RECORD_WARNING_OPERATIONS = new Set(["kb_model_requirement"]);
|
|
26
|
+
// implements REQ-kibi-mcp-tool-consolidation
|
|
27
|
+
/**
|
|
28
|
+
* A composite accepts every route's parameters, so a parameter of another
|
|
29
|
+
* route passes schema validation and the chosen route silently ignores it.
|
|
30
|
+
* Name each one instead, with the parameter this route uses for the same
|
|
31
|
+
* thing when there is one.
|
|
32
|
+
*/
|
|
33
|
+
export function foreignParameterWarnings(selector, choice, routes, rest) {
|
|
34
|
+
const route = routes[choice];
|
|
35
|
+
if (route === undefined)
|
|
36
|
+
return [];
|
|
37
|
+
const own = new Set(Object.keys(properties(route)));
|
|
38
|
+
const equivalents = route.name === undefined ? {} : (EQUIVALENT_PARAMETERS[route.name] ?? {});
|
|
39
|
+
const warnings = [];
|
|
40
|
+
for (const parameter of Object.keys(rest)) {
|
|
41
|
+
if (own.has(parameter) || rest[parameter] === undefined)
|
|
42
|
+
continue;
|
|
43
|
+
const owners = Object.entries(routes)
|
|
44
|
+
.filter(([other, otherRoute]) => other !== choice && parameter in properties(otherRoute))
|
|
45
|
+
.map(([other]) => `${selector}: ${other}`);
|
|
46
|
+
if (owners.length === 0)
|
|
47
|
+
continue;
|
|
48
|
+
const equivalent = equivalents[parameter];
|
|
49
|
+
warnings.push({
|
|
50
|
+
parameter,
|
|
51
|
+
message: `${parameter} is a ${owners.join(" / ")} argument; ${selector}: ${choice} ignored it.`,
|
|
52
|
+
nextAction: equivalent !== undefined
|
|
53
|
+
? `Use ${equivalent} in ${selector}: ${choice}.`
|
|
54
|
+
: `Drop ${parameter}, or switch to ${owners.join(" / ")} if that is what you meant.`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return warnings;
|
|
58
|
+
}
|
|
14
59
|
export async function dispatchComposite(selector, routes, input, context) {
|
|
15
60
|
const choice = input[selector];
|
|
16
61
|
const route = typeof choice === "string" ? routes[choice] : undefined;
|
|
@@ -33,9 +78,41 @@ export async function dispatchComposite(selector, routes, input, context) {
|
|
|
33
78
|
const content = wrapped && Array.isArray(result.content)
|
|
34
79
|
? result.content
|
|
35
80
|
: [{ type: "text", text: `${selector} ${String(choice)} completed` }];
|
|
81
|
+
const ignored = foreignParameterWarnings(selector, String(choice), routes, rest);
|
|
82
|
+
if (ignored.length === 0) {
|
|
83
|
+
return {
|
|
84
|
+
content,
|
|
85
|
+
structuredContent: { [selector]: choice, ...payload },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// The routed payload's own warnings list carries them, in its own shape;
|
|
89
|
+
// a payload without one gets them in the text content only.
|
|
90
|
+
const asRecords = route.name !== undefined && RECORD_WARNING_OPERATIONS.has(route.name);
|
|
91
|
+
const routedWarnings = Array.isArray(payload.warnings)
|
|
92
|
+
? {
|
|
93
|
+
warnings: [
|
|
94
|
+
...payload.warnings,
|
|
95
|
+
...ignored.map((warning) => asRecords
|
|
96
|
+
? {
|
|
97
|
+
kind: "parameter_ignored",
|
|
98
|
+
message: warning.message,
|
|
99
|
+
nextAction: warning.nextAction,
|
|
100
|
+
}
|
|
101
|
+
: `${warning.message} ${warning.nextAction}`),
|
|
102
|
+
],
|
|
103
|
+
}
|
|
104
|
+
: {};
|
|
36
105
|
return {
|
|
37
|
-
content
|
|
38
|
-
|
|
106
|
+
content: [
|
|
107
|
+
...content,
|
|
108
|
+
{
|
|
109
|
+
type: "text",
|
|
110
|
+
text: ignored
|
|
111
|
+
.map((warning) => `${warning.message} ${warning.nextAction}`)
|
|
112
|
+
.join("\n"),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
structuredContent: { [selector]: choice, ...payload, ...routedWarnings },
|
|
39
116
|
};
|
|
40
117
|
}
|
|
41
118
|
// implements REQ-kibi-mcp-tool-consolidation
|
|
@@ -61,7 +61,7 @@ export declare const modelRequirementSpec: {
|
|
|
61
61
|
};
|
|
62
62
|
readonly requirementId: {
|
|
63
63
|
readonly type: "string";
|
|
64
|
-
readonly description: "Optional
|
|
64
|
+
readonly description: "Optional requirement ID. The strict write set updates this requirement instead of minting a REQ-AUTO id, and a typed logic rule attaches its requires_rule relationship to it.";
|
|
65
65
|
};
|
|
66
66
|
readonly claimKey: {
|
|
67
67
|
readonly type: "string";
|
|
@@ -56,7 +56,7 @@ export const modelRequirementSpec = {
|
|
|
56
56
|
},
|
|
57
57
|
requirementId: {
|
|
58
58
|
type: "string",
|
|
59
|
-
description: "Optional
|
|
59
|
+
description: "Optional requirement ID. The strict write set updates this requirement instead of minting a REQ-AUTO id, and a typed logic rule attaches its requires_rule relationship to it.",
|
|
60
60
|
},
|
|
61
61
|
claimKey: {
|
|
62
62
|
type: "string",
|