kibi-cli 2.12.0 → 2.14.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/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +76 -1
- package/dist/engine.d.ts +27 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +85 -28
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +16 -4
- package/dist/operations/bootstrap/candidate-helpers.d.ts +5 -0
- package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidate-helpers.js +8 -0
- package/dist/operations/bootstrap/candidates.d.ts +12 -1
- package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidates.js +41 -7
- package/dist/operations/bootstrap/discovery-evidence.d.ts.map +1 -1
- package/dist/operations/bootstrap/discovery-evidence.js +8 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +17 -5
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +17 -5
- package/dist/operations/bootstrap/types.d.ts +6 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.d.ts +7 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +66 -21
- package/dist/operations/modeling/predicate-binding-hints.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-binding-hints.js +60 -8
- package/dist/operations/modeling/predicate-bindings.d.ts +29 -0
- package/dist/operations/modeling/predicate-bindings.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-bindings.js +79 -1
- package/dist/operations/modeling/predicate-types.d.ts +12 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-utils.js +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +40 -12
- package/dist/package-versions.d.ts +10 -0
- package/dist/package-versions.d.ts.map +1 -0
- package/dist/package-versions.js +68 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +4 -19
- package/dist/provenance-stub.d.ts +15 -0
- package/dist/provenance-stub.d.ts.map +1 -0
- package/dist/provenance-stub.js +30 -0
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-usage/SKILL.md +14 -5
- package/dist/search-answer.d.ts.map +1 -1
- package/dist/search-answer.js +7 -0
- package/dist/search-ranking.d.ts.map +1 -1
- package/dist/search-ranking.js +9 -1
- package/package.json +2 -2
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-usage/SKILL.md +14 -5
|
@@ -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":"AAiFA,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,CAoG/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
|
@@ -21,9 +21,11 @@ import { createRequire } from "node:module";
|
|
|
21
21
|
import * as path from "node:path";
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
import { bootstrapKibiEnvironment, secretSourceFromBootstrap, } from "../env/bootstrap.js";
|
|
24
|
+
import { kibiPackageVersions } from "../package-versions.js";
|
|
24
25
|
import { describeConfiguredCapabilityPlugins, readProjectKibiConfig, } from "../plugins/project-config.js";
|
|
25
26
|
import { SwiplResolutionError, inspectSwiplBundle, probeRequiredLibraries, resolveSwipl, } from "../prolog/swipl-resolver.js";
|
|
26
27
|
import { buildMigrationPlan, migrationAction, } from "../public/operations/migration-plan.js";
|
|
28
|
+
import { resolveReadBranchAttachment } from "../utils/branch-resolver.js";
|
|
27
29
|
import { resolveGitRepository, } from "../utils/git-repository-context.js";
|
|
28
30
|
import { readKbManifestStatus } from "../utils/kb-manifest.js";
|
|
29
31
|
import { hasManagedHooks, outdatedManagedHooks } from "./init-helpers.js";
|
|
@@ -86,6 +88,10 @@ export async function doctorCommand(options = {}) {
|
|
|
86
88
|
name: "Capability plugins",
|
|
87
89
|
check: checkCapabilityPlugins,
|
|
88
90
|
},
|
|
91
|
+
{
|
|
92
|
+
name: "Engine daemon",
|
|
93
|
+
check: checkEngineDaemon,
|
|
94
|
+
},
|
|
89
95
|
];
|
|
90
96
|
const results = [];
|
|
91
97
|
for (const { name, check } of checks) {
|
|
@@ -227,7 +233,7 @@ async function runtimeProvenance() {
|
|
|
227
233
|
mcpCliRange: mcp.dependencies?.["kibi-cli"] ?? "unknown",
|
|
228
234
|
executeApplyPlanExported,
|
|
229
235
|
entrypoint: process.argv[1] ?? "unknown",
|
|
230
|
-
packageVersions:
|
|
236
|
+
packageVersions: kibiPackageVersions(),
|
|
231
237
|
locations: {
|
|
232
238
|
cli: packagePath,
|
|
233
239
|
cliEntrypoint: process.argv[1] ?? "unknown",
|
|
@@ -494,6 +500,75 @@ function formatJevStaticConfigParts(env = process.env) {
|
|
|
494
500
|
}
|
|
495
501
|
return [`jev.model=${model}`, `jev.timeoutMs=${String(timeoutMs)}`];
|
|
496
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* The package versions and SWI-Prolog of the engine daemon serving this
|
|
505
|
+
* workspace and branch, read through its handshake without starting one. A
|
|
506
|
+
* daemon with other versions is replaced by the next Kibi command, so it is
|
|
507
|
+
* reported, not failed.
|
|
508
|
+
*/
|
|
509
|
+
// implements REQ-engine-daemon-package-versions
|
|
510
|
+
async function checkEngineDaemon() {
|
|
511
|
+
const workspaceRoot = path.resolve(process.env.KIBI_WORKSPACE ??
|
|
512
|
+
process.env.KIBI_PROJECT_ROOT ??
|
|
513
|
+
process.env.KIBI_ROOT ??
|
|
514
|
+
process.cwd());
|
|
515
|
+
const expected = kibiPackageVersions();
|
|
516
|
+
const attachment = resolveReadBranchAttachment(workspaceRoot);
|
|
517
|
+
if ("error" in attachment) {
|
|
518
|
+
return {
|
|
519
|
+
passed: true,
|
|
520
|
+
message: "Not checked: no branch to address the engine daemon",
|
|
521
|
+
details: { running: false, expectedPackageVersions: expected },
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
const { EngineClient } = await import("../engine.js");
|
|
525
|
+
const client = new EngineClient({
|
|
526
|
+
workspaceRoot,
|
|
527
|
+
branch: attachment.kbBranch,
|
|
528
|
+
});
|
|
529
|
+
let daemon = null;
|
|
530
|
+
try {
|
|
531
|
+
daemon = await client.inspectLiveDaemon();
|
|
532
|
+
}
|
|
533
|
+
catch (error) {
|
|
534
|
+
return {
|
|
535
|
+
passed: true,
|
|
536
|
+
message: `Not reachable: ${error instanceof Error ? error.message : String(error)}`,
|
|
537
|
+
details: { running: false, expectedPackageVersions: expected },
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
finally {
|
|
541
|
+
await client.terminate();
|
|
542
|
+
}
|
|
543
|
+
if (daemon === null) {
|
|
544
|
+
return {
|
|
545
|
+
passed: true,
|
|
546
|
+
message: "Not running",
|
|
547
|
+
details: { running: false, expectedPackageVersions: expected },
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
const details = {
|
|
551
|
+
running: true,
|
|
552
|
+
pid: client.getPid(),
|
|
553
|
+
branch: attachment.kbBranch,
|
|
554
|
+
packageVersions: daemon.packageVersions,
|
|
555
|
+
prologIdentity: daemon.prologIdentity,
|
|
556
|
+
expectedPackageVersions: expected,
|
|
557
|
+
};
|
|
558
|
+
if (daemon.packageVersions === expected) {
|
|
559
|
+
return {
|
|
560
|
+
passed: true,
|
|
561
|
+
message: `Running ${daemon.packageVersions}`,
|
|
562
|
+
details,
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
return {
|
|
566
|
+
passed: true,
|
|
567
|
+
message: `Running ${daemon.packageVersions ?? "a daemon that reports no package versions"}, not this CLI's ${expected}; the next Kibi command replaces it`,
|
|
568
|
+
remediation: "Run: kibi engine stop",
|
|
569
|
+
details,
|
|
570
|
+
};
|
|
571
|
+
}
|
|
497
572
|
function checkKbDirectory() {
|
|
498
573
|
const kbDir = path.join(process.cwd(), ".kb");
|
|
499
574
|
if (!existsSync(kbDir)) {
|
package/dist/engine.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ export { EngineQueryLimitError, QUERY_LIMIT_EXCEEDED_CODE, queryLimitExceededOf,
|
|
|
8
8
|
export type { EngineLimitExceeded, EngineQueryLimits, } from "./engine-limits.js";
|
|
9
9
|
export declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
10
10
|
export declare const ENGINE_IDLE_TIMEOUT_MS: number;
|
|
11
|
+
/**
|
|
12
|
+
* Package versions this engine build carries (KIBI_PACKAGE_VERSIONS when
|
|
13
|
+
* set). The client sends them on every request and the daemon reports its
|
|
14
|
+
* own in the handshake; a daemon with other versions is replaced, never
|
|
15
|
+
* reused.
|
|
16
|
+
*/
|
|
17
|
+
export declare function enginePackageVersions(): string;
|
|
18
|
+
/** @deprecated The versions at module load; call enginePackageVersions(). */
|
|
11
19
|
export declare const ENGINE_PACKAGE_VERSIONS: string;
|
|
12
20
|
/**
|
|
13
21
|
* Identity of the SWI-Prolog this process would launch (`<bin>@<version>`).
|
|
@@ -43,6 +51,11 @@ export type EnginePublicationLease = Readonly<{
|
|
|
43
51
|
readonly release: () => void;
|
|
44
52
|
}>;
|
|
45
53
|
export declare function acquireEnginePublicationLease(workspaceRoot: string, branch: string): EnginePublicationLease;
|
|
54
|
+
/** What a live daemon reports in its handshake. */
|
|
55
|
+
export type EngineDaemonIdentity = Readonly<{
|
|
56
|
+
prologIdentity: string | null;
|
|
57
|
+
packageVersions: string | null;
|
|
58
|
+
}>;
|
|
46
59
|
export type EngineClientOptions = {
|
|
47
60
|
readonly workspaceRoot: string;
|
|
48
61
|
readonly branch: string;
|
|
@@ -99,11 +112,21 @@ export declare class EngineClient {
|
|
|
99
112
|
invalidateCache(): void;
|
|
100
113
|
isRunning(): boolean;
|
|
101
114
|
private readAttachedIdentity;
|
|
102
|
-
|
|
115
|
+
/** The live daemon's handshake: its SWI-Prolog and package versions. */
|
|
116
|
+
private daemonHandshake;
|
|
117
|
+
/**
|
|
118
|
+
* The identity a live daemon reports, without starting one; null when no
|
|
119
|
+
* daemon serves this workspace and branch. The connection is closed again.
|
|
120
|
+
*/
|
|
121
|
+
inspectLiveDaemon(): Promise<EngineDaemonIdentity | null>;
|
|
122
|
+
/** Why the live daemon may not serve this client, or null when it may. */
|
|
123
|
+
private daemonRuntimeMismatch;
|
|
103
124
|
/**
|
|
104
|
-
* A live daemon keeps the SWI-Prolog
|
|
105
|
-
* resolves a different executable or
|
|
106
|
-
* bundled package was upgraded, a
|
|
125
|
+
* A live daemon keeps the SWI-Prolog and the package versions it was
|
|
126
|
+
* started with. When this client resolves a different executable or
|
|
127
|
+
* version (KIBI_SWIPL changed, the bundled package was upgraded, a
|
|
128
|
+
* pre-handshake daemon) or carries other package versions (a daemon left
|
|
129
|
+
* by another install, for example one a git hook started), the daemon is
|
|
107
130
|
* stopped and replaced; it is never reused.
|
|
108
131
|
*/
|
|
109
132
|
private reconcileRuntime;
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAgCA,OAAO,EAEL,KAAK,iBAAiB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAgCA,OAAO,EAEL,KAAK,iBAAiB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAK7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAQ9C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAU5B,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,sBAAsB,QAAiB,CAAC;AAErD;;;;;GAKG;AAEH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,QAAwB,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_hooks";
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { BOUNDED_READ_HELPER_DEFINITION, assertWithinQueryLimits, boundedReadGoal, normalizeQueryLimits, queryLimitsFromEnv, settleBoundedRead, } from "./engine-limits.js";
|
|
17
|
+
import { kibiPackageVersions } from "./package-versions.js";
|
|
17
18
|
import { writePerformanceTraceEvent } from "./performance-trace.js";
|
|
18
19
|
import { PrologProcess, resolveKbPlPath } from "./prolog.js";
|
|
19
20
|
import { parseEntityFromList, parseListOfLists } from "./prolog/codec.js";
|
|
@@ -33,7 +34,18 @@ const READ_LIMITED_METHODS = new Set([
|
|
|
33
34
|
]);
|
|
34
35
|
export const ENGINE_PROTOCOL_VERSION = 1;
|
|
35
36
|
export const ENGINE_IDLE_TIMEOUT_MS = 10 * 60 * 1000;
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Package versions this engine build carries (KIBI_PACKAGE_VERSIONS when
|
|
39
|
+
* set). The client sends them on every request and the daemon reports its
|
|
40
|
+
* own in the handshake; a daemon with other versions is replaced, never
|
|
41
|
+
* reused.
|
|
42
|
+
*/
|
|
43
|
+
// implements REQ-engine-daemon-package-versions
|
|
44
|
+
export function enginePackageVersions() {
|
|
45
|
+
return kibiPackageVersions();
|
|
46
|
+
}
|
|
47
|
+
/** @deprecated The versions at module load; call enginePackageVersions(). */
|
|
48
|
+
export const ENGINE_PACKAGE_VERSIONS = kibiPackageVersions();
|
|
37
49
|
/**
|
|
38
50
|
* Identity of the SWI-Prolog this process would launch (`<bin>@<version>`).
|
|
39
51
|
* The daemon and every client compare it; a daemon running a different
|
|
@@ -864,6 +876,10 @@ export class EngineClient {
|
|
|
864
876
|
env: {
|
|
865
877
|
...process.env,
|
|
866
878
|
KIBI_ENGINE_PROTOCOL: String(ENGINE_PROTOCOL_VERSION),
|
|
879
|
+
// The daemon reports the versions of the client that
|
|
880
|
+
// started it, so this client and its own daemon agree even
|
|
881
|
+
// when the daemon entry is resolved from a bundled host.
|
|
882
|
+
KIBI_PACKAGE_VERSIONS: enginePackageVersions(),
|
|
867
883
|
},
|
|
868
884
|
});
|
|
869
885
|
await new Promise((resolve, reject) => {
|
|
@@ -978,7 +994,7 @@ export class EngineClient {
|
|
|
978
994
|
...limits,
|
|
979
995
|
id,
|
|
980
996
|
protocolVersion: ENGINE_PROTOCOL_VERSION,
|
|
981
|
-
packageVersions:
|
|
997
|
+
packageVersions: enginePackageVersions(),
|
|
982
998
|
prologIdentity: engineSwiplIdentity(),
|
|
983
999
|
workspaceRoot: this.workspaceRoot,
|
|
984
1000
|
branch: this.branch,
|
|
@@ -1092,7 +1108,7 @@ export class EngineClient {
|
|
|
1092
1108
|
method: "cancel",
|
|
1093
1109
|
cancelOf: requestId,
|
|
1094
1110
|
protocolVersion: ENGINE_PROTOCOL_VERSION,
|
|
1095
|
-
packageVersions:
|
|
1111
|
+
packageVersions: enginePackageVersions(),
|
|
1096
1112
|
prologIdentity: engineSwiplIdentity(),
|
|
1097
1113
|
workspaceRoot: this.workspaceRoot,
|
|
1098
1114
|
branch: this.branch,
|
|
@@ -1136,30 +1152,68 @@ export class EngineClient {
|
|
|
1136
1152
|
return null;
|
|
1137
1153
|
return parseEngineAttachmentIdentity(status.bindings.JsonString);
|
|
1138
1154
|
}
|
|
1139
|
-
|
|
1155
|
+
/** The live daemon's handshake: its SWI-Prolog and package versions. */
|
|
1156
|
+
async daemonHandshake() {
|
|
1140
1157
|
const reply = await this.request({
|
|
1141
1158
|
method: "handshake",
|
|
1142
1159
|
});
|
|
1143
|
-
return
|
|
1160
|
+
return {
|
|
1161
|
+
prologIdentity: typeof reply?.prologIdentity === "string" ? reply.prologIdentity : null,
|
|
1162
|
+
packageVersions: typeof reply?.packageVersions === "string"
|
|
1163
|
+
? reply.packageVersions
|
|
1164
|
+
: null,
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* The identity a live daemon reports, without starting one; null when no
|
|
1169
|
+
* daemon serves this workspace and branch. The connection is closed again.
|
|
1170
|
+
*/
|
|
1171
|
+
// implements REQ-engine-daemon-package-versions
|
|
1172
|
+
async inspectLiveDaemon() {
|
|
1173
|
+
const wasConnected = this.isRunning();
|
|
1174
|
+
if (!wasConnected)
|
|
1175
|
+
await this.connect(false);
|
|
1176
|
+
if (!this.isRunning())
|
|
1177
|
+
return null;
|
|
1178
|
+
try {
|
|
1179
|
+
return await this.daemonHandshake();
|
|
1180
|
+
}
|
|
1181
|
+
finally {
|
|
1182
|
+
if (!wasConnected)
|
|
1183
|
+
await this.terminate();
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
/** Why the live daemon may not serve this client, or null when it may. */
|
|
1187
|
+
async daemonRuntimeMismatch() {
|
|
1188
|
+
const daemon = await this.daemonHandshake();
|
|
1189
|
+
const packageVersions = enginePackageVersions();
|
|
1190
|
+
if (daemon.packageVersions !== packageVersions)
|
|
1191
|
+
return `Kibi engine is running other package versions (${daemon.packageVersions ?? "not reported"}) than this client (${packageVersions})`;
|
|
1192
|
+
if (daemon.prologIdentity !== engineSwiplIdentity())
|
|
1193
|
+
return `Kibi engine is running a different SWI-Prolog than this client resolved (${engineSwiplIdentity()})`;
|
|
1194
|
+
return null;
|
|
1144
1195
|
}
|
|
1145
1196
|
/**
|
|
1146
|
-
* A live daemon keeps the SWI-Prolog
|
|
1147
|
-
* resolves a different executable or
|
|
1148
|
-
* bundled package was upgraded, a
|
|
1197
|
+
* A live daemon keeps the SWI-Prolog and the package versions it was
|
|
1198
|
+
* started with. When this client resolves a different executable or
|
|
1199
|
+
* version (KIBI_SWIPL changed, the bundled package was upgraded, a
|
|
1200
|
+
* pre-handshake daemon) or carries other package versions (a daemon left
|
|
1201
|
+
* by another install, for example one a git hook started), the daemon is
|
|
1149
1202
|
* stopped and replaced; it is never reused.
|
|
1150
1203
|
*/
|
|
1151
|
-
// implements REQ-prolog-daemon-runtime-identity
|
|
1204
|
+
// implements REQ-prolog-daemon-runtime-identity, REQ-engine-daemon-package-versions
|
|
1152
1205
|
async reconcileRuntime() {
|
|
1153
1206
|
if (this.replacingStaleDaemon || this.socket === null)
|
|
1154
1207
|
return;
|
|
1155
|
-
if (await this.
|
|
1208
|
+
if ((await this.daemonRuntimeMismatch()) === null)
|
|
1156
1209
|
return;
|
|
1157
1210
|
this.replacingStaleDaemon = true;
|
|
1158
1211
|
try {
|
|
1159
1212
|
await this.shutdownConnectedDaemon();
|
|
1160
1213
|
await this.connect(true);
|
|
1161
|
-
|
|
1162
|
-
|
|
1214
|
+
const mismatch = await this.daemonRuntimeMismatch();
|
|
1215
|
+
if (mismatch !== null) {
|
|
1216
|
+
throw new Error(`${mismatch} after replacing it; run 'kibi engine stop' and retry`);
|
|
1163
1217
|
}
|
|
1164
1218
|
}
|
|
1165
1219
|
finally {
|
|
@@ -1577,6 +1631,7 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
1577
1631
|
await session.boot();
|
|
1578
1632
|
let attachedIdentity = readEngineAttachmentIdentity(branchPath);
|
|
1579
1633
|
const serverPrologIdentity = engineSwiplIdentity();
|
|
1634
|
+
const serverPackageVersions = enginePackageVersions();
|
|
1580
1635
|
mkdirSync(path.dirname(options.socketPath), { recursive: true, mode: 0o700 });
|
|
1581
1636
|
if (existsSync(options.socketPath)) {
|
|
1582
1637
|
const isLivePeerSignal = (error) => {
|
|
@@ -1739,23 +1794,22 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
1739
1794
|
if (request.protocolVersion !== ENGINE_PROTOCOL_VERSION) {
|
|
1740
1795
|
throw new Error(`Kibi engine protocol mismatch: client=${request.protocolVersion ?? "missing"}, server=${ENGINE_PROTOCOL_VERSION}`);
|
|
1741
1796
|
}
|
|
1742
|
-
const expectedPackages = process.env.KIBI_PACKAGE_VERSIONS;
|
|
1743
|
-
if (expectedPackages !== undefined &&
|
|
1744
|
-
request.packageVersions !== expectedPackages) {
|
|
1745
|
-
throw new Error(`Kibi engine package-version mismatch: client=${request.packageVersions ?? "missing"}, server=${expectedPackages}`);
|
|
1746
|
-
}
|
|
1747
1797
|
if (canonicalFilesystemPath(request.workspaceRoot ?? "") !==
|
|
1748
1798
|
options.workspaceRoot ||
|
|
1749
1799
|
request.branch !== options.branch) {
|
|
1750
1800
|
throw new Error("Kibi engine workspace identity mismatch");
|
|
1751
1801
|
}
|
|
1752
|
-
// A client
|
|
1753
|
-
//
|
|
1802
|
+
// A client from another install (other package versions) or one that
|
|
1803
|
+
// resolved a different Prolog must not be served by this daemon.
|
|
1804
|
+
// Handshake reports both identities and stop must still work so the
|
|
1754
1805
|
// client can replace the daemon.
|
|
1755
|
-
if (request.method !== "handshake" &&
|
|
1756
|
-
request.
|
|
1757
|
-
|
|
1758
|
-
|
|
1806
|
+
if (request.method !== "handshake" && request.method !== "stop") {
|
|
1807
|
+
if (request.packageVersions !== serverPackageVersions) {
|
|
1808
|
+
throw new Error(`Kibi engine package-version mismatch: client=${request.packageVersions ?? "missing"}, server=${serverPackageVersions}`);
|
|
1809
|
+
}
|
|
1810
|
+
if (request.prologIdentity !== serverPrologIdentity) {
|
|
1811
|
+
throw new Error(`Kibi engine SWI-Prolog mismatch: client=${request.prologIdentity ?? "missing"}, server=${serverPrologIdentity}`);
|
|
1812
|
+
}
|
|
1759
1813
|
}
|
|
1760
1814
|
if (!isEngineLifecycleRequest(request) && (await session.ensureLive())) {
|
|
1761
1815
|
// A recycled session re-read the store; nothing cached from the lost
|
|
@@ -2037,7 +2091,10 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
2037
2091
|
throw new Error("export.targetDirectory is required");
|
|
2038
2092
|
return prolog.query(`kb_storage_export('${quoteProlog(request.targetDirectory)}')`);
|
|
2039
2093
|
case "handshake":
|
|
2040
|
-
return {
|
|
2094
|
+
return {
|
|
2095
|
+
prologIdentity: serverPrologIdentity,
|
|
2096
|
+
packageVersions: serverPackageVersions,
|
|
2097
|
+
};
|
|
2041
2098
|
case "stop":
|
|
2042
2099
|
setImmediate(() => void shutdown());
|
|
2043
2100
|
return { stopped: true };
|
|
@@ -2134,7 +2191,7 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
2134
2191
|
id: request.id,
|
|
2135
2192
|
ok: false,
|
|
2136
2193
|
error: "Kibi engine is shutting down; request was not executed",
|
|
2137
|
-
serverPackageVersions
|
|
2194
|
+
serverPackageVersions,
|
|
2138
2195
|
});
|
|
2139
2196
|
return;
|
|
2140
2197
|
}
|
|
@@ -2149,7 +2206,7 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
2149
2206
|
id: request.id,
|
|
2150
2207
|
ok: false,
|
|
2151
2208
|
error: "Kibi engine request cancelled",
|
|
2152
|
-
serverPackageVersions
|
|
2209
|
+
serverPackageVersions,
|
|
2153
2210
|
});
|
|
2154
2211
|
return;
|
|
2155
2212
|
}
|
|
@@ -2159,7 +2216,7 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
2159
2216
|
id: request.id,
|
|
2160
2217
|
ok: true,
|
|
2161
2218
|
result,
|
|
2162
|
-
serverPackageVersions
|
|
2219
|
+
serverPackageVersions,
|
|
2163
2220
|
});
|
|
2164
2221
|
}
|
|
2165
2222
|
catch (error) {
|
|
@@ -2167,7 +2224,7 @@ export async function runEngineDaemon(requestedOptions) {
|
|
|
2167
2224
|
id: request.id,
|
|
2168
2225
|
ok: false,
|
|
2169
2226
|
error: error instanceof Error ? error.message : String(error),
|
|
2170
|
-
serverPackageVersions
|
|
2227
|
+
serverPackageVersions,
|
|
2171
2228
|
});
|
|
2172
2229
|
}
|
|
2173
2230
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,s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AS,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAO1E;AA8FD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAGD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CA0C1E"}
|
package/dist/intent-search.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { bodySnippetLine } from "./entity-body-context.js";
|
|
3
3
|
import { escapeAtom, normalizeEntityId, parseTriples } from "./prolog/codec.js";
|
|
4
|
+
import { isProvenanceStub } from "./provenance-stub.js";
|
|
4
5
|
import { listSearchCandidates, loadEntityRows, loadSearchCandidates, } from "./public/operations/discovery-entities.js";
|
|
5
6
|
import { loadMarkdownBody } from "./search-ranking.js";
|
|
6
7
|
const GRAPH_RELATIONSHIPS = [
|
|
@@ -108,6 +109,9 @@ const NON_GOVERNING_STATUSES = new Set([
|
|
|
108
109
|
"archived",
|
|
109
110
|
]);
|
|
110
111
|
const NON_GOVERNING_FACTOR = 0.5;
|
|
112
|
+
// A bootstrap provenance stub states no claim: it is demoted and, whatever
|
|
113
|
+
// its score, sorted after every match that is not a stub.
|
|
114
|
+
const PROVENANCE_STUB_FACTOR = 0.25;
|
|
111
115
|
const AMBIGUOUS_MARGIN = 0.05;
|
|
112
116
|
const MAX_CANDIDATES = 10_000;
|
|
113
117
|
const MAX_GRAPH_SEEDS = 5;
|
|
@@ -280,7 +284,7 @@ function entityTokens(entity, body) {
|
|
|
280
284
|
ENTITY_TOKENS.set(entity, computed);
|
|
281
285
|
return computed;
|
|
282
286
|
}
|
|
283
|
-
function scoreEntity(entity, queryTokens, facets, sourceEvidence, graphEvidence, documentFrequency, documentCount, body, superseded = false) {
|
|
287
|
+
function scoreEntity(entity, queryTokens, facets, sourceEvidence, graphEvidence, documentFrequency, documentCount, body, superseded = false, provenanceStub = false) {
|
|
284
288
|
const { title: titleTokens, metadata: metadataTokens, bodyTokens, } = entityTokens(entity, body);
|
|
285
289
|
const allSignalTokens = Array.from(new Set(queryTokens));
|
|
286
290
|
// BM25-style inverse document frequency over title, metadata and body:
|
|
@@ -335,10 +339,14 @@ function scoreEntity(entity, queryTokens, facets, sourceEvidence, graphEvidence,
|
|
|
335
339
|
const score = Math.min(1, lexicalScore * 0.58 +
|
|
336
340
|
facetScore * 0.17 +
|
|
337
341
|
sourceScore * 0.2 +
|
|
338
|
-
graphScore * 0.05) *
|
|
342
|
+
graphScore * 0.05) *
|
|
343
|
+
(nonGoverning ? NON_GOVERNING_FACTOR : 1) *
|
|
344
|
+
(provenanceStub ? PROVENANCE_STUB_FACTOR : 1);
|
|
339
345
|
const reasons = [];
|
|
340
346
|
if (nonGoverning)
|
|
341
347
|
reasons.push(superseded ? "demoted: superseded" : `demoted: ${status}`);
|
|
348
|
+
if (provenanceStub)
|
|
349
|
+
reasons.push("demoted: provenance stub");
|
|
342
350
|
if (lexicalScore > 0)
|
|
343
351
|
reasons.push("intent token match");
|
|
344
352
|
if (matchedFacets.length > 0)
|
|
@@ -380,7 +388,7 @@ async function readBodies(entities, workspaceRoot, cache) {
|
|
|
380
388
|
cache.get(String(entity.source ?? "")) ?? null,
|
|
381
389
|
]));
|
|
382
390
|
}
|
|
383
|
-
// implements REQ-kibi-intent-aware-source-discovery
|
|
391
|
+
// implements REQ-kibi-intent-aware-source-discovery, REQ-bootstrap-provenance-stubs
|
|
384
392
|
export async function rankIntentEntities(entities, options, workspaceRoot, graphEdges = [], bodyCache = new Map()) {
|
|
385
393
|
const queryTokens = tokens(options.query);
|
|
386
394
|
const facets = facetValues(options.semanticFacets);
|
|
@@ -416,7 +424,7 @@ export async function rankIntentEntities(entities, options, workspaceRoot, graph
|
|
|
416
424
|
// already capped; unbounded parallel paths only add noise to receipts.
|
|
417
425
|
const graphEvidence = (graphByEntity.get(entityId) ?? []).slice(0, 8);
|
|
418
426
|
const body = bodies.get(entity) ?? null;
|
|
419
|
-
const scored = scoreEntity(entity, allTokens, facets, sourceEvidence, graphEvidence, documentFrequency, entities.length, body, supersededIds.has(entityId));
|
|
427
|
+
const scored = scoreEntity(entity, allTokens, facets, sourceEvidence, graphEvidence, documentFrequency, entities.length, body, supersededIds.has(entityId), isProvenanceStub(entity));
|
|
420
428
|
if (scored.score < minScore)
|
|
421
429
|
continue;
|
|
422
430
|
const snippet = body === null
|
|
@@ -439,6 +447,10 @@ export async function rankIntentEntities(entities, options, workspaceRoot, graph
|
|
|
439
447
|
});
|
|
440
448
|
}
|
|
441
449
|
ranked.sort((left, right) => {
|
|
450
|
+
const stubOrder = Number(isProvenanceStub(left.entity)) -
|
|
451
|
+
Number(isProvenanceStub(right.entity));
|
|
452
|
+
if (stubOrder !== 0)
|
|
453
|
+
return stubOrder;
|
|
442
454
|
if (right.score !== left.score)
|
|
443
455
|
return right.score - left.score;
|
|
444
456
|
const typeOrder = String(left.entity.type ?? "").localeCompare(String(right.entity.type ?? ""));
|
|
@@ -23,6 +23,11 @@ export declare function withDocumentBody(step: Readonly<Record<string, unknown>>
|
|
|
23
23
|
export declare function bootstrapProvenance(provider: string, location: string, confidence: number): string;
|
|
24
24
|
/** Body for a non-requirement entity: its title, then its provenance. */
|
|
25
25
|
export declare function provenanceBody(title: string, provenance: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Body for a provenance stub: the title, the provenance, and a sentence that
|
|
28
|
+
* says the entry is a stub so a reader never mistakes it for a claim.
|
|
29
|
+
*/
|
|
30
|
+
export declare function provenanceStubBody(title: string, provenance: string): string;
|
|
26
31
|
/**
|
|
27
32
|
* Body for a requirement found in prose: the statement, the provenance as
|
|
28
33
|
* its Context and the quoted statement with its location as its Source.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate-helpers.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/candidate-help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;AAED,yEAAyE;AAEzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;GAGG;AAEH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,CAMR"}
|
|
@@ -83,6 +83,14 @@ export function bootstrapProvenance(provider, location, confidence) {
|
|
|
83
83
|
export function provenanceBody(title, provenance) {
|
|
84
84
|
return `${title.trim()}\n\n${provenance}\n`;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Body for a provenance stub: the title, the provenance, and a sentence that
|
|
88
|
+
* says the entry is a stub so a reader never mistakes it for a claim.
|
|
89
|
+
*/
|
|
90
|
+
// implements REQ-bootstrap-provenance-stubs
|
|
91
|
+
export function provenanceStubBody(title, provenance) {
|
|
92
|
+
return `${title.trim()}\n\n${provenance} This entry is a provenance stub: the provider found the source but no claim about it, so it is tagged bootstrap:provenance-stub, ranked after every other search match and not counted as knowledge by gap or coverage reports.\n`;
|
|
93
|
+
}
|
|
86
94
|
/**
|
|
87
95
|
* Body for a requirement found in prose: the statement, the provenance as
|
|
88
96
|
* its Context and the quoted statement with its location as its Source.
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { type CandidateBuildResult } from "./markdown-candidates.js";
|
|
2
2
|
import type { SubjectKeyRegistry } from "./requirement-claims.js";
|
|
3
|
-
import type { BootstrapEvidence } from "./types.js";
|
|
3
|
+
import type { BootstrapEvidence, Candidate } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The claim a provider states about its source, or undefined when the
|
|
6
|
+
* provider found only that the file exists. A provider candidate without a
|
|
7
|
+
* claim is a provenance stub: its body would be nothing but the provenance
|
|
8
|
+
* template, so it is written as a `meta` fact tagged
|
|
9
|
+
* `bootstrap:provenance-stub` instead of an observation that search, gap and
|
|
10
|
+
* coverage reports would otherwise read as knowledge.
|
|
11
|
+
*/
|
|
12
|
+
export declare function providerClaim(item: BootstrapEvidence): string | undefined;
|
|
13
|
+
/** Whether a planned candidate writes a provenance stub. */
|
|
14
|
+
export declare function isProvenanceStubCandidate(candidate: Candidate): boolean;
|
|
4
15
|
export declare function buildBootstrapCandidates(evidence: readonly BootstrapEvidence[], existingIds: ReadonlySet<string>, minConfidence: number, includeGenericMarkdown: boolean, subjectKeys?: SubjectKeyRegistry): CandidateBuildResult;
|
|
5
16
|
//# sourceMappingURL=candidates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/candidates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/candidates.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EAEV,MAAM,YAAY,CAAC;AA8CpB;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAIzE;AAED,4DAA4D;AAE5D,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAOvE;AAgFD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,sBAAsB,EAAE,OAAO,EAC/B,WAAW,CAAC,EAAE,kBAAkB,GAC/B,oBAAoB,CAiEtB"}
|