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,7 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { extractFromManifestString } from "../../extractors/manifest.js";
|
|
3
3
|
import { extractFromMarkdownString } from "../../extractors/markdown.js";
|
|
4
|
-
import {
|
|
4
|
+
import { PROVENANCE_STUB_TAG } from "../../provenance-stub.js";
|
|
5
|
+
import { bootstrapProvenance, confidenceBand, provenanceBody, provenanceStubBody, slug, upsert, withDocumentBody, } from "./candidate-helpers.js";
|
|
5
6
|
import { markdownCandidates, } from "./markdown-candidates.js";
|
|
6
7
|
function typedCandidates(item, existingIds) {
|
|
7
8
|
const results = item.kind === "symbol_manifest"
|
|
@@ -36,6 +37,31 @@ function typedCandidates(item, existingIds) {
|
|
|
36
37
|
];
|
|
37
38
|
});
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The claim a provider states about its source, or undefined when the
|
|
42
|
+
* provider found only that the file exists. A provider candidate without a
|
|
43
|
+
* claim is a provenance stub: its body would be nothing but the provenance
|
|
44
|
+
* template, so it is written as a `meta` fact tagged
|
|
45
|
+
* `bootstrap:provenance-stub` instead of an observation that search, gap and
|
|
46
|
+
* coverage reports would otherwise read as knowledge.
|
|
47
|
+
*/
|
|
48
|
+
// implements REQ-bootstrap-provenance-stubs
|
|
49
|
+
export function providerClaim(item) {
|
|
50
|
+
const claim = typeof item.data.claim === "string" ? item.data.claim.trim() : "";
|
|
51
|
+
return claim.length > 0 ? claim : undefined;
|
|
52
|
+
}
|
|
53
|
+
/** Whether a planned candidate writes a provenance stub. */
|
|
54
|
+
// implements REQ-bootstrap-provenance-stubs
|
|
55
|
+
export function isProvenanceStubCandidate(candidate) {
|
|
56
|
+
return candidate.applyPlan.some((payload) => {
|
|
57
|
+
const properties = payload.properties;
|
|
58
|
+
if (properties === null || typeof properties !== "object")
|
|
59
|
+
return false;
|
|
60
|
+
const tags = properties.tags;
|
|
61
|
+
return Array.isArray(tags) && tags.includes(PROVENANCE_STUB_TAG);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// implements REQ-bootstrap-provenance-stubs
|
|
39
65
|
function providerCandidate(item, existingIds, minConfidence) {
|
|
40
66
|
if (!new Set([
|
|
41
67
|
"repo_metadata",
|
|
@@ -55,22 +81,28 @@ function providerCandidate(item, existingIds, minConfidence) {
|
|
|
55
81
|
const title = (typeof item.data.title === "string" ? item.data.title : undefined) ??
|
|
56
82
|
symbolTitle ??
|
|
57
83
|
`Bootstrap evidence from ${relativePath}`;
|
|
84
|
+
const claim = providerClaim(item);
|
|
85
|
+
const stub = claim === undefined;
|
|
58
86
|
const entity = {
|
|
59
87
|
type: "fact",
|
|
60
88
|
id,
|
|
61
89
|
title,
|
|
62
90
|
status: "active",
|
|
63
|
-
fact_kind:
|
|
64
|
-
?
|
|
65
|
-
: item.
|
|
66
|
-
?
|
|
67
|
-
: "
|
|
91
|
+
fact_kind: stub
|
|
92
|
+
? "meta"
|
|
93
|
+
: typeof item.data.factKind === "string"
|
|
94
|
+
? item.data.factKind
|
|
95
|
+
: item.kind === "repo_metadata"
|
|
96
|
+
? "meta"
|
|
97
|
+
: "observation",
|
|
68
98
|
source: `bootstrap:${item.provider}:${relativePath}`,
|
|
69
99
|
text_ref: relativePath,
|
|
100
|
+
...(stub ? { tags: [PROVENANCE_STUB_TAG] } : {}),
|
|
70
101
|
};
|
|
71
102
|
const evidence = Array.isArray(item.data.evidence)
|
|
72
103
|
? item.data.evidence.filter((value) => typeof value === "string")
|
|
73
104
|
: [`provider:${item.provider}`, `${item.provider}:${relativePath}`];
|
|
105
|
+
const provenance = `${bootstrapProvenance(item.provider, relativePath, confidence)}${evidence.length > 0 ? ` Evidence: ${evidence.join("; ")}.` : ""}`;
|
|
74
106
|
return [
|
|
75
107
|
{
|
|
76
108
|
candidateId: `prov:${item.kind}:${slug(relativePath, 96) || "evidence"}`,
|
|
@@ -83,7 +115,9 @@ function providerCandidate(item, existingIds, minConfidence) {
|
|
|
83
115
|
evidence,
|
|
84
116
|
relationships: [],
|
|
85
117
|
applyPlan: [
|
|
86
|
-
withDocumentBody(upsert(entity),
|
|
118
|
+
withDocumentBody(upsert(entity), stub
|
|
119
|
+
? provenanceStubBody(title, provenance)
|
|
120
|
+
: provenanceBody(`${title.trim()}\n\n${claim}`, provenance)),
|
|
87
121
|
],
|
|
88
122
|
},
|
|
89
123
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-evidence.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/discovery-evidence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AA0BpB,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery-evidence.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/discovery-evidence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AA0BpB,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AA4KF,wBAAsB,YAAY,CAChC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,YAAY,CAAC,CA4DvB"}
|
|
@@ -92,6 +92,9 @@ function evidenceData(provider, relativePath, content) {
|
|
|
92
92
|
content.includes("vitest") ? "vitest" : "",
|
|
93
93
|
content.includes("node:test") ? "node:test" : "",
|
|
94
94
|
].filter(Boolean);
|
|
95
|
+
// A recognized framework is a claim about the file (it is a test that
|
|
96
|
+
// runs under that framework); without one the provider only found the
|
|
97
|
+
// file, and the candidate becomes a provenance stub.
|
|
95
98
|
return {
|
|
96
99
|
title: `Test topology: ${frameworks.join(", ") || relativePath}`,
|
|
97
100
|
factKind: "observation",
|
|
@@ -101,6 +104,11 @@ function evidenceData(provider, relativePath, content) {
|
|
|
101
104
|
...frameworks.map((item) => `framework:${item}`),
|
|
102
105
|
],
|
|
103
106
|
frameworks,
|
|
107
|
+
...(frameworks.length > 0
|
|
108
|
+
? {
|
|
109
|
+
claim: `${relativePath} is a test file that runs under ${frameworks.join(", ")}.`,
|
|
110
|
+
}
|
|
111
|
+
: {}),
|
|
104
112
|
};
|
|
105
113
|
}
|
|
106
114
|
if (provider === "source_symbols") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAcjF,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA+BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,OAAO,EAAE,MAAM,GACd;IACD,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAwJA;AA+JD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAiH9B"}
|
|
@@ -4,7 +4,7 @@ import { loadEntityIds } from "../../public/operations/discovery-entities.js";
|
|
|
4
4
|
import { executeStatus } from "../../public/operations/discovery-executors.js";
|
|
5
5
|
import { readWorkspaceSnapshot } from "../../public/operations/workspace-snapshot.js";
|
|
6
6
|
import { stagedLogicalGroundingError, } from "../semantic-advisor/ingestion-boundary.js";
|
|
7
|
-
import { buildBootstrapCandidates } from "./candidates.js";
|
|
7
|
+
import { buildBootstrapCandidates, isProvenanceStubCandidate, } from "./candidates.js";
|
|
8
8
|
import { discoverBootstrap } from "./discovery.js";
|
|
9
9
|
import { buildIntentClaimCandidates } from "./intent-claims.js";
|
|
10
10
|
import { normalizeBootstrapContext, presentBootstrap } from "./presentation.js";
|
|
@@ -37,7 +37,7 @@ function firstUpsertId(candidate) {
|
|
|
37
37
|
function sha256(value) {
|
|
38
38
|
return createHash("sha256").update(value).digest("hex");
|
|
39
39
|
}
|
|
40
|
-
// implements REQ-bootstrap-write-safety, REQ-bootstrap-intent-claim-accounting, REQ-bootstrap-discovered-candidate-budget
|
|
40
|
+
// implements REQ-bootstrap-write-safety, REQ-bootstrap-intent-claim-accounting, REQ-bootstrap-discovered-candidate-budget, REQ-bootstrap-provenance-stubs
|
|
41
41
|
export function selectBootstrapCandidates(input, existingIds, entityTypes, maximum) {
|
|
42
42
|
const allowed = entityTypes?.length ? new Set(entityTypes) : null;
|
|
43
43
|
const lane = (candidate) => {
|
|
@@ -46,7 +46,9 @@ export function selectBootstrapCandidates(input, existingIds, entityTypes, maxim
|
|
|
46
46
|
if (candidate.entityType === "req" &&
|
|
47
47
|
["typed_markdown", "generic_markdown"].includes(candidate.sourceKind))
|
|
48
48
|
return 1;
|
|
49
|
-
|
|
49
|
+
// Provenance stubs state no claim, so they take the budget last: a
|
|
50
|
+
// candidate with a claim is never suppressed as over_limit by a stub.
|
|
51
|
+
return isProvenanceStubCandidate(candidate) ? 3 : 2;
|
|
50
52
|
};
|
|
51
53
|
const suppressed = [];
|
|
52
54
|
const sourceOnlySignals = [];
|
|
@@ -122,11 +124,21 @@ export function selectBootstrapCandidates(input, existingIds, entityTypes, maxim
|
|
|
122
124
|
const candidates = [];
|
|
123
125
|
let discoveredCount = 0;
|
|
124
126
|
let overLimit = 0;
|
|
127
|
+
let overLimitStubs = 0;
|
|
125
128
|
for (const candidate of selected.values()) {
|
|
126
129
|
const discovered = candidate.sourceKind !== "intent_claim";
|
|
127
130
|
if (discovered && discoveredCount >= maximum) {
|
|
128
|
-
|
|
131
|
+
const stub = isProvenanceStubCandidate(candidate);
|
|
132
|
+
suppressed.push({
|
|
133
|
+
candidateId: candidate.candidateId,
|
|
134
|
+
reason: "over_limit",
|
|
135
|
+
sourcePath: candidate.sourcePath,
|
|
136
|
+
entityType: candidate.entityType,
|
|
137
|
+
provenanceStub: stub,
|
|
138
|
+
});
|
|
129
139
|
overLimit += 1;
|
|
140
|
+
if (stub)
|
|
141
|
+
overLimitStubs += 1;
|
|
130
142
|
continue;
|
|
131
143
|
}
|
|
132
144
|
// Two candidates that write one entity ID with different content would
|
|
@@ -158,7 +170,7 @@ export function selectBootstrapCandidates(input, existingIds, entityTypes, maxim
|
|
|
158
170
|
candidates.push(candidate);
|
|
159
171
|
}
|
|
160
172
|
if (overLimit > 0)
|
|
161
|
-
diagnostics.push(`${overLimit} discovered candidate(s) exceeded maxCandidates ${maximum} and are suppressed as over_limit; declared intent claims do not count against it.`);
|
|
173
|
+
diagnostics.push(`${overLimit} discovered candidate(s) exceeded maxCandidates ${maximum} and are suppressed as over_limit, ${overLimitStubs} of them provenance stubs that state no claim (raise the limit only for the ${overLimit - overLimitStubs} with a claim); declared intent claims do not count against it.`);
|
|
162
174
|
return {
|
|
163
175
|
candidates,
|
|
164
176
|
suppressed,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/presentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/presentation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAGhB,gBAAgB,EAChB,wBAAwB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ates.js";
|
|
1
2
|
import { buildGuidance } from "./guidance.js";
|
|
2
3
|
import { INTENT_CLAIM_KINDS, KNOWLEDGE_SOURCE_AUTHORITIES, KNOWLEDGE_SOURCE_KINDS, bootstrapPlanHash, } from "./types.js";
|
|
3
4
|
function strings(values) {
|
|
@@ -153,7 +154,7 @@ function claimAccounting(declared, candidates, suppressed) {
|
|
|
153
154
|
return [{ source, declared: count, planned, existing, filtered }];
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
|
-
// implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-bootstrap-discovered-candidate-budget
|
|
157
|
+
// implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-bootstrap-discovered-candidate-budget, REQ-bootstrap-provenance-stubs
|
|
157
158
|
export function presentBootstrap(input) {
|
|
158
159
|
const declaredContext = normalizeBootstrapContext(input.bootstrapContext);
|
|
159
160
|
const guidance = buildGuidance({
|
|
@@ -183,9 +184,20 @@ export function presentBootstrap(input) {
|
|
|
183
184
|
const suppressionSummary = suppressedTotal > 0
|
|
184
185
|
? ` Suppressed ${suppressedTotal} candidate(s) by reason: ${suppression.map((row) => `${row.reason} ${row.count}`).join(", ")}.`
|
|
185
186
|
: "";
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
// Stubs are counted apart from candidates with a claim so nobody raises
|
|
188
|
+
// maxCandidates to admit entries that state nothing.
|
|
189
|
+
const provenanceStubs = input.candidates.filter(isProvenanceStubCandidate);
|
|
190
|
+
const overLimitRows = input.suppressedCandidates.filter((row) => row.reason === "over_limit");
|
|
191
|
+
const overLimitStubs = overLimitRows.filter((row) => row.provenanceStub === true).length;
|
|
192
|
+
const limitSummary = overLimitRows.length > 0
|
|
193
|
+
? ` Discovered candidates over maxCandidates are over_limit (${overLimitStubs} of ${overLimitRows.length} are provenance stubs that state no claim); raise the limit only for the ${overLimitRows.length - overLimitStubs} with a claim, or narrow entityTypes. Declared intent claims do not count against it.`
|
|
188
194
|
: "";
|
|
195
|
+
const discoverySummary = {
|
|
196
|
+
...input.discoverySummary,
|
|
197
|
+
candidatesWithClaims: input.candidates.length - provenanceStubs.length,
|
|
198
|
+
provenanceStubs: provenanceStubs.length,
|
|
199
|
+
suppressedProvenanceStubs: overLimitStubs,
|
|
200
|
+
};
|
|
189
201
|
const tldr = (confidenceLevel === "low" && !input.activation.applyBlocked
|
|
190
202
|
? `Low-confidence bootstrap (${String(guidance.confidence.score)}): review diagnostics before proceeding. ${baseTldr}`
|
|
191
203
|
: baseTldr) +
|
|
@@ -279,7 +291,7 @@ export function presentBootstrap(input) {
|
|
|
279
291
|
declaredContext,
|
|
280
292
|
contextQuestions: contextQuestions.slice(0, 4),
|
|
281
293
|
confidence: guidance.confidence,
|
|
282
|
-
discoverySummary
|
|
294
|
+
discoverySummary,
|
|
283
295
|
candidates: input.candidates,
|
|
284
296
|
actions,
|
|
285
297
|
sourceWrites: [],
|
|
@@ -312,7 +324,7 @@ export function presentBootstrap(input) {
|
|
|
312
324
|
promptBlock: guidance.promptBlock,
|
|
313
325
|
recommendedActions: guidance.actions,
|
|
314
326
|
declaredContext,
|
|
315
|
-
discoverySummary
|
|
327
|
+
discoverySummary,
|
|
316
328
|
candidates: input.candidates,
|
|
317
329
|
actions,
|
|
318
330
|
sourceWrites: [],
|
|
@@ -130,6 +130,12 @@ export type DiscoverySummary = {
|
|
|
130
130
|
readonly excludedRoots: readonly string[];
|
|
131
131
|
readonly truncated: boolean;
|
|
132
132
|
readonly scanWarnings: readonly string[];
|
|
133
|
+
/** Planned discovered or declared candidates that state a claim. */
|
|
134
|
+
readonly candidatesWithClaims?: number;
|
|
135
|
+
/** Planned provider facts that only record provenance (no claim). */
|
|
136
|
+
readonly provenanceStubs?: number;
|
|
137
|
+
/** Provenance stubs suppressed as over_limit; no reason to raise the cap. */
|
|
138
|
+
readonly suppressedProvenanceStubs?: number;
|
|
133
139
|
};
|
|
134
140
|
export type DiscoveryResult = {
|
|
135
141
|
readonly activation: ActivationPolicy;
|
|
@@ -1 +1 @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AM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5E,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC7B,eAAe,CAAC,0BAA0B,CAAC,GAAG;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,0BAA0B,CAAC;CACxD,CAAC"}
|
|
@@ -11,6 +11,13 @@ export declare function buildSuggestion(schema: PredicateSchemaCandidate, text:
|
|
|
11
11
|
* the caller bound that argument or passed subjectHint.
|
|
12
12
|
*/
|
|
13
13
|
requirementSubject?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Every subject_key the requirement constrains. When there are any, the
|
|
16
|
+
* predicate must be about one of them (its `subject` argument or, for a
|
|
17
|
+
* schema without one, its subject_key) or kb_check reports
|
|
18
|
+
* strict-req-fact-pairing; an unpaired candidate stays incomplete.
|
|
19
|
+
*/
|
|
20
|
+
constrainedSubjects?: readonly string[];
|
|
14
21
|
}): PredicateSuggestion;
|
|
15
22
|
export declare function buildPredicateApplyPlan(suggestion: PredicateSuggestion, args: SuggestPredicatesArgs): Array<Record<string, unknown>>;
|
|
16
23
|
export declare function buildRelationshipPlan(factId: string | undefined, requirementId: string | undefined, claimText?: string, existingLogicClaims?: readonly string[]): Record<string, unknown> | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"
|
|
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,E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|
import { semanticClaimKey } from "../semantic-advisor/clauses.js";
|
|
2
2
|
import { exactLauncherPredicateArgs } from "../semantic-advisor/predicate-rules-launcher.js";
|
|
3
|
-
import { aggregateBindingProvenance, bindingCanBeApplied, classifyBinding, isGenericPlaceholder, } from "./predicate-bindings.js";
|
|
3
|
+
import { aggregateBindingProvenance, bindingCanBeApplied, classifyBinding, isGenericPlaceholder, isParticipantArgumentType, } from "./predicate-bindings.js";
|
|
4
4
|
import { inferArgs } from "./predicate-inference.js";
|
|
5
5
|
import { schemaForCandidate } from "./predicate-loader.js";
|
|
6
6
|
import { hashId } from "./predicate-utils.js";
|
|
7
7
|
import { applyArgumentRewrites, predicateArgumentConformance, } from "./predicate-vocabulary.js";
|
|
8
|
-
// implements REQ-mcp-suggest-predicates
|
|
8
|
+
// implements REQ-mcp-suggest-predicates, REQ-model-predicates-requirement-subject-v2, REQ-model-predicates-binding-clauses, REQ-model-predicates-participant-not-subject
|
|
9
9
|
export function buildSuggestion(schema, text, subject, score, argumentBindings = {}, polarityHint, diagnostics) {
|
|
10
10
|
const inferredArgs = inferArgs(schema, text, subject);
|
|
11
11
|
const canonicalLauncherArgs = exactLauncherPredicateArgs(schema.predicate_name, text);
|
|
12
12
|
const hasExactBinding = (name) => typeof argumentBindings[name] === "string" &&
|
|
13
13
|
argumentBindings[name].trim().length > 0;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// The argument the schema names `subject`, wherever it sits; -1 when the
|
|
15
|
+
// schema names no subject (permission_rule(actor, action, resource, ...)).
|
|
16
|
+
const subjectArgument = schema.argument_names.indexOf("subject");
|
|
17
|
+
const explicitSubject = diagnostics?.explicitSubject === true;
|
|
18
|
+
// The reviewed subject: subjectHint, else the requirement's constrained
|
|
19
|
+
// subject. It binds the `subject` argument unless that argument is bound.
|
|
20
|
+
const reviewedSubject = explicitSubject
|
|
21
|
+
? subject
|
|
22
|
+
: diagnostics?.requirementSubject;
|
|
23
|
+
const reviewedSubjectArgument = reviewedSubject !== undefined && !hasExactBinding("subject")
|
|
24
|
+
? subjectArgument
|
|
18
25
|
: -1;
|
|
19
26
|
const boundArgs = schema.argument_names.map((name, index) => {
|
|
20
27
|
const exactBinding = argumentBindings[name];
|
|
21
|
-
if (index ===
|
|
22
|
-
return
|
|
28
|
+
if (index === reviewedSubjectArgument)
|
|
29
|
+
return reviewedSubject ?? "unknown";
|
|
23
30
|
return typeof exactBinding === "string" && exactBinding.trim().length > 0
|
|
24
31
|
? exactBinding.trim()
|
|
25
32
|
: (inferredArgs[index] ?? "unknown");
|
|
@@ -34,32 +41,63 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
34
41
|
const conformance = predicateArgumentConformance(schema.argument_names, boundArgs, vocabulary);
|
|
35
42
|
const predicateArgs = applyArgumentRewrites(boundArgs, conformance.rewrites);
|
|
36
43
|
const undeclaredArguments = new Set(conformance.undeclared.map((value) => value.argumentName));
|
|
44
|
+
// A schema without a `subject` argument may still lead with the hinted
|
|
45
|
+
// subject (inference put it there): that value is the agent's reviewed
|
|
46
|
+
// value, even when the schema names its first argument after it. A
|
|
47
|
+
// participant argument (actor, role, owner) is the exception: the subject
|
|
48
|
+
// is what the claim is about, never who acts on it.
|
|
49
|
+
const hintedFirstArgument = explicitSubject &&
|
|
50
|
+
subjectArgument < 0 &&
|
|
51
|
+
!hasExactBinding(schema.argument_names[0] ?? "") &&
|
|
52
|
+
predicateArgs[0] === subject &&
|
|
53
|
+
!isParticipantArgumentType(schema.argument_types[0])
|
|
54
|
+
? 0
|
|
55
|
+
: -1;
|
|
56
|
+
const constrainedSubjects = diagnostics?.constrainedSubjects ?? [];
|
|
37
57
|
const bindingProvenanceByArgument = Object.fromEntries(schema.argument_names.map((name, index) => [
|
|
38
58
|
name,
|
|
39
|
-
index ===
|
|
40
|
-
?
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
index === reviewedSubjectArgument && !undeclaredArguments.has(name)
|
|
60
|
+
? explicitSubject
|
|
61
|
+
? classifyBinding(predicateArgs[index] ?? "unknown", text, true)
|
|
62
|
+
: "requirement"
|
|
63
|
+
: classifyBinding(predicateArgs[index] ?? "unknown", text, hasExactBinding(name) || index === hintedFirstArgument, canonicalLauncherArgs?.[index] === predicateArgs[index] &&
|
|
44
64
|
!(index === 0 &&
|
|
45
65
|
predicateArgs[index] === "launcher" &&
|
|
46
|
-
|
|
47
|
-
typeof argumentBindings[name] !== "string"),
|
|
48
|
-
// A subject named through subjectHint is the agent's reviewed
|
|
49
|
-
// subject, even when the schema names its first argument after it.
|
|
50
|
-
index === 0 &&
|
|
51
|
-
diagnostics?.explicitSubject === true &&
|
|
52
|
-
typeof argumentBindings[name] !== "string"
|
|
66
|
+
!explicitSubject &&
|
|
67
|
+
typeof argumentBindings[name] !== "string"), index === hintedFirstArgument
|
|
53
68
|
? { constants: schema.argument_constants?.[name] }
|
|
54
69
|
: {
|
|
55
70
|
argumentName: name,
|
|
56
71
|
argumentNames: schema.argument_names,
|
|
72
|
+
argumentType: schema.argument_types[index],
|
|
57
73
|
constants: schema.argument_constants?.[name],
|
|
74
|
+
constrainedSubjects,
|
|
58
75
|
}),
|
|
59
76
|
]));
|
|
77
|
+
// The subject the planned predicate fact is about, when the requirement
|
|
78
|
+
// constrains subjects: the `subject` argument's value, or for a schema
|
|
79
|
+
// without one the reviewed subject, recorded as the fact's subject_key.
|
|
80
|
+
const subjectKey = constrainedSubjects.length === 0
|
|
81
|
+
? null
|
|
82
|
+
: subjectArgument >= 0
|
|
83
|
+
? (predicateArgs[subjectArgument] ?? null)
|
|
84
|
+
: (reviewedSubject ?? null);
|
|
85
|
+
const subjectPairing = constrainedSubjects.length === 0
|
|
86
|
+
? "not_required"
|
|
87
|
+
: subjectKey !== null && constrainedSubjects.includes(subjectKey)
|
|
88
|
+
? "paired"
|
|
89
|
+
: "unpaired";
|
|
60
90
|
const bindingProvenance = aggregateBindingProvenance(Object.values(bindingProvenanceByArgument));
|
|
61
91
|
const unboundArguments = schema.argument_names.filter((name) => undeclaredArguments.has(name) ||
|
|
62
92
|
!bindingCanBeApplied(bindingProvenanceByArgument[name] ?? "placeholder"));
|
|
93
|
+
// An unpaired predicate would leave kb_check's strict-req-fact-pairing on
|
|
94
|
+
// the requirement, so the subject still needs a binding: the `subject`
|
|
95
|
+
// argument, or the fact's subject_key for a schema without one.
|
|
96
|
+
if (subjectPairing === "unpaired") {
|
|
97
|
+
const missing = subjectArgument >= 0 ? "subject" : "subject_key";
|
|
98
|
+
if (!unboundArguments.includes(missing))
|
|
99
|
+
unboundArguments.push(missing);
|
|
100
|
+
}
|
|
63
101
|
const canonicalKey = `${schema.predicate_name}(${predicateArgs.join(",")})`;
|
|
64
102
|
// Permission-style inference carries the deontic decision as its final
|
|
65
103
|
// argument. Preserve that polarity in the typed suggestion instead of
|
|
@@ -79,6 +117,8 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
79
117
|
unbound_arguments: unboundArguments,
|
|
80
118
|
binding_provenance: bindingProvenance,
|
|
81
119
|
binding_provenance_by_argument: bindingProvenanceByArgument,
|
|
120
|
+
subject_key: subjectKey,
|
|
121
|
+
subject_pairing: subjectPairing,
|
|
82
122
|
eligibility: diagnostics?.eligibility ?? "eligible",
|
|
83
123
|
rejection_reasons: [...(diagnostics?.rejectionReasons ?? [])],
|
|
84
124
|
applicability_score: diagnostics?.applicabilityScore ?? score,
|
|
@@ -97,7 +137,7 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
97
137
|
schema: schemaForCandidate(schema),
|
|
98
138
|
};
|
|
99
139
|
}
|
|
100
|
-
// implements REQ-mcp-suggest-predicates
|
|
140
|
+
// implements REQ-mcp-suggest-predicates, REQ-model-predicates-requirement-subject-v2
|
|
101
141
|
export function buildPredicateApplyPlan(suggestion, args) {
|
|
102
142
|
if (suggestion.binding_status !== "complete" ||
|
|
103
143
|
suggestion.eligibility !== "eligible")
|
|
@@ -123,6 +163,11 @@ export function buildPredicateApplyPlan(suggestion, args) {
|
|
|
123
163
|
...suggestion.schema.tags.map((tag) => `predicate:${tag}`),
|
|
124
164
|
],
|
|
125
165
|
fact_kind: "predicate",
|
|
166
|
+
// The subject the predicate is about, so kb_check pairs it with the
|
|
167
|
+
// requirement's subject fact whatever argument holds the subject.
|
|
168
|
+
...(suggestion.subject_key
|
|
169
|
+
? { subject_key: suggestion.subject_key }
|
|
170
|
+
: {}),
|
|
126
171
|
predicate_name: suggestion.predicate_name,
|
|
127
172
|
predicate_args: suggestion.predicate_args,
|
|
128
173
|
canonical_key: suggestion.canonical_key,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-binding-hints.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-binding-hints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"predicate-binding-hints.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-binding-hints.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAmF7E;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,MAAM,EACZ,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,WAAW,EAAE,CA6Df;AAED,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAW1E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isGenericPlaceholder, nameOrStopWordReason, } from "./predicate-bindings.js";
|
|
1
|
+
import { bindingCanBeApplied, clauseBindingReason, isGenericPlaceholder, isParticipantArgumentType, nameOrStopWordReason, subjectKeyParticipantReason, } from "./predicate-bindings.js";
|
|
2
2
|
const MAX_EXAMPLES = 5;
|
|
3
3
|
/** Split `name(a, b(c), d)` into its top-level arguments, or [] when it is not a call. */
|
|
4
4
|
function exampleArguments(example) {
|
|
@@ -25,9 +25,21 @@ function exampleArguments(example) {
|
|
|
25
25
|
args.push(current.trim());
|
|
26
26
|
return args.filter(Boolean);
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* What to do when the claim names no participant for an actor-like argument:
|
|
30
|
+
* the requirement's subject key is not a participant, and a schema whose
|
|
31
|
+
* actor the claim never names does not fit the claim.
|
|
32
|
+
*/
|
|
33
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
34
|
+
function noParticipantGuidance(type) {
|
|
35
|
+
return `The claim names no ${type}. Bind the participant the claim names (a noun of at most 3 words), never the requirement's subject key; if the claim names no ${type}, this schema does not fit the claim: record_ontology_gap instead.`;
|
|
36
|
+
}
|
|
37
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
38
|
+
function unboundReason(candidate, name, value, text, requirementSubjects) {
|
|
29
39
|
const schema = candidate.schema;
|
|
30
40
|
const provenance = candidate.binding_provenance_by_argument[name];
|
|
41
|
+
const type = schema.argument_types[schema.argument_names.indexOf(name)];
|
|
42
|
+
const participant = isParticipantArgumentType(type);
|
|
31
43
|
const nameReason = nameOrStopWordReason(value, {
|
|
32
44
|
argumentName: name,
|
|
33
45
|
argumentNames: schema.argument_names,
|
|
@@ -36,8 +48,25 @@ function unboundReason(candidate, name, value, text) {
|
|
|
36
48
|
});
|
|
37
49
|
if (nameReason !== null)
|
|
38
50
|
return `The value "${value}" is not a binding: ${nameReason}.`;
|
|
51
|
+
const subjectReason = subjectKeyParticipantReason(value, {
|
|
52
|
+
argumentType: type,
|
|
53
|
+
constants: schema.argument_constants?.[name],
|
|
54
|
+
constrainedSubjects: requirementSubjects,
|
|
55
|
+
});
|
|
56
|
+
if (subjectReason !== null)
|
|
57
|
+
return `The value "${value}" is not a binding: ${subjectReason}. ${noParticipantGuidance(String(type))}`;
|
|
58
|
+
const clauseReason = clauseBindingReason(value, {
|
|
59
|
+
argumentType: type,
|
|
60
|
+
constants: schema.argument_constants?.[name],
|
|
61
|
+
});
|
|
62
|
+
if (clauseReason !== null)
|
|
63
|
+
return participant
|
|
64
|
+
? `The value "${value}" is not a binding: ${clauseReason}. Bind a noun of at most 3 words. ${noParticipantGuidance(String(type))}`
|
|
65
|
+
: `The value "${value}" is not a binding: ${clauseReason}. Bind a noun of at most 3 words, or the requirement's subject key.`;
|
|
39
66
|
if (!value.trim() || isGenericPlaceholder(value))
|
|
40
|
-
return
|
|
67
|
+
return participant
|
|
68
|
+
? noParticipantGuidance(String(type))
|
|
69
|
+
: "The claim text names no value for this argument.";
|
|
41
70
|
if (provenance === "inferred")
|
|
42
71
|
return `The value "${value}" was inferred and does not appear in the claim text; confirm it or pass the exact value.`;
|
|
43
72
|
if (schema.argument_constants?.[name])
|
|
@@ -50,20 +79,39 @@ function unboundReason(candidate, name, value, text) {
|
|
|
50
79
|
* current value was not accepted, so the agent binds from the claim text
|
|
51
80
|
* instead of guessing.
|
|
52
81
|
*/
|
|
53
|
-
// implements REQ-model-predicates-binding-placeholders, REQ-model-predicates-requirement-subject
|
|
82
|
+
// implements REQ-model-predicates-binding-placeholders, REQ-model-predicates-requirement-subject-v2, REQ-model-predicates-binding-clauses, REQ-model-predicates-participant-not-subject
|
|
54
83
|
export function buildBindingHints(candidate, text, requirementSubjects = []) {
|
|
55
84
|
const schema = candidate.schema;
|
|
56
85
|
const parsedExamples = schema.examples.map(exampleArguments);
|
|
86
|
+
const namesSubject = schema.argument_names.includes("subject");
|
|
57
87
|
return candidate.unbound_arguments.map((name) => {
|
|
88
|
+
// A schema without a subject argument records the requirement's subject
|
|
89
|
+
// as the predicate fact's subject_key instead.
|
|
90
|
+
if (name === "subject_key" && !namesSubject)
|
|
91
|
+
return {
|
|
92
|
+
argument: name,
|
|
93
|
+
position: -1,
|
|
94
|
+
type: "subject_key",
|
|
95
|
+
description: "The subject the predicate fact is about; recorded as its subject_key because the schema names no subject argument.",
|
|
96
|
+
examples: requirementSubjects.slice(0, MAX_EXAMPLES),
|
|
97
|
+
currentValue: candidate.subject_key ?? "",
|
|
98
|
+
provenance: "placeholder",
|
|
99
|
+
reason: `The ${schema.predicate_name} schema does not name the requirement's subject, so kb_check pairs the predicate with the subject fact only through subject_key. Pass subjectHint with one of the subjects the requirement constrains.`,
|
|
100
|
+
};
|
|
58
101
|
const position = schema.argument_names.indexOf(name);
|
|
59
102
|
const constants = schema.argument_constants?.[name];
|
|
60
103
|
const exampleValues = parsedExamples
|
|
61
104
|
.map((args) => args[position])
|
|
62
105
|
.filter((value) => typeof value === "string");
|
|
63
|
-
// The subject keys the requirement already constrains come first
|
|
64
|
-
// the
|
|
106
|
+
// The subject keys the requirement already constrains come first for
|
|
107
|
+
// the subject argument, and for an entity argument of a schema without
|
|
108
|
+
// one, so the predicate and the subject fact use one identifier for the
|
|
109
|
+
// subject. A participant argument (actor, role, owner) never gets them:
|
|
110
|
+
// the subject is what the claim is about, not who acts on it.
|
|
111
|
+
const offersSubjects = name === "subject" ||
|
|
112
|
+
(!namesSubject && schema.argument_types[position] === "entity");
|
|
65
113
|
const examples = Array.from(new Set([
|
|
66
|
-
...(
|
|
114
|
+
...(offersSubjects ? requirementSubjects : []),
|
|
67
115
|
...(constants ?? []),
|
|
68
116
|
...exampleValues,
|
|
69
117
|
])).slice(0, MAX_EXAMPLES);
|
|
@@ -78,7 +126,11 @@ export function buildBindingHints(candidate, text, requirementSubjects = []) {
|
|
|
78
126
|
examples,
|
|
79
127
|
currentValue: current,
|
|
80
128
|
provenance: candidate.binding_provenance_by_argument[name] ?? "placeholder",
|
|
81
|
-
reason:
|
|
129
|
+
reason: name === "subject" &&
|
|
130
|
+
candidate.subject_pairing === "unpaired" &&
|
|
131
|
+
bindingCanBeApplied(candidate.binding_provenance_by_argument[name] ?? "placeholder")
|
|
132
|
+
? `The value "${current}" is not a subject the requirement constrains (${requirementSubjects.join(", ")}), so kb_check would not pair the predicate with the subject fact. Bind one of them.`
|
|
133
|
+
: unboundReason(candidate, name, current, text, requirementSubjects),
|
|
82
134
|
};
|
|
83
135
|
});
|
|
84
136
|
}
|