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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-protocol.d.ts","sourceRoot":"","sources":["../src/cli-protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG7D,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAS3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMpE,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG;IAC1C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CACpD,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,iBAAS,WAAW,CAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,UAAU,GAAG,cAAc,EAClC,IAAI,CAAC,EAAE;IACL,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,EACD,SAAS,UAAO,EAChB,OAAO,CAAC,EAAE,OAAO,GAChB,iBAAiB,CAwBnB;AA4BD;;;;GAIG;AAEH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE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AI,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EACvC,KAAK,EAAE,OAAO,GACb,iBAAiB,CAWnB;AAGD,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAqF5B"}
|
package/dist/cli-protocol.js
CHANGED
|
@@ -78,6 +78,19 @@ export async function executeOperation(catalogName, input, context) {
|
|
|
78
78
|
if (!protocolValid(spec, envelope)) {
|
|
79
79
|
return errorResult(catalogName, new OperationError("PROTOCOL_VALIDATION_FAILED", "Operation produced a result that does not satisfy its generated output contract."), spec);
|
|
80
80
|
}
|
|
81
|
+
// A result the operation itself reports as an error (a rejected
|
|
82
|
+
// bootstrap, a refused migration plan) exits non-zero like any other.
|
|
83
|
+
if (envelope.status === "error") {
|
|
84
|
+
return {
|
|
85
|
+
exitCode: 1,
|
|
86
|
+
stdout: `${JSON.stringify(envelope)}\n`,
|
|
87
|
+
...(envelope.error
|
|
88
|
+
? {
|
|
89
|
+
stderr: `Error [${envelope.error.code}]: ${envelope.error.message}\n`,
|
|
90
|
+
}
|
|
91
|
+
: {}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
81
94
|
return { exitCode: 0, stdout: `${JSON.stringify(envelope)}\n` };
|
|
82
95
|
}
|
|
83
96
|
catch (error) {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
export declare function registerProofCommand(program: Command): void;
|
|
3
|
+
/**
|
|
4
|
+
* `--command` for `kibi proof inspect`: a JSON array of argv strings, or
|
|
5
|
+
* space-separated words (no shell quoting; Kibi runs integrations with
|
|
6
|
+
* `shell: false`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseCommandOption(value: string): readonly string[];
|
|
3
9
|
//# sourceMappingURL=cli-register-proof.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-register-proof.d.ts","sourceRoot":"","sources":["../src/cli-register-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"cli-register-proof.d.ts","sourceRoot":"","sources":["../src/cli-register-proof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2M3D;AAED;;;;GAIG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAwBnE"}
|
|
@@ -39,10 +39,18 @@ export function registerProofCommand(program) {
|
|
|
39
39
|
.description("Inspect proof integration and maintain proof evidence");
|
|
40
40
|
proof
|
|
41
41
|
.command("inspect")
|
|
42
|
-
.description("Detect test infrastructure and
|
|
42
|
+
.description("Detect test infrastructure, propose a proof integration and return the reviewed plan that writes .kb/proof/integrations.json")
|
|
43
|
+
.option("--update <id>", "Plan adding or replacing this integration in an existing .kb/proof/integrations.json")
|
|
44
|
+
.option("--command <command>", 'Command the proposed integration runs instead of the detected one: space-separated words, or a JSON array of argv strings (e.g. \'["npx","vitest","run","tests/e2e"]\')')
|
|
43
45
|
.option("--json", "Emit structured JSON", false)
|
|
44
46
|
.action(withExitCode(async (options) => {
|
|
45
|
-
const
|
|
47
|
+
const command = options.command === undefined
|
|
48
|
+
? undefined
|
|
49
|
+
: parseCommandOption(options.command);
|
|
50
|
+
const result = await (await import("./proof/inspect.js")).inspectProofEnvironment(process.cwd(), {
|
|
51
|
+
...(options.update === undefined ? {} : { update: options.update }),
|
|
52
|
+
...(command === undefined ? {} : { command }),
|
|
53
|
+
});
|
|
46
54
|
if (options.json) {
|
|
47
55
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
48
56
|
return undefined;
|
|
@@ -108,6 +116,33 @@ export function registerProofCommand(program) {
|
|
|
108
116
|
});
|
|
109
117
|
}));
|
|
110
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* `--command` for `kibi proof inspect`: a JSON array of argv strings, or
|
|
121
|
+
* space-separated words (no shell quoting; Kibi runs integrations with
|
|
122
|
+
* `shell: false`).
|
|
123
|
+
*/
|
|
124
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
125
|
+
export function parseCommandOption(value) {
|
|
126
|
+
const trimmed = value.trim();
|
|
127
|
+
if (trimmed.startsWith("[")) {
|
|
128
|
+
let parsed;
|
|
129
|
+
try {
|
|
130
|
+
parsed = JSON.parse(trimmed);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
throw new Error("--command must be a JSON array of argv strings or space-separated words.");
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(parsed) ||
|
|
136
|
+
parsed.length === 0 ||
|
|
137
|
+
!parsed.every((entry) => typeof entry === "string" && entry !== ""))
|
|
138
|
+
throw new Error("--command must be a JSON array of non-empty argv strings.");
|
|
139
|
+
return parsed;
|
|
140
|
+
}
|
|
141
|
+
const words = trimmed.split(/\s+/).filter((word) => word !== "");
|
|
142
|
+
if (words.length === 0)
|
|
143
|
+
throw new Error("--command must not be empty.");
|
|
144
|
+
return words;
|
|
145
|
+
}
|
|
111
146
|
function renderInspection(result) {
|
|
112
147
|
const inspection = result;
|
|
113
148
|
const lines = ["Proof environment", ""];
|
|
@@ -136,5 +171,20 @@ function renderInspection(result) {
|
|
|
136
171
|
for (const entry of inspection.missing)
|
|
137
172
|
lines.push(` - ${entry}`);
|
|
138
173
|
}
|
|
174
|
+
if (inspection.proposedIntegration) {
|
|
175
|
+
const proposed = inspection.proposedIntegration;
|
|
176
|
+
lines.push("");
|
|
177
|
+
lines.push(`Proposed integration: ${proposed.id} (${proposed.producer}: ${proposed.command.join(" ")})`);
|
|
178
|
+
}
|
|
179
|
+
if (inspection.integrationPlan) {
|
|
180
|
+
const plan = inspection.integrationPlan;
|
|
181
|
+
lines.push(`Integration plan: ${plan.planHash.slice(0, 12)} (actions: ${plan.actions.map((action) => action.id).join(", ")}); rerun with --json for the plan to pass to kb_apply_plan.`);
|
|
182
|
+
if (inspection.integrationPlanReason)
|
|
183
|
+
lines.push(inspection.integrationPlanReason);
|
|
184
|
+
}
|
|
185
|
+
else if (inspection.integrationPlanReason) {
|
|
186
|
+
lines.push("");
|
|
187
|
+
lines.push(`Integration plan: none. ${inspection.integrationPlanReason}`);
|
|
188
|
+
}
|
|
139
189
|
return `${lines.join("\n")}\n`;
|
|
140
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA8E7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AA8gBD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAC5B,MAAM,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAC3B,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAMpB;AAGD,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC;IAAE,QA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,OAAO,CAAC,SAAS,EAAE,CAAC,CAkEtB;AAID,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAmGtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,SAAS,EAAE,CAAC,CAyCtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAgDtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CA0BtB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CA+BtB"}
|
package/dist/commands/check.js
CHANGED
|
@@ -885,7 +885,11 @@ export async function checkCommand(options) {
|
|
|
885
885
|
invalidateCache: () => activeProlog.invalidateCache(),
|
|
886
886
|
save: () => activeProlog.query("kb_save"),
|
|
887
887
|
},
|
|
888
|
-
}, {
|
|
888
|
+
}, {
|
|
889
|
+
collectFullQualityDiagnosticsForExplicitRules: true,
|
|
890
|
+
// The engine reads the branch store; an explicit --kb-path does not.
|
|
891
|
+
branchStoreAttached: options.kbPath === undefined,
|
|
892
|
+
});
|
|
889
893
|
const violations = result.structuredContent?.violations ?? [];
|
|
890
894
|
const qualityDiagnostics = result.structuredContent?.qualityDiagnostics ?? [];
|
|
891
895
|
if (options.format === "json") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AA2FA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAmH/B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,GAAE,MAAM,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CACT,GACxC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;;;MAkE3C;AAkGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAepB"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -25,7 +25,8 @@ import { kibiPackageVersions } from "../package-versions.js";
|
|
|
25
25
|
import { describeConfiguredCapabilityPlugins, readProjectKibiConfig, } from "../plugins/project-config.js";
|
|
26
26
|
import { SwiplResolutionError, inspectSwiplBundle, probeRequiredLibraries, resolveSwipl, } from "../prolog/swipl-resolver.js";
|
|
27
27
|
import { buildMigrationPlan, migrationAction, } from "../public/operations/migration-plan.js";
|
|
28
|
-
import { resolveReadBranchAttachment } from "../utils/branch-resolver.js";
|
|
28
|
+
import { resolveBranchAttachment, resolveReadBranchAttachment, } from "../utils/branch-resolver.js";
|
|
29
|
+
import { branchStoreCompilation, inspectBranchStore, uncompiledBranchStoreReason, } from "../utils/branch-store.js";
|
|
29
30
|
import { resolveGitRepository, } from "../utils/git-repository-context.js";
|
|
30
31
|
import { readKbManifestStatus } from "../utils/kb-manifest.js";
|
|
31
32
|
import { hasManagedHooks, outdatedManagedHooks } from "./init-helpers.js";
|
|
@@ -68,6 +69,10 @@ export async function doctorCommand(options = {}) {
|
|
|
68
69
|
name: "Git repository",
|
|
69
70
|
check: checkGitRepository,
|
|
70
71
|
},
|
|
72
|
+
{
|
|
73
|
+
name: "Branch store",
|
|
74
|
+
check: checkBranchStore,
|
|
75
|
+
},
|
|
71
76
|
{
|
|
72
77
|
name: "Git hooks",
|
|
73
78
|
check: checkGitHooks,
|
|
@@ -98,6 +103,7 @@ export async function doctorCommand(options = {}) {
|
|
|
98
103
|
results.push({ name, ...(await check()) });
|
|
99
104
|
}
|
|
100
105
|
const allPassed = results.every((result) => result.passed);
|
|
106
|
+
const warnings = results.filter((result) => result.passed && result.warning === true).length;
|
|
101
107
|
const runtime = await runtimeProvenance();
|
|
102
108
|
const packageActions = await packageMigrationActions(runtime);
|
|
103
109
|
const migrationPlan = buildMigrationPlan({
|
|
@@ -113,6 +119,7 @@ export async function doctorCommand(options = {}) {
|
|
|
113
119
|
console.log(JSON.stringify({
|
|
114
120
|
version: "kibi.doctor.v1",
|
|
115
121
|
passed: allPassed,
|
|
122
|
+
warnings,
|
|
116
123
|
runtime,
|
|
117
124
|
checks: results,
|
|
118
125
|
migrationPlan,
|
|
@@ -121,12 +128,17 @@ export async function doctorCommand(options = {}) {
|
|
|
121
128
|
}
|
|
122
129
|
console.log("Kibi Environment Diagnostics\n");
|
|
123
130
|
for (const result of results) {
|
|
124
|
-
const
|
|
131
|
+
const warned = result.passed && result.warning === true;
|
|
132
|
+
const status = !result.passed ? "✗" : warned ? "!" : "✓";
|
|
125
133
|
console.log(`${status} ${result.name}: ${result.message}`);
|
|
126
|
-
if (!result.passed && result.remediation)
|
|
134
|
+
if ((!result.passed || warned) && result.remediation)
|
|
127
135
|
console.log(` → ${result.remediation}`);
|
|
128
136
|
}
|
|
129
137
|
console.log();
|
|
138
|
+
if (allPassed && warnings > 0) {
|
|
139
|
+
console.log(`All required checks passed, with ${warnings} warning(s) above (marked !).`);
|
|
140
|
+
return { exitCode: 0 };
|
|
141
|
+
}
|
|
130
142
|
if (allPassed) {
|
|
131
143
|
console.log("All checks passed! Your environment is ready.");
|
|
132
144
|
return { exitCode: 0 };
|
|
@@ -644,6 +656,68 @@ function checkGitRepository() {
|
|
|
644
656
|
};
|
|
645
657
|
}
|
|
646
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* The current branch's KB store: it must exist and hold a compilation
|
|
661
|
+
* (journal sequence above 0) when .kb/ has authored sources. Kibi stores are
|
|
662
|
+
* per branch and never copied, so a branch created without the post-checkout
|
|
663
|
+
* hook starts empty until `kibi sync`.
|
|
664
|
+
*/
|
|
665
|
+
// implements REQ-cli-doctor
|
|
666
|
+
function checkBranchStore() {
|
|
667
|
+
const workspaceRoot = process.cwd();
|
|
668
|
+
let attachment;
|
|
669
|
+
try {
|
|
670
|
+
attachment = resolveBranchAttachment(workspaceRoot);
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
attachment = {
|
|
674
|
+
error: error instanceof Error ? error.message : String(error),
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
if ("error" in attachment) {
|
|
678
|
+
return {
|
|
679
|
+
passed: true,
|
|
680
|
+
message: `Not checked: no current Git branch (${attachment.error})`,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
const branch = attachment.kbBranch;
|
|
684
|
+
const store = inspectBranchStore(workspaceRoot, branch);
|
|
685
|
+
const details = { branch, path: store.path, state: store.state };
|
|
686
|
+
if (store.state === "incomplete" || store.state === "unreadable") {
|
|
687
|
+
return {
|
|
688
|
+
passed: false,
|
|
689
|
+
message: `Store for ${branch} is ${store.state}: ${store.detail ?? store.errorCode ?? "requires recovery"}`,
|
|
690
|
+
remediation: "Run: kibi branch recover, then kibi branch recover --apply",
|
|
691
|
+
details,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
const compilation = branchStoreCompilation(store);
|
|
695
|
+
if (compilation.compiled) {
|
|
696
|
+
return {
|
|
697
|
+
passed: true,
|
|
698
|
+
message: `Compiled for ${branch}${compilation.generation ? ` (${compilation.generation})` : ""}`,
|
|
699
|
+
details: { ...details, generation: compilation.generation },
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
const reason = uncompiledBranchStoreReason(workspaceRoot, store, branch);
|
|
703
|
+
if (reason === null) {
|
|
704
|
+
return {
|
|
705
|
+
passed: true,
|
|
706
|
+
message: `Not compiled yet for ${branch}; .kb/ holds no authored sources`,
|
|
707
|
+
details,
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
passed: false,
|
|
712
|
+
message: String(reason.detail),
|
|
713
|
+
remediation: "Run: kibi sync",
|
|
714
|
+
details: {
|
|
715
|
+
...details,
|
|
716
|
+
generation: compilation.generation,
|
|
717
|
+
authoredSources: reason.authoredSources,
|
|
718
|
+
},
|
|
719
|
+
};
|
|
720
|
+
}
|
|
647
721
|
// Hook health must be diagnosed against the hooks directory Git actually
|
|
648
722
|
// executes (resolved via git rev-parse --git-path hooks, honoring
|
|
649
723
|
// core.hooksPath and linked worktrees), not against <cwd>/.git/hooks.
|
|
@@ -720,10 +794,15 @@ function checkGitHooks() {
|
|
|
720
794
|
const postMergeExists = existsSync(postMergePath);
|
|
721
795
|
// An existing pre-commit is hard enforcement; the companions being absent
|
|
722
796
|
// must not downgrade the summary to "optional".
|
|
797
|
+
// implements REQ-cli-doctor
|
|
798
|
+
// Without the hooks kibi init installs, a new branch starts with an empty
|
|
799
|
+
// store (post-checkout compiles it) and commits skip kibi check --staged.
|
|
723
800
|
if (!postCheckoutExists && !postMergeExists && !existsSync(preCommitPath)) {
|
|
724
801
|
return {
|
|
725
802
|
passed: true,
|
|
726
|
-
|
|
803
|
+
warning: true,
|
|
804
|
+
message: `Not installed: a new branch is not compiled on checkout and commits skip 'kibi check --staged'${hooksPathSuffix()}`,
|
|
805
|
+
remediation: "Run: kibi init (installs the git hooks)",
|
|
727
806
|
};
|
|
728
807
|
}
|
|
729
808
|
if (postCheckoutExists && postMergeExists) {
|
package/dist/commands/prove.js
CHANGED
|
@@ -279,7 +279,7 @@ export async function proveCommand(options, deps = {}) {
|
|
|
279
279
|
for (const [integrationId, tests] of groups) {
|
|
280
280
|
const integration = resolveIntegration(integrations.integrations, integrationId);
|
|
281
281
|
if (!integration) {
|
|
282
|
-
failures.push(`integration '${integrationId}' (required by ${tests.map((t) => t.id).join(", ")}) is not configured in .kb/proof/integrations.json`);
|
|
282
|
+
failures.push(`integration '${integrationId}' (required by ${tests.map((t) => t.id).join(", ")}) is not configured in .kb/proof/integrations.json; plan it with kibi proof inspect --update ${integrationId} --json and apply the plan with kb_apply_plan`);
|
|
283
283
|
continue;
|
|
284
284
|
}
|
|
285
285
|
const commandArgv = [...integration.command];
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { type StrictWriteSet } from "../../public/check-types.js";
|
|
1
2
|
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
3
|
import { strictWriteSetToApplyPlan, writeSetPrimaryEntityId } from "./requirement-applyplan.js";
|
|
3
4
|
import { estimateNormativeSignalConfidence, extractRequirementClaim } from "./requirement-modeler.js";
|
|
4
5
|
import type { ModelRequirementArgs, ModelRequirementResult } from "./requirement-types.js";
|
|
5
6
|
export type { ModelRequirementArgs, ModelRequirementResult, } from "./requirement-types.js";
|
|
7
|
+
export declare function reuseExistingSubject(writeSet: StrictWriteSet, existingFactId: string): {
|
|
8
|
+
writeSet: StrictWriteSet;
|
|
9
|
+
replacedSubjectId: string | null;
|
|
10
|
+
};
|
|
6
11
|
export { estimateNormativeSignalConfidence, extractRequirementClaim, strictWriteSetToApplyPlan, writeSetPrimaryEntityId, };
|
|
7
12
|
export declare function annotateModelRequirementStep(step: Record<string, unknown>, context: {
|
|
8
13
|
claimKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-requirement.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/model-requirement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-requirement.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/model-requirement.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAiBjF,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAUhC,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAuBhC,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,cAAc,EAAE,MAAM,GACrB;IAAE,QAAQ,EAAE,cAAc,CAAC;IAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAuBhE;AA2KD,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GACxB,CAAC;AAIF,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,GACA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+CzB;AAwOD,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIxB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,oBAAoB,EAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,sBAAsB,CAAC,CAwHjC;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAajC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildStrictWriteSet, } from "../../public/check-types.js";
|
|
2
2
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
3
|
-
import { isConventionalSubjectKey, normalizeSubjectKey, } from "../../utils/strict-modeling.js";
|
|
3
|
+
import { factSourcePath, isConventionalSubjectKey, normalizeSubjectKey, } from "../../utils/strict-modeling.js";
|
|
4
4
|
import { modeledClaimRole, normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
|
|
5
5
|
import { detectConditionalRule } from "../semantic-advisor/conditional-rules.js";
|
|
6
6
|
import { advisorPropositionRole } from "../semantic-advisor/proposition-role.js";
|
|
@@ -11,7 +11,10 @@ import { estimateNormativeSignalConfidence, extractRequirementClaim, } from "./r
|
|
|
11
11
|
import { normalizeOptionalString, normalizeSourceFiles, } from "./requirement-utils.js";
|
|
12
12
|
import { alignRequirementVocabulary, } from "./vocabulary-alignment.js";
|
|
13
13
|
const NEW_SUBJECT_REVIEW_SCORE = 0.3;
|
|
14
|
-
|
|
14
|
+
// implements REQ-kibi-subject-vocabulary
|
|
15
|
+
// The write set describes the existing subject fact, so its id and its source
|
|
16
|
+
// both name that fact; the minted fact (and its file) is never created.
|
|
17
|
+
export function reuseExistingSubject(writeSet, existingFactId) {
|
|
15
18
|
if (!writeSet.isStrict)
|
|
16
19
|
return { writeSet, replacedSubjectId: null };
|
|
17
20
|
const replacedSubjectId = writeSet.subjectFact.id;
|
|
@@ -22,7 +25,11 @@ function reuseExistingSubject(writeSet, existingFactId) {
|
|
|
22
25
|
subjectFact: {
|
|
23
26
|
...writeSet.subjectFact,
|
|
24
27
|
id: existingFactId,
|
|
25
|
-
properties: {
|
|
28
|
+
properties: {
|
|
29
|
+
...writeSet.subjectFact.properties,
|
|
30
|
+
id: existingFactId,
|
|
31
|
+
source: factSourcePath(existingFactId),
|
|
32
|
+
},
|
|
26
33
|
},
|
|
27
34
|
relationships: writeSet.relationships.map((relationship) => relationship.type === "constrains"
|
|
28
35
|
? { ...relationship, to: existingFactId }
|
|
@@ -57,10 +64,11 @@ function possibleDuplicateObservation(claimKey, statement, source, candidates) {
|
|
|
57
64
|
* when the keys match. Otherwise the plan explicitly declares a new subject.
|
|
58
65
|
*/
|
|
59
66
|
// implements REQ-kibi-subject-vocabulary
|
|
60
|
-
async function applyVocabularyAlignment(context, extracted, claimKey) {
|
|
67
|
+
async function applyVocabularyAlignment(context, extracted, claimKey, requirementId) {
|
|
61
68
|
const initial = buildStrictWriteSet({
|
|
62
69
|
claim: extracted.claim,
|
|
63
70
|
statement: extracted.statement,
|
|
71
|
+
...(requirementId !== undefined ? { requirementId } : {}),
|
|
64
72
|
});
|
|
65
73
|
const unchanged = {
|
|
66
74
|
writeSet: initial,
|
|
@@ -90,6 +98,7 @@ async function applyVocabularyAlignment(context, extracted, claimKey) {
|
|
|
90
98
|
const rebuilt = buildStrictWriteSet({
|
|
91
99
|
claim: { ...extracted.claim, subjectKey: subject.subjectKey },
|
|
92
100
|
statement: extracted.statement,
|
|
101
|
+
...(requirementId !== undefined ? { requirementId } : {}),
|
|
93
102
|
});
|
|
94
103
|
({ writeSet, replacedSubjectId } = reuseExistingSubject(rebuilt, subject.existingFactId));
|
|
95
104
|
}
|
|
@@ -431,7 +440,10 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot, con
|
|
|
431
440
|
if (conditional?.kind === "unparsed")
|
|
432
441
|
return unresolvedConditionalResult(args, extracted, conditional.reason, workspaceRoot);
|
|
433
442
|
const claimKey = semanticClaimKey(extracted.statement);
|
|
434
|
-
|
|
443
|
+
// implements REQ-kibi-subject-vocabulary
|
|
444
|
+
// A caller-named requirement keeps its id: the strict write set updates it
|
|
445
|
+
// instead of minting REQ-AUTO-<hash>.
|
|
446
|
+
const aligned = await applyVocabularyAlignment(context, extracted, claimKey, normalizeOptionalString(args.requirementId));
|
|
435
447
|
const writeSet = aligned.writeSet;
|
|
436
448
|
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
437
449
|
const plan = aligned.adjustPlan(strictWriteSetToApplyPlan(writeSet));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA2W1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,GACX,qBAAqB,CA2EvB"}
|
|
@@ -96,7 +96,13 @@ const INTENT_RULES = {
|
|
|
96
96
|
permission_rule: {
|
|
97
97
|
allOf: [
|
|
98
98
|
[/only|may|can|allowed|denied|forbidden|must\s+not|cannot/i],
|
|
99
|
-
[
|
|
99
|
+
[
|
|
100
|
+
/delete|export|access|read|write|update|remove|manage|permission/i,
|
|
101
|
+
// A common action verb counts only right after the permission modal
|
|
102
|
+
// ("must not publish", "may approve"), so a quota such as "uploads
|
|
103
|
+
// must not exceed 10 MB" does not read as a permission.
|
|
104
|
+
/\b(?:may|can|cannot|can't|must\s+(?:not|never)|never|(?:is|are)\s+(?:not\s+)?(?:allowed|permitted|forbidden)\s+to)\s+(?:only\s+)?(?:publish|unpublish|approve|assign|view|see|edit|modify|create|submit|share|invite|upload|download|comment|post|complete|archive|restore|grant|revoke|purchase|cancel|execute|invoke|configure|moderate|ban|join|book|reserve|transfer|close|reopen|merge)\b/i,
|
|
105
|
+
],
|
|
100
106
|
],
|
|
101
107
|
},
|
|
102
108
|
resource_constraint: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAQ9B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,EACvD,YAAY,CAAC,EAAE,QAAQ,GAAG,MAAM,EAChC,WAAW,CAAC,EAAE;IACZ,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAA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GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0ChC;AAGD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAuBhC;AAoBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,0BAA0B,CAoE5B"}
|
|
@@ -74,17 +74,27 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
74
74
|
constrainedSubjects,
|
|
75
75
|
}),
|
|
76
76
|
]));
|
|
77
|
-
// The
|
|
78
|
-
// constrains
|
|
79
|
-
//
|
|
80
|
-
|
|
77
|
+
// The subjects the planned predicate must be about: those the requirement
|
|
78
|
+
// constrains, or, for a requirement that is not written yet or constrains
|
|
79
|
+
// nothing, the explicit subjectHint. The hint is then the subject fact the
|
|
80
|
+
// agent is about to link, so the planned fact carries its subject_key and
|
|
81
|
+
// kb_check pairs the two once the requirement is written.
|
|
82
|
+
const plannedSubjects = constrainedSubjects.length > 0
|
|
83
|
+
? constrainedSubjects
|
|
84
|
+
: explicitSubject
|
|
85
|
+
? [subject]
|
|
86
|
+
: [];
|
|
87
|
+
// The subject the planned predicate fact is about: the `subject`
|
|
88
|
+
// argument's value, or for a schema without one the reviewed subject,
|
|
89
|
+
// recorded as the fact's subject_key.
|
|
90
|
+
const subjectKey = plannedSubjects.length === 0
|
|
81
91
|
? null
|
|
82
92
|
: subjectArgument >= 0
|
|
83
93
|
? (predicateArgs[subjectArgument] ?? null)
|
|
84
94
|
: (reviewedSubject ?? null);
|
|
85
|
-
const subjectPairing =
|
|
95
|
+
const subjectPairing = plannedSubjects.length === 0
|
|
86
96
|
? "not_required"
|
|
87
|
-
: subjectKey !== null &&
|
|
97
|
+
: subjectKey !== null && plannedSubjects.includes(subjectKey)
|
|
88
98
|
? "paired"
|
|
89
99
|
: "unpaired";
|
|
90
100
|
const bindingProvenance = aggregateBindingProvenance(Object.values(bindingProvenanceByArgument));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-utils.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"predicate-utils.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlD;AAGD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAGpB;AAGD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,CAIR;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAM5D;AAGD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM1C;AAGD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAO9D;AAED;;;;;;GAMG;AAEH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,CAAC,EAAE,QAAQ,CAAC;IACrB,aAAa,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|
const DEFAULT_MIN_SCORE = 0.35;
|
|
3
4
|
// implements REQ-mcp-suggest-predicates
|
|
4
5
|
export function normalizeText(text) {
|
|
@@ -114,9 +115,7 @@ export function normalizePredicateToken(value) {
|
|
|
114
115
|
}
|
|
115
116
|
// implements REQ-mcp-suggest-predicates
|
|
116
117
|
export function singularize(value) {
|
|
117
|
-
|
|
118
|
-
return value;
|
|
119
|
-
return value.endsWith("s") && value.length > 3 ? value.slice(0, -1) : value;
|
|
118
|
+
return singularizeToken(value, ["changes", "status", "results"]);
|
|
120
119
|
}
|
|
121
120
|
// implements REQ-mcp-suggest-predicates
|
|
122
121
|
export function normalizeSubjectKey(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-plan.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/apply-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply-plan.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/apply-plan.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAEV,gBAAgB,EAGjB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAC;AAgE/B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AA6G9E,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,IAAI,CAMN;AAED,wBAAgB,mCAAmC,CACjD,SAAS,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,EACnE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,IAAI,CAaN;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,SAAS,cAAoB,GAC5B,eAAe,EAAE,CA2CnB;AA8zBD;;;;;;GAMG;AAEH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAiCf;AAyqDD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,eAAe,CAAC;CACpC,CAAC,CAkDD"}
|
|
@@ -4,12 +4,14 @@ import { OperationError } from "../../cli-errors.js";
|
|
|
4
4
|
import { branchEnsureCommand, branchMigrateCommand, branchRecoverCommand, } from "../../commands/branch.js";
|
|
5
5
|
import { migrateCommand } from "../../commands/migrate.js";
|
|
6
6
|
import { syncCommand } from "../../commands/sync.js";
|
|
7
|
+
import { PROOF_INTEGRATION_CONFIGURE, applyProofIntegrationAction, } from "../../proof/integration-plan.js";
|
|
7
8
|
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
8
9
|
import { executeStatus } from "../../public/operations/discovery-executors.js";
|
|
9
10
|
import { PREDICATE_SCHEMA_ALIGNMENT_CODE, migrationPlanHash, } from "../../public/operations/migration-plan.js";
|
|
10
11
|
import { readMigrationConfigStatus } from "../../public/operations/migration-plan.js";
|
|
11
12
|
import { readWorkspaceSnapshot } from "../../public/operations/workspace-snapshot.js";
|
|
12
13
|
import { computeShardPath, renderShardWithRelationship, } from "../../relationships/shards.js";
|
|
14
|
+
import { BRANCH_STORE_NOT_COMPILED } from "../../utils/branch-store.js";
|
|
13
15
|
import { canonicalFilesystemPath } from "../../utils/canonical-path.js";
|
|
14
16
|
import { isDerivedKbPath } from "../../utils/kb-paths.js";
|
|
15
17
|
import { bootstrapEmptyKbSnapshotId, bootstrapPlanHash, } from "../bootstrap/types.js";
|
|
@@ -22,6 +24,7 @@ import { canonicalSourcePath, renderSourceDocument, } from "../mutation/source-a
|
|
|
22
24
|
import { assertRelationshipShardContained, executeUpsert, validateUpsertForCommit, } from "../mutation/upsert.js";
|
|
23
25
|
import { acquireWorkspaceMutationLock, releaseWorkspaceMutationLock, } from "../mutation/workspace-mutation-lock.js";
|
|
24
26
|
import { compilePlanHash, isBlockingWitness, parseWhatIfAnalysis, planWhatIfGoal, } from "./compile-intent.js";
|
|
27
|
+
import { MigrationActionRefusedError } from "./migration-refusal.js";
|
|
25
28
|
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
26
29
|
export const PLAN_APPLY_RESULT_VERSION = "kibi.plan-apply-result.v1";
|
|
27
30
|
const ENTITY_TYPES = new Set([
|
|
@@ -2119,6 +2122,9 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
|
|
|
2119
2122
|
}
|
|
2120
2123
|
const results = [];
|
|
2121
2124
|
let failed = false;
|
|
2125
|
+
// Failures that changed nothing (a precondition refused the action).
|
|
2126
|
+
let refusals = 0;
|
|
2127
|
+
let failures = 0;
|
|
2122
2128
|
for (const action of actions) {
|
|
2123
2129
|
if (failed) {
|
|
2124
2130
|
results.push({
|
|
@@ -2139,6 +2145,9 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
|
|
|
2139
2145
|
}
|
|
2140
2146
|
catch (error) {
|
|
2141
2147
|
failed = true;
|
|
2148
|
+
failures += 1;
|
|
2149
|
+
if (error instanceof MigrationActionRefusedError)
|
|
2150
|
+
refusals += 1;
|
|
2142
2151
|
results.push({
|
|
2143
2152
|
actionId: action.id,
|
|
2144
2153
|
outcome: "failed",
|
|
@@ -2188,10 +2197,15 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
|
|
|
2188
2197
|
});
|
|
2189
2198
|
}
|
|
2190
2199
|
}
|
|
2200
|
+
// refused: nothing was applied and every failure was a refusal, so the
|
|
2201
|
+
// workspace is as it was; reconciliation_required: an action failed
|
|
2202
|
+
// without being refused, so its effect must be inspected.
|
|
2191
2203
|
const outcome = failed
|
|
2192
2204
|
? results.some((result) => result.outcome === "applied")
|
|
2193
2205
|
? "partially_applied"
|
|
2194
|
-
:
|
|
2206
|
+
: failures > 0 && refusals === failures
|
|
2207
|
+
? "refused"
|
|
2208
|
+
: "reconciliation_required"
|
|
2195
2209
|
: "applied";
|
|
2196
2210
|
const kbState = finalStatus.branchAttachment?.migrationRequired
|
|
2197
2211
|
? "legacy_compat"
|
|
@@ -2235,7 +2249,7 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
|
|
|
2235
2249
|
closeout: {
|
|
2236
2250
|
taskOutcome: outcome === "applied"
|
|
2237
2251
|
? "complete"
|
|
2238
|
-
: outcome === "reconciliation_required"
|
|
2252
|
+
: outcome === "reconciliation_required" || outcome === "refused"
|
|
2239
2253
|
? "blocked"
|
|
2240
2254
|
: "interim",
|
|
2241
2255
|
kbState,
|
|
@@ -2248,7 +2262,11 @@ async function applyMigrationPlan(args, context, onCommitted = () => undefined)
|
|
|
2248
2262
|
content: [
|
|
2249
2263
|
{
|
|
2250
2264
|
type: "text",
|
|
2251
|
-
text:
|
|
2265
|
+
text: outcome === "applied"
|
|
2266
|
+
? `Applied migration plan ${args.plan.planHash.slice(0, 12)}.`
|
|
2267
|
+
: outcome === "refused"
|
|
2268
|
+
? `Refused migration plan ${args.plan.planHash.slice(0, 12)}; nothing was changed.`
|
|
2269
|
+
: `Stopped after migration plan ${args.plan.planHash.slice(0, 12)}.`,
|
|
2252
2270
|
},
|
|
2253
2271
|
],
|
|
2254
2272
|
structuredContent: payload,
|
|
@@ -2278,6 +2296,15 @@ async function applyMigrationAction(action, context) {
|
|
|
2278
2296
|
case "missing_exact_branch_store":
|
|
2279
2297
|
await branchEnsureCommand({ workspaceRoot: context.workspaceRoot });
|
|
2280
2298
|
return;
|
|
2299
|
+
// implements REQ-cli-status-pre-first-sync
|
|
2300
|
+
case BRANCH_STORE_NOT_COMPILED: {
|
|
2301
|
+
const result = await syncCommand({
|
|
2302
|
+
workspaceRoot: context.workspaceRoot,
|
|
2303
|
+
});
|
|
2304
|
+
if (!result.success)
|
|
2305
|
+
throw new Error("Compiling the branch store (kibi sync) did not complete successfully.");
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2281
2308
|
case "damaged_exact_branch_store":
|
|
2282
2309
|
await branchRecoverCommand({
|
|
2283
2310
|
apply: true,
|
|
@@ -2307,12 +2334,16 @@ async function applyMigrationAction(action, context) {
|
|
|
2307
2334
|
case PREDICATE_SCHEMA_ALIGNMENT_CODE:
|
|
2308
2335
|
await applyPredicateSchemaAlignment(action, context);
|
|
2309
2336
|
return;
|
|
2337
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
2338
|
+
case PROOF_INTEGRATION_CONFIGURE:
|
|
2339
|
+
applyProofIntegrationAction(action, context.workspaceRoot);
|
|
2340
|
+
return;
|
|
2310
2341
|
default:
|
|
2311
2342
|
if (SCHEMA6_AUTOMATIC_CODES.has(action.code)) {
|
|
2312
2343
|
await applySchema6MigrationAction(action, context);
|
|
2313
2344
|
return;
|
|
2314
2345
|
}
|
|
2315
|
-
throw new
|
|
2346
|
+
throw new MigrationActionRefusedError(`Migration action '${action.code}' has no automatic executor.`);
|
|
2316
2347
|
}
|
|
2317
2348
|
}
|
|
2318
2349
|
/**
|
|
@@ -2323,10 +2354,10 @@ async function applyMigrationAction(action, context) {
|
|
|
2323
2354
|
async function applyPredicateSchemaAlignment(action, context) {
|
|
2324
2355
|
const invocation = action.invocation;
|
|
2325
2356
|
if (invocation.kind !== "operation" || invocation.name !== "kb_upsert")
|
|
2326
|
-
throw new
|
|
2357
|
+
throw new MigrationActionRefusedError("Predicate schema alignment requires its planned kb_upsert invocation.");
|
|
2327
2358
|
const input = asUpsert(invocation.input);
|
|
2328
2359
|
if (input.type !== "fact")
|
|
2329
|
-
throw new
|
|
2360
|
+
throw new MigrationActionRefusedError("Predicate schema alignment only rewrites fact entities.");
|
|
2330
2361
|
const prolog = context.prolog ?? (await context.ensureProlog?.());
|
|
2331
2362
|
if (!prolog)
|
|
2332
2363
|
throw new Error("Predicate schema alignment requires a Prolog runtime.");
|
|
@@ -2348,6 +2379,6 @@ async function applyPredicateSchemaAlignment(action, context) {
|
|
|
2348
2379
|
typeof rewrite.index === "number" &&
|
|
2349
2380
|
currentArgs[rewrite.index] === rewrite.from);
|
|
2350
2381
|
if (!unchanged)
|
|
2351
|
-
throw new
|
|
2382
|
+
throw new MigrationActionRefusedError(`Predicate fact ${input.id} changed since planning; rerun kibi check and approve the new plan.`);
|
|
2352
2383
|
await executeUpsert(input, operationContext);
|
|
2353
2384
|
}
|