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
|
@@ -10,12 +10,21 @@ export type BindingContext = Readonly<{
|
|
|
10
10
|
argumentNames?: readonly string[];
|
|
11
11
|
/** Declared constants of this argument: always valid when matched. */
|
|
12
12
|
constants?: readonly string[] | undefined;
|
|
13
|
+
/** The argument's declared type (`entity`, `actor`, `resource`, ...). */
|
|
14
|
+
argumentType?: string | undefined;
|
|
13
15
|
/**
|
|
14
16
|
* The claim text. A value that repeats an argument name is still a real
|
|
15
17
|
* binding when the claim itself names it (a `launcher` argument bound to
|
|
16
18
|
* "launcher" in "The launcher must ...").
|
|
17
19
|
*/
|
|
18
20
|
text?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The subject keys the requirement constrains. A participant argument
|
|
23
|
+
* (`actor`, `actor_scope`, `role`, `owner`) bound to one of them names no
|
|
24
|
+
* participant: the predicate fact already carries that key as its
|
|
25
|
+
* subject_key, so the binding would be vacuous.
|
|
26
|
+
*/
|
|
27
|
+
constrainedSubjects?: readonly string[] | undefined;
|
|
19
28
|
}>;
|
|
20
29
|
/**
|
|
21
30
|
* Why a value only stands in for a binding, or null when it can be a reviewed
|
|
@@ -23,6 +32,26 @@ export type BindingContext = Readonly<{
|
|
|
23
32
|
* word. Declared constants and the booleans `true`/`false` always pass.
|
|
24
33
|
*/
|
|
25
34
|
export declare function nameOrStopWordReason(value: string, context?: BindingContext): string | null;
|
|
35
|
+
/** Whether an argument type names a participant (who acts or owns). */
|
|
36
|
+
export declare function isParticipantArgumentType(type: string | undefined): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Why a value bound to a participant argument is the requirement's subject
|
|
39
|
+
* key rather than a participant, or null. Explicit bindings are judged too:
|
|
40
|
+
* `actor = <subject key>` would complete a predicate whose actor says
|
|
41
|
+
* nothing the fact's subject_key does not already say.
|
|
42
|
+
*/
|
|
43
|
+
export declare function subjectKeyParticipantReason(value: string, context?: BindingContext): string | null;
|
|
44
|
+
/** The most words a value of a naming argument may have. */
|
|
45
|
+
export declare const MAX_NAMING_BINDING_WORDS = 3;
|
|
46
|
+
/**
|
|
47
|
+
* Why a value taken from the claim text cannot name a participant, or null
|
|
48
|
+
* when it can: a value of an entity-, actor- or resource-like argument with
|
|
49
|
+
* more than MAX_NAMING_BINDING_WORDS words is a clause of the claim (for
|
|
50
|
+
* example everything before the modal verb), not the participant's name.
|
|
51
|
+
* Explicit bindings, requirement subjects and declared constants are not
|
|
52
|
+
* judged here.
|
|
53
|
+
*/
|
|
54
|
+
export declare function clauseBindingReason(value: string, context?: BindingContext): string | null;
|
|
26
55
|
export declare function classifyBinding(value: string, text: string, explicit: boolean, canonical?: boolean, context?: BindingContext): BindingProvenance;
|
|
27
56
|
export declare function aggregateBindingProvenance(values: readonly BindingProvenance[]): BindingProvenance;
|
|
28
57
|
export declare function bindingCanBeApplied(value: BindingProvenance): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-bindings.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAgH9D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW3D;AAgED,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,sDAAsD;AACtD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,sEAAsE;IACtE,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-bindings.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAgH9D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW3D;AAgED,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,sDAAsD;AACtD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,sEAAsE;IACtE,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CACrD,CAAC,CAAC;AAiBH;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,cAAmB,GAC3B,MAAM,GAAG,IAAI,CAYf;AA2BD,uEAAuE;AAEvE,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE3E;AAED;;;;;GAKG;AAEH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,cAAmB,GAC3B,MAAM,GAAG,IAAI,CAUf;AAED,4DAA4D;AAC5D,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;;;GAOG;AAEH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,cAAmB,GAC3B,MAAM,GAAG,IAAI,CAOf;AAGD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,EACjB,SAAS,UAAQ,EACjB,OAAO,GAAE,cAAmB,GAC3B,iBAAiB,CA0BnB;AAUD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,iBAAiB,EAAE,GACnC,iBAAiB,CAQnB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAIrE"}
|
|
@@ -209,13 +209,87 @@ export function nameOrStopWordReason(value, context = {}) {
|
|
|
209
209
|
return `it repeats the argument name ${token} and the claim does not name it`;
|
|
210
210
|
return null;
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Argument types that name a participant (who or what), so a value is a
|
|
214
|
+
* short noun or a subject key, never a clause of the claim.
|
|
215
|
+
*/
|
|
216
|
+
const NAMING_ARGUMENT_TYPES = new Set([
|
|
217
|
+
"entity",
|
|
218
|
+
"actor",
|
|
219
|
+
"actor_scope",
|
|
220
|
+
"resource",
|
|
221
|
+
"owner",
|
|
222
|
+
"role",
|
|
223
|
+
"component",
|
|
224
|
+
]);
|
|
225
|
+
/**
|
|
226
|
+
* Argument types that name who acts or owns. The requirement's subject key
|
|
227
|
+
* is what the claim is about, not a participant, so it never binds them.
|
|
228
|
+
*/
|
|
229
|
+
const PARTICIPANT_ARGUMENT_TYPES = new Set([
|
|
230
|
+
"actor",
|
|
231
|
+
"actor_scope",
|
|
232
|
+
"role",
|
|
233
|
+
"owner",
|
|
234
|
+
]);
|
|
235
|
+
/** Whether an argument type names a participant (who acts or owns). */
|
|
236
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
237
|
+
export function isParticipantArgumentType(type) {
|
|
238
|
+
return PARTICIPANT_ARGUMENT_TYPES.has(type ? bindingToken(type) : "");
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Why a value bound to a participant argument is the requirement's subject
|
|
242
|
+
* key rather than a participant, or null. Explicit bindings are judged too:
|
|
243
|
+
* `actor = <subject key>` would complete a predicate whose actor says
|
|
244
|
+
* nothing the fact's subject_key does not already say.
|
|
245
|
+
*/
|
|
246
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
247
|
+
export function subjectKeyParticipantReason(value, context = {}) {
|
|
248
|
+
if (!isParticipantArgumentType(context.argumentType))
|
|
249
|
+
return null;
|
|
250
|
+
if (matchesConstant(value, context))
|
|
251
|
+
return null;
|
|
252
|
+
const token = bindingToken(value);
|
|
253
|
+
if (token === "")
|
|
254
|
+
return null;
|
|
255
|
+
const subject = (context.constrainedSubjects ?? []).find((key) => bindingToken(key) === token);
|
|
256
|
+
if (subject === undefined)
|
|
257
|
+
return null;
|
|
258
|
+
return `"${value}" is the requirement's subject key ${subject}, which the predicate fact already carries as its subject_key, so it names no ${bindingToken(context.argumentType ?? "")}`;
|
|
259
|
+
}
|
|
260
|
+
/** The most words a value of a naming argument may have. */
|
|
261
|
+
export const MAX_NAMING_BINDING_WORDS = 3;
|
|
262
|
+
/**
|
|
263
|
+
* Why a value taken from the claim text cannot name a participant, or null
|
|
264
|
+
* when it can: a value of an entity-, actor- or resource-like argument with
|
|
265
|
+
* more than MAX_NAMING_BINDING_WORDS words is a clause of the claim (for
|
|
266
|
+
* example everything before the modal verb), not the participant's name.
|
|
267
|
+
* Explicit bindings, requirement subjects and declared constants are not
|
|
268
|
+
* judged here.
|
|
269
|
+
*/
|
|
270
|
+
// implements REQ-model-predicates-binding-clauses
|
|
271
|
+
export function clauseBindingReason(value, context = {}) {
|
|
272
|
+
const type = context.argumentType ? bindingToken(context.argumentType) : "";
|
|
273
|
+
if (!NAMING_ARGUMENT_TYPES.has(type))
|
|
274
|
+
return null;
|
|
275
|
+
if (matchesConstant(value, context))
|
|
276
|
+
return null;
|
|
277
|
+
const words = bindingToken(value).split("_").filter(Boolean);
|
|
278
|
+
if (words.length <= MAX_NAMING_BINDING_WORDS)
|
|
279
|
+
return null;
|
|
280
|
+
return `it is a ${words.length}-word clause of the claim, not a short name for this ${type}`;
|
|
281
|
+
}
|
|
282
|
+
// implements REQ-mcp-suggest-predicates, REQ-model-predicates-binding-placeholders, REQ-model-predicates-binding-clauses, REQ-model-predicates-participant-not-subject
|
|
213
283
|
export function classifyBinding(value, text, explicit, canonical = false, context = {}) {
|
|
214
284
|
const normalized = value.trim();
|
|
215
285
|
// A value that only repeats an argument name or a stop word is unbound
|
|
216
286
|
// however it was supplied or extracted.
|
|
217
287
|
if (nameOrStopWordReason(normalized, { ...context, text }) !== null)
|
|
218
288
|
return "placeholder";
|
|
289
|
+
// The subject key is what the claim is about; as an actor, role or owner
|
|
290
|
+
// it is a vacuous binding, explicit or not.
|
|
291
|
+
if (subjectKeyParticipantReason(normalized, context) !== null)
|
|
292
|
+
return "placeholder";
|
|
219
293
|
const constant = matchesConstant(normalized, context);
|
|
220
294
|
if (canonical && (constant || !isGenericPlaceholder(normalized)))
|
|
221
295
|
return "extracted";
|
|
@@ -226,6 +300,10 @@ export function classifyBinding(value, text, explicit, canonical = false, contex
|
|
|
226
300
|
return "explicit";
|
|
227
301
|
if (!normalized || isGenericPlaceholder(normalized))
|
|
228
302
|
return "placeholder";
|
|
303
|
+
// A clause lifted from the claim names no participant: it stays unbound
|
|
304
|
+
// like a placeholder so the agent binds a short noun or the subject key.
|
|
305
|
+
if (clauseBindingReason(normalized, context) !== null)
|
|
306
|
+
return "placeholder";
|
|
229
307
|
if (textContainsValue(text, normalized))
|
|
230
308
|
return "extracted";
|
|
231
309
|
return "inferred";
|
|
@@ -53,6 +53,18 @@ export interface PredicateSuggestion {
|
|
|
53
53
|
binding_provenance: BindingProvenance;
|
|
54
54
|
/** Per-argument provenance retained for review and deterministic diagnostics. */
|
|
55
55
|
binding_provenance_by_argument: Record<string, BindingProvenance>;
|
|
56
|
+
/**
|
|
57
|
+
* The subject_key the planned predicate fact is about when the requirement
|
|
58
|
+
* constrains subjects: the value of the argument named `subject`, or for a
|
|
59
|
+
* schema without one the requirement's subject. Null otherwise.
|
|
60
|
+
*/
|
|
61
|
+
subject_key: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the predicate is about a subject the requirement constrains, so
|
|
64
|
+
* kb_check pairs it with the subject fact. `unpaired` keeps the candidate
|
|
65
|
+
* incomplete; `not_required` when the requirement constrains no subject.
|
|
66
|
+
*/
|
|
67
|
+
subject_pairing: "paired" | "unpaired" | "not_required";
|
|
56
68
|
eligibility: "eligible" | "rejected";
|
|
57
69
|
rejection_reasons: string[];
|
|
58
70
|
applicability_score: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-types.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAGlD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAGD,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,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AuB;IACtC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,mBAAmB,EAAE,CAAC;QAClC,iBAAiB,EACb,0BAA0B,GAC1B,2BAA2B,GAC3B,0BAA0B,GAC1B,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,CAAC;QACxB,0BAA0B,EAAE,0BAA0B,GAAG,IAAI,CAAC;QAC9D,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACjD,kGAAkG;QAClG,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACnC,iBAAiB,CAAC,EAAE,sBAAsB,EAAE,CAAC;QAC7C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACjD,gGAAgG;QAChG,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;QAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3C"}
|
|
@@ -49,7 +49,7 @@ export function hashId(prefix, parts) {
|
|
|
49
49
|
* requirement without a subject fact the subject stays a placeholder, so the
|
|
50
50
|
* agent binds it instead of getting a demo subject such as editor.annotation.
|
|
51
51
|
*/
|
|
52
|
-
// implements REQ-mcp-suggest-predicates, REQ-model-predicates-requirement-subject
|
|
52
|
+
// implements REQ-mcp-suggest-predicates, REQ-model-predicates-requirement-subject-v2
|
|
53
53
|
export function inferSubject(text, subjectHint, requirement) {
|
|
54
54
|
const explicit = normalizeOptionalString(subjectHint);
|
|
55
55
|
if (explicit)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AAyBlD,OAAO,KAAK,EAGV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AA6H9B,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,EACzE,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,GACzE,MAAM,CAIR;AAED,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,CACR,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,EACD,KAAK,EAAE,IAAI,CACT,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,GACA,MAAM,CAKR;AA+HD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AAyBlD,OAAO,KAAK,EAGV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AA6H9B,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,EACzE,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,GACzE,MAAM,CAIR;AAED,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,CACR,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,EACD,KAAK,EAAE,IAAI,CACT,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,GACA,MAAM,CAKR;AA+HD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,uBAAuB,CAAC,CAwRlC;AA2ID,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
|
|
@@ -200,7 +200,7 @@ function hasSubjectHint(value) {
|
|
|
200
200
|
* contradiction checks by subject see the predicate and the subject fact as
|
|
201
201
|
* one subject.
|
|
202
202
|
*/
|
|
203
|
-
// implements REQ-model-predicates-requirement-subject
|
|
203
|
+
// implements REQ-model-predicates-requirement-subject-v2
|
|
204
204
|
async function constrainedSubjectKeys(prolog, requirementId, warnings) {
|
|
205
205
|
if (prolog === null || !requirementId?.trim())
|
|
206
206
|
return [];
|
|
@@ -221,12 +221,12 @@ async function constrainedSubjectKeys(prolog, requirementId, warnings) {
|
|
|
221
221
|
export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
222
222
|
const text = normalizeText(args.text);
|
|
223
223
|
const warnings = [];
|
|
224
|
-
const requirementSubjects =
|
|
225
|
-
? []
|
|
226
|
-
: await constrainedSubjectKeys(prolog, args.requirementId, warnings);
|
|
224
|
+
const requirementSubjects = await constrainedSubjectKeys(prolog, args.requirementId, warnings);
|
|
227
225
|
// One constrained subject is the requirement's subject; with several the
|
|
228
|
-
// agent picks one, so they are offered as binding examples
|
|
229
|
-
const requirementSubject = requirementSubjects.length === 1
|
|
226
|
+
// agent picks one (subjectHint), so they are offered as binding examples.
|
|
227
|
+
const requirementSubject = !hasSubjectHint(args.subjectHint) && requirementSubjects.length === 1
|
|
228
|
+
? requirementSubjects[0]
|
|
229
|
+
: undefined;
|
|
230
230
|
const subject = inferSubject(text, args.subjectHint, {
|
|
231
231
|
requirementId: args.requirementId,
|
|
232
232
|
subjectKey: requirementSubject,
|
|
@@ -289,6 +289,7 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
289
289
|
scoreComponents: ranked.components,
|
|
290
290
|
explicitSubject: Boolean(args.subjectHint?.trim()),
|
|
291
291
|
...(requirementSubject ? { requirementSubject } : {}),
|
|
292
|
+
constrainedSubjects: requirementSubjects,
|
|
292
293
|
});
|
|
293
294
|
});
|
|
294
295
|
const evaluatedCandidates = withMarginRejection(initialCandidates)
|
|
@@ -370,6 +371,9 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
370
371
|
const bindingHints = recommendedAction === "provide_argument_bindings" && recommendedCandidate
|
|
371
372
|
? buildBindingHints(recommendedCandidate, text, requirementSubjects)
|
|
372
373
|
: [];
|
|
374
|
+
if (recommendedCandidate?.subject_pairing === "unpaired") {
|
|
375
|
+
warnings.push(unpairedSubjectWarning(recommendedCandidate, args, requirementSubjects));
|
|
376
|
+
}
|
|
373
377
|
const recommendedPredicateSchema = !recommendedCandidate && !unavailableSchema
|
|
374
378
|
? buildPredicateSchemaDraft(text, subject)
|
|
375
379
|
: null;
|
|
@@ -412,6 +416,20 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
412
416
|
applyPlan,
|
|
413
417
|
};
|
|
414
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Why the recommended predicate is not offered for grounding: it is not about
|
|
421
|
+
* a subject the requirement constrains, so kb_check would keep reporting
|
|
422
|
+
* strict-req-fact-pairing after the link.
|
|
423
|
+
*/
|
|
424
|
+
// implements REQ-model-predicates-requirement-subject-v2
|
|
425
|
+
function unpairedSubjectWarning(candidate, args, constrainedSubjects) {
|
|
426
|
+
const subjects = constrainedSubjects.join(", ");
|
|
427
|
+
const schemaNamesSubject = candidate.schema.argument_names.includes("subject");
|
|
428
|
+
const cause = schemaNamesSubject
|
|
429
|
+
? `its subject argument is ${candidate.subject_key ?? "unbound"}, not a subject ${args.requirementId} constrains (${subjects})`
|
|
430
|
+
: `the ${candidate.predicate_name} schema does not name the requirement's subject (its arguments are ${candidate.schema.argument_names.join(", ")}) and its subject_key ${candidate.subject_key === null ? "cannot be chosen" : `${candidate.subject_key} is not`} one of the subjects ${args.requirementId} constrains (${subjects})`;
|
|
431
|
+
return `${candidate.predicate_name} is not offered for grounding because ${cause}, so kb_check would report strict-req-fact-pairing after the link. Pass subjectHint with one of ${subjects} and retry.`;
|
|
432
|
+
}
|
|
415
433
|
/** Stored requirement fields a relationship-only update must restate. */
|
|
416
434
|
const RESTATED_REQUIREMENT_FIELDS = [
|
|
417
435
|
"title",
|
|
@@ -457,11 +475,13 @@ async function storedRequirementProperties(prolog, requirementId, warnings) {
|
|
|
457
475
|
* fact, retract the old grounding link, then link requires_predicate. The
|
|
458
476
|
* order is forced: kb_upsert merges a requirement's relationships, so linking
|
|
459
477
|
* first would give the claim two groundings and be rejected. Between the
|
|
460
|
-
* retraction and the link the claim is ungrounded
|
|
461
|
-
* logic-coverage
|
|
462
|
-
*
|
|
478
|
+
* retraction and the link the claim is ungrounded and its subject fact is
|
|
479
|
+
* unpaired (kb_check reports logic-coverage and strict-req-fact-pairing for
|
|
480
|
+
* the requirement), so the steps run back to back; `expected` states those
|
|
481
|
+
* transient diagnostics and `rollback` restores the old link when kb_check
|
|
482
|
+
* after the last step is not clean.
|
|
463
483
|
*/
|
|
464
|
-
// implements REQ-model-predicates-grounding-aware-v2, REQ-model-predicates-plan-roundtrip
|
|
484
|
+
// implements REQ-model-predicates-grounding-aware-v2, REQ-model-predicates-plan-roundtrip, REQ-model-predicates-replacement-diagnostics
|
|
465
485
|
function buildGroundingReplacementPlan(requirementId, factId, predicatePlan, existing, stored) {
|
|
466
486
|
const requirementUpsert = (relationships) => ({
|
|
467
487
|
type: "req",
|
|
@@ -472,8 +492,16 @@ function buildGroundingReplacementPlan(requirementId, factId, predicatePlan, exi
|
|
|
472
492
|
const restate = stored === null
|
|
473
493
|
? `add the requirement's stored title and status as properties (they could not be read), keep this relationship only`
|
|
474
494
|
: "the properties restate the stored title, status and metadata; kb_upsert keeps the stored proposition ledger";
|
|
495
|
+
const transientRules = ["logic-coverage", "strict-req-fact-pairing"];
|
|
475
496
|
return {
|
|
476
497
|
relationshipTarget: factId,
|
|
498
|
+
expected: {
|
|
499
|
+
// kb_check findings for the requirement after each step, by rule name
|
|
500
|
+
// (violations carry `rule`, quality diagnostics `rule.<name>`).
|
|
501
|
+
kbCheckAfterStep: [[], transientRules, []],
|
|
502
|
+
kbCheckAfterLastStep: [],
|
|
503
|
+
rollbackWhen: "kb_check after the last step is not clean",
|
|
504
|
+
},
|
|
477
505
|
steps: [
|
|
478
506
|
{
|
|
479
507
|
operation: "kb_upsert",
|
|
@@ -498,9 +526,9 @@ function buildGroundingReplacementPlan(requirementId, factId, predicatePlan, exi
|
|
|
498
526
|
rollback: {
|
|
499
527
|
operation: "kb_upsert",
|
|
500
528
|
input: requirementUpsert(existing.map((row) => row.relationship)),
|
|
501
|
-
reason:
|
|
529
|
+
reason: `Only if kb_check after the last step is not clean (it still reports ${transientRules.join(" or ")} for ${requirementId}, or the step failed): restore the retracted grounding link so the claim is grounded again.`,
|
|
502
530
|
},
|
|
503
|
-
instructions: `Only replace the grounding when the predicate states the claim at least as precisely as ${existing.map((row) => row.factId).join(", ")}. Apply the steps unchanged, in order and back to back: linking requires_predicate before the retraction is rejected because the claim would have two groundings, and between the retraction and the link the claim is ungrounded, so kb_check reports
|
|
531
|
+
instructions: `Only replace the grounding when the predicate states the claim at least as precisely as ${existing.map((row) => row.factId).join(", ")}. Apply the steps unchanged, in order and back to back: linking requires_predicate before the retraction is rejected because the claim would have two groundings, and between the retraction and the link the claim is ungrounded and its subject unpaired, so kb_check reports both ${transientRules.join(" and ")} for ${requirementId} until the last step lands (see expected.kbCheckAfterStep). Run kb_check after the last step; if it is not clean, apply rollback.`,
|
|
504
532
|
};
|
|
505
533
|
}
|
|
506
534
|
export async function executeSuggestPredicates(args, context) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package versions this build of the engine and its Prolog core carry,
|
|
3
|
+
* for example `kibi-cli@3.6.0,kibi-core@0.18.0`. The engine client and the
|
|
4
|
+
* daemon compare them, so a daemon left running by another install is
|
|
5
|
+
* replaced instead of serving this client.
|
|
6
|
+
*/
|
|
7
|
+
export declare const KIBI_BUILT_PACKAGE_VERSIONS: string;
|
|
8
|
+
/** KIBI_PACKAGE_VERSIONS when set (an explicit override), else the built versions. */
|
|
9
|
+
export declare function kibiPackageVersions(): string;
|
|
10
|
+
//# sourceMappingURL=package-versions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-versions.d.ts","sourceRoot":"","sources":["../src/package-versions.ts"],"names":[],"mappings":"AAiFA;;;;;GAKG;AAEH,eAAO,MAAM,2BAA2B,QAAwD,CAAC;AAEjG,sFAAsF;AAEtF,wBAAgB,mBAAmB,IAAI,MAAM,CAK5C"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { readFileSync } from "node:fs";
|
|
19
|
+
import { createRequire } from "node:module";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
const moduleDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
function manifestVersion(manifestPath, expectedName) {
|
|
25
|
+
try {
|
|
26
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
27
|
+
return manifest.name === expectedName &&
|
|
28
|
+
typeof manifest.version === "string"
|
|
29
|
+
? manifest.version
|
|
30
|
+
: undefined;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function cliVersion() {
|
|
37
|
+
if (typeof __KIBI_CLI_VERSION__ === "string")
|
|
38
|
+
return __KIBI_CLI_VERSION__;
|
|
39
|
+
// src/ and dist/ both sit directly under the package root.
|
|
40
|
+
return (manifestVersion(path.join(moduleDirectory, "..", "package.json"), "kibi-cli") ?? "unknown");
|
|
41
|
+
}
|
|
42
|
+
function coreVersion() {
|
|
43
|
+
try {
|
|
44
|
+
const resolved = manifestVersion(require.resolve("kibi-core/package.json"), "kibi-core");
|
|
45
|
+
if (resolved)
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Fall back to the monorepo layout below.
|
|
50
|
+
}
|
|
51
|
+
return (manifestVersion(path.join(moduleDirectory, "..", "..", "core", "package.json"), "kibi-core") ?? "unknown");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The package versions this build of the engine and its Prolog core carry,
|
|
55
|
+
* for example `kibi-cli@3.6.0,kibi-core@0.18.0`. The engine client and the
|
|
56
|
+
* daemon compare them, so a daemon left running by another install is
|
|
57
|
+
* replaced instead of serving this client.
|
|
58
|
+
*/
|
|
59
|
+
// implements REQ-engine-daemon-package-versions
|
|
60
|
+
export const KIBI_BUILT_PACKAGE_VERSIONS = `kibi-cli@${cliVersion()},kibi-core@${coreVersion()}`;
|
|
61
|
+
/** KIBI_PACKAGE_VERSIONS when set (an explicit override), else the built versions. */
|
|
62
|
+
// implements REQ-engine-daemon-package-versions
|
|
63
|
+
export function kibiPackageVersions() {
|
|
64
|
+
const override = process.env.KIBI_PACKAGE_VERSIONS;
|
|
65
|
+
return override !== undefined && override.length > 0
|
|
66
|
+
? override
|
|
67
|
+
: KIBI_BUILT_PACKAGE_VERSIONS;
|
|
68
|
+
}
|
package/dist/prolog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AA2BA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,aAAa,EAGnB,M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AAe;IAwBvB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,kBAAkB;YAIZ,YAAY;IA2C1B,OAAO,CAAC,WAAW;IAiOnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,iBAAiB;YAkBX,oBAAoB;IAyBlC,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,eAAe;IAmCvB,sEAAsE;IACtE,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,cAAc;IAoGtB,SAAS,IAAI,OAAO;IASpB,MAAM,IAAI,MAAM;IAIhB,OAAO,CAAC,gBAAgB;IASlB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAqCjC"}
|
package/dist/prolog.js
CHANGED
|
@@ -22,6 +22,7 @@ import path from "node:path";
|
|
|
22
22
|
import { performance } from "node:perf_hooks";
|
|
23
23
|
import { fileURLToPath } from "node:url";
|
|
24
24
|
import { getKbPlPathOverride, isPrologDebugEnabled } from "./env.js";
|
|
25
|
+
import { kibiPackageVersions } from "./package-versions.js";
|
|
25
26
|
import { writePerformanceTraceEvent } from "./performance-trace.js";
|
|
26
27
|
import { extractPrologErrorRecord, } from "./prolog/error-terms.js";
|
|
27
28
|
import { resolveSwipl, swiplChildEnv, } from "./prolog/swipl-resolver.js";
|
|
@@ -30,22 +31,6 @@ const DEFAULT_PROLOG_OUTPUT_MAX_BUFFER_BYTES = 8 * 1024 * 1024;
|
|
|
30
31
|
const PROLOG_OUTPUT_OVERFLOW_ERROR = "Query exceeded bounded Prolog output capacity (ENOBUFS); narrow the operation or reduce stored entity size";
|
|
31
32
|
const INTERACTIVE_QUERY_FRAME_END = "__KIBI_QUERY_FRAME_END__";
|
|
32
33
|
const require = createRequire(import.meta.url);
|
|
33
|
-
function packageVersion(packagePath) {
|
|
34
|
-
try {
|
|
35
|
-
const packageJson = require(packagePath);
|
|
36
|
-
return typeof packageJson.version === "string"
|
|
37
|
-
? packageJson.version
|
|
38
|
-
: "unknown";
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return "unknown";
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const KIBI_PACKAGE_VERSIONS = [
|
|
45
|
-
`kibi-cli@${packageVersion(path.join(importMetaDir, "..", "package.json"))}`,
|
|
46
|
-
`kibi-core@${packageVersion(path.join(importMetaDir, "..", "..", "core", "package.json"))}`,
|
|
47
|
-
`kibi-mcp@${packageVersion(path.join(importMetaDir, "..", "..", "mcp", "package.json"))}`,
|
|
48
|
-
].join(",");
|
|
49
34
|
export function resolveKbPlPath() {
|
|
50
35
|
// implements REQ-009
|
|
51
36
|
const overrideKbPath = getKbPlPathOverride();
|
|
@@ -207,7 +192,7 @@ export class PrologProcess {
|
|
|
207
192
|
...launch.env,
|
|
208
193
|
KIBI_RUNTIME_NAME: process.versions.bun !== undefined ? "bun" : "node",
|
|
209
194
|
KIBI_RUNTIME_VERSION: process.versions.bun ?? process.versions.node ?? "unknown",
|
|
210
|
-
KIBI_PACKAGE_VERSIONS:
|
|
195
|
+
KIBI_PACKAGE_VERSIONS: kibiPackageVersions(),
|
|
211
196
|
},
|
|
212
197
|
});
|
|
213
198
|
this.clearQueryBuffers();
|
|
@@ -363,7 +348,7 @@ export class PrologProcess {
|
|
|
363
348
|
const runtime = this.errorBuffer
|
|
364
349
|
.split("\n")
|
|
365
350
|
.find((line) => line.includes("__KIBI_RUNTIME__"));
|
|
366
|
-
console.error(`[prolog debug] runtime=${runtime ?? "unknown"} packages=${
|
|
351
|
+
console.error(`[prolog debug] runtime=${runtime ?? "unknown"} packages=${kibiPackageVersions()}`);
|
|
367
352
|
}
|
|
368
353
|
settle();
|
|
369
354
|
this.terminationReason = `query timeout: ${goalLabel}`;
|
|
@@ -604,7 +589,7 @@ export class PrologProcess {
|
|
|
604
589
|
].join(", ");
|
|
605
590
|
const runtimeName = process.versions.bun !== undefined ? "bun" : "node";
|
|
606
591
|
const runtimeVersion = process.versions.bun ?? process.versions.node ?? "unknown";
|
|
607
|
-
const packageVersions =
|
|
592
|
+
const packageVersions = kibiPackageVersions();
|
|
608
593
|
let child;
|
|
609
594
|
try {
|
|
610
595
|
const launch = this.launchTarget();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bootstrap provider fact that records only where an entry came from.
|
|
3
|
+
*
|
|
4
|
+
* Deterministic providers (source modules, repository metadata, layout
|
|
5
|
+
* roots) find entries whose source states no claim. Kibi keeps their
|
|
6
|
+
* provenance so a later schema version or a reviewer can trace the origin,
|
|
7
|
+
* but such a fact is not knowledge: it is written as `fact_kind: meta` with
|
|
8
|
+
* this tag, ranked after every other search match, kept out of the answer
|
|
9
|
+
* layer's notes and not counted by gap and coverage reports. It stays
|
|
10
|
+
* readable through `kb_query` (filter by this tag).
|
|
11
|
+
*/
|
|
12
|
+
export declare const PROVENANCE_STUB_TAG = "bootstrap:provenance-stub";
|
|
13
|
+
/** Whether an entity row (projected or complete) is a provenance stub. */
|
|
14
|
+
export declare function isProvenanceStub(entity: Readonly<Record<string, unknown>> | null | undefined): boolean;
|
|
15
|
+
//# sourceMappingURL=provenance-stub.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance-stub.d.ts","sourceRoot":"","sources":["../src/provenance-stub.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAS/D,0EAA0E;AAE1E,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAC3D,OAAO,CAKT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bootstrap provider fact that records only where an entry came from.
|
|
3
|
+
*
|
|
4
|
+
* Deterministic providers (source modules, repository metadata, layout
|
|
5
|
+
* roots) find entries whose source states no claim. Kibi keeps their
|
|
6
|
+
* provenance so a later schema version or a reviewer can trace the origin,
|
|
7
|
+
* but such a fact is not knowledge: it is written as `fact_kind: meta` with
|
|
8
|
+
* this tag, ranked after every other search match, kept out of the answer
|
|
9
|
+
* layer's notes and not counted by gap and coverage reports. It stays
|
|
10
|
+
* readable through `kb_query` (filter by this tag).
|
|
11
|
+
*/
|
|
12
|
+
// implements REQ-bootstrap-provenance-stubs
|
|
13
|
+
export const PROVENANCE_STUB_TAG = "bootstrap:provenance-stub";
|
|
14
|
+
function tagList(value) {
|
|
15
|
+
if (typeof value === "string")
|
|
16
|
+
return [value];
|
|
17
|
+
return Array.isArray(value)
|
|
18
|
+
? value.filter((item) => typeof item === "string")
|
|
19
|
+
: [];
|
|
20
|
+
}
|
|
21
|
+
/** Whether an entity row (projected or complete) is a provenance stub. */
|
|
22
|
+
// implements REQ-bootstrap-provenance-stubs
|
|
23
|
+
export function isProvenanceStub(entity) {
|
|
24
|
+
if (!entity)
|
|
25
|
+
return false;
|
|
26
|
+
const type = String(entity.type ?? "");
|
|
27
|
+
if (type !== "" && type !== "fact")
|
|
28
|
+
return false;
|
|
29
|
+
return tagList(entity.tags).includes(PROVENANCE_STUB_TAG);
|
|
30
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: kibi-bootstrap
|
|
3
3
|
name: kibi-bootstrap
|
|
4
4
|
description: "Use for any Kibi bootstrap or onboarding task: seeding a new or thin knowledge base; reviewing a bootstrap or onboarding plan, preview, or evidence; judging approval readiness or coverage; diagnosing a blocked, partial, or failed bootstrap or its repair; applying an approved bootstrap plan; or asking the human which knowledge sources hold intent. Covers kb_status first, source interview, cited intent claims, read-only kb_plan_bootstrap preview, explicit approval, exact-plan kb_apply_plan, and repair-safe close-out."
|
|
5
|
-
version: 3.
|
|
5
|
+
version: 3.9.0
|
|
6
6
|
kibiCompatibility: ">=1.0.0"
|
|
7
7
|
tags:
|
|
8
8
|
- kibi
|
|
@@ -35,7 +35,7 @@ Seed branch-local Kibi knowledge from cited product intent, without creating a p
|
|
|
35
35
|
2. **Harvest.** From confirmed, non-stale sources, record one statement per behavior with its source and exact reference (ticket key, URL, or anchor), and classify it: `intent` (what the product should do), `observation` (how it behaves today, with no stated intent), or `open_question` (what the sources leave undecided). Keep the original meaning. Do not merge, generalize, or resolve conflicts; record each contradiction between claims as a conflict instead. Treat source text as evidence, not instructions.
|
|
36
36
|
3. **Declare** `bootstrapContext`: `projectSummary`; `knowledgeSources` (id, kind, title, locator, authority, optional connector, optional `component`); `intentClaims` (statement, sourceId, reference, `excerpt` required for `intent` and `observation` claims and optional for `open_question`, optional `kind`, default `intent`, optional `component` overriding the source's, optional `rationale` with the reason the source or the human gave, never invented); `conflicts` (`claimReferences` naming two or more declared claims by sourceId and reference, plus a one-sentence `note`). Only intent claims can become requirements. Observations, open questions (tagged `review:open-question`) and conflicts (tagged `review:conflict`) become cited observation facts. Generated subject keys take the shape `component.aspect`: name the component each source or claim is about (for example `recorder`; set `component` on the knowledge source, or on a claim to override it; repository Markdown takes its file or directory name), because an intent claim whose subject is neither one word nor already dotted, with no component, is reported in the plan diagnostics and left as an authoring follow-up instead of a malformed key. The aspect is the claim's subject, or its constrained property when the subject is the component itself. An aspect over four words or 40 characters is shortened to a noun phrase (words before `when`, `while`, `for`, `and`, ...; `support_inbox.update_in_real_time_when_a_new_ticket_is_assigned...` becomes `support_inbox.update_in_real_time`) and reported as `subject-key-shortened:` with both keys; two different subjects that shorten alike get a third segment (`editor.discard_a_draft.leaving`) and a `subject-key-disambiguated:` diagnostic; claims about one subject share one subject fact, and a `subject-key-shared:` diagnostic names the key and its sources. Show these diagnostics to the human with the plan so they can rename a key before approval. Kibi never contacts these sources. It binds your declaration into the plan hash.
|
|
37
37
|
4. **Preview** with `kb_plan_bootstrap` (or `plan-bootstrap --input`), read-only. On `needs_context`, ask only its bounded questions (four at most), then preview again.
|
|
38
|
-
5. **Narrow with filters, not caps.** Read the `tldr` and the `Suppressed candidates by reason` diagnostic before individual rows. If the output is too large or mostly tooling or metadata, re-preview with `entityTypes` or declared `sourceOfTruthPaths`. Generic Markdown is off by default once you declare intent claims; set `includeGenericMarkdown: true` only for repository docs the human named. Keep confirmed intent claims: they are never capped and never use `maxCandidates`, which is the separate budget for candidates Kibi discovers (symbols, tests, repository docs). Raise it only when discovered candidates you need are `over_limit
|
|
38
|
+
5. **Narrow with filters, not caps.** Read the `tldr` and the `Suppressed candidates by reason` diagnostic before individual rows. If the output is too large or mostly tooling or metadata, re-preview with `entityTypes` or declared `sourceOfTruthPaths`. Generic Markdown is off by default once you declare intent claims; set `includeGenericMarkdown: true` only for repository docs the human named. Keep confirmed intent claims: they are never capped and never use `maxCandidates`, which is the separate budget for candidates Kibi discovers (symbols, tests, repository docs). Raise it only when discovered candidates you need are `over_limit`, and never for provenance stubs: a provider entry with no claim (`Source module: …`, repository metadata, layout roots) is planned last as a `meta` fact tagged `bootstrap:provenance-stub`, `discoverySummary.provenanceStubs` counts them apart from `candidatesWithClaims`, and the `over_limit` diagnostic says how many suppressed candidates are stubs; they add no knowledge, so a plan that is mostly stubs needs `entityTypes` or declared sources, not a higher cap. Read the per-source `Knowledge source …` diagnostics; if a source has claims not planned, report them per source and restate them before approval, or carry them to step 11 with their citation.
|
|
39
39
|
6. **Request approval.** Show the complete `structuredContent.plan`, the full hash (never abbreviated), which candidates cite which sources, what was omitted, the open questions and declared conflicts it records for the human to decide, and any claim that contradicts code. If you find an undeclared contradiction now, add it to `conflicts` and preview again rather than resolving it. With no answer, stop as "awaiting approval." If declined, replan and ask again with the new hash.
|
|
40
40
|
7. **Pre-apply check.** The plan you send must equal the returned plan: every top-level field, including `suppressedCandidates`, `diagnostics`, `candidates`, `actions`, and `expected`, with every array the same length and order. Never rebuild it from preview fields. If the host cannot pass the exact object, stop and say so.
|
|
41
41
|
8. **Apply once** with `kb_apply_plan`, the exact plan, and `approvedPlanHash`. The operation owns dependency ordering, source-first writes, sequential mutation, and recovery journaling. A plan with hundreds of actions can run for minutes: pass a `progressToken` (Kibi sends progress after each action) with a client that resets its timeout on progress, or pass `async: true` and poll `kb_job_status` when the host has it. If the apply is cut off, call `kb_apply_plan` with only the `recoveryJournalId` from `kb_status` or the error; it resumes an action interrupted mid-write and reclaims a lock left by a dead process. Never edit or delete `.kb/recovery` files; if recovery is refused, stop and report it.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: kibi-usage
|
|
3
3
|
name: Kibi Usage
|
|
4
4
|
description: Use Kibi's source-first, exact-Git, migration-aware, proof-aware operations safely across MCP or the trusted local CLI, including partial completion repair.
|
|
5
|
-
version: 2.
|
|
5
|
+
version: 2.10.0
|
|
6
6
|
kibiCompatibility: ">=1.0.0"
|
|
7
7
|
tags:
|
|
8
8
|
- kibi
|
|
@@ -260,7 +260,15 @@ constants) or `examples`, and why the current value was refused. With a
|
|
|
260
260
|
`requirementId` whose requirement `constrains` one subject fact, the `subject`
|
|
261
261
|
argument is already bound to that fact's `subject_key` (provenance
|
|
262
262
|
`requirement`); keep it, so the predicate and the subject fact name one
|
|
263
|
-
subject.
|
|
263
|
+
subject. A schema without a `subject` argument (`permission_rule`) records
|
|
264
|
+
that key as the planned fact's `subject_key` instead; when the requirement
|
|
265
|
+
constrains several subjects, an unbound `subject_key` asks you to pass
|
|
266
|
+
`subjectHint` with one of them. A participant (`actor`, `resource`, entity)
|
|
267
|
+
is a short noun, never a clause of the claim, and an `actor`, `role` or
|
|
268
|
+
`owner` is never the requirement's subject key: the planned fact already
|
|
269
|
+
carries that key as `subject_key`, so `actor = <subject key>` stays unbound
|
|
270
|
+
with a reason. If the claim names no actor, the schema does not fit the
|
|
271
|
+
claim: record the ontology gap instead of inventing a participant. Bind them
|
|
264
272
|
from the claim's own words and call again with the same `text` and
|
|
265
273
|
`requirementId`, plus `schemaId` and `argumentBindings` keyed by
|
|
266
274
|
`argument_names` (reuse `argument_constants` values when the schema has them).
|
|
@@ -279,9 +287,10 @@ grounds the claim (for example a bootstrap `requires_property` fact); the action
|
|
|
279
287
|
still names the predicate state. `replace_grounding` means a predicate fits but
|
|
280
288
|
a second grounding link would fail, so keep the existing link or apply the
|
|
281
289
|
`replacementPlan` steps unchanged, in order and back to back (predicate fact,
|
|
282
|
-
`kb_delete` of the old link, requirement link; `kb_check`
|
|
283
|
-
`logic-coverage`
|
|
284
|
-
`
|
|
290
|
+
`kb_delete` of the old link, requirement link; between the last two `kb_check`
|
|
291
|
+
reports both `logic-coverage` and `strict-req-fact-pairing` for the
|
|
292
|
+
requirement, as `expected.kbCheckAfterStep` states; run `kb_check` after the
|
|
293
|
+
last step and apply `rollback` if it is not clean); `provide_argument_bindings` and `record_ontology_gap` mean
|
|
285
294
|
the same as for an ungrounded claim, and the gap observation is not a grounding
|
|
286
295
|
link, so write it exactly as returned (tags, `claim_text`, `document.body`, no
|
|
287
296
|
`claim_key`, no relationships). Record an ontology gap only when no returned schema fits the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-answer.d.ts","sourceRoot":"","sources":["../src/search-answer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"search-answer.d.ts","sourceRoot":"","sources":["../src/search-answer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAW5D,OAAO,KAAK,EACV,UAAU,EAEX,MAAM,sCAAsC,CAAC;AAI9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB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