kibi-cli 2.10.0 → 2.12.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/operations/bootstrap/candidates.d.ts +2 -1
- package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidates.js +2 -2
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +10 -3
- package/dist/operations/bootstrap/intent-claims.d.ts +2 -1
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/intent-claims.js +6 -4
- package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -1
- package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/markdown-candidates.js +7 -5
- package/dist/operations/bootstrap/requirement-claims.d.ts +60 -2
- package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/requirement-claims.js +324 -20
- package/dist/operations/modeling/predicate-applyplan.d.ts +13 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +56 -18
- package/dist/operations/modeling/predicate-binding-hints.d.ts +11 -0
- package/dist/operations/modeling/predicate-binding-hints.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-binding-hints.js +97 -0
- package/dist/operations/modeling/predicate-bindings.d.ts +24 -1
- package/dist/operations/modeling/predicate-bindings.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-bindings.js +129 -4
- package/dist/operations/modeling/predicate-catalog-1.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-1.js +3 -0
- package/dist/operations/modeling/predicate-catalog-2.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-2.js +3 -0
- package/dist/operations/modeling/predicate-catalog-3.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-3.js +7 -0
- package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-4.js +2 -0
- package/dist/operations/modeling/predicate-closed-vocabularies.d.ts +104 -0
- package/dist/operations/modeling/predicate-closed-vocabularies.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-closed-vocabularies.js +104 -0
- package/dist/operations/modeling/predicate-types.d.ts +19 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-utils.d.ts +11 -1
- package/dist/operations/modeling/predicate-utils.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-utils.js +19 -3
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +112 -16
- package/dist/operations/semantic-advisor/observation-plan.d.ts +7 -0
- package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/observation-plan.js +13 -14
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +4 -0
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-usage/SKILL.md +20 -7
- package/dist/public/skills/kibi-usage/resources/workflows.md +2 -2
- package/dist/utils/strict-modeling.d.ts +1 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +1 -1
- package/package.json +2 -2
- package/src/public/operations/contracts.ts +5 -0
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-usage/SKILL.md +20 -7
- package/src/public/skills/kibi-usage/resources/workflows.md +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CandidateBuildResult } from "./markdown-candidates.js";
|
|
2
|
+
import type { SubjectKeyRegistry } from "./requirement-claims.js";
|
|
2
3
|
import type { BootstrapEvidence } from "./types.js";
|
|
3
|
-
export declare function buildBootstrapCandidates(evidence: readonly BootstrapEvidence[], existingIds: ReadonlySet<string>, minConfidence: number, includeGenericMarkdown: boolean): CandidateBuildResult;
|
|
4
|
+
export declare function buildBootstrapCandidates(evidence: readonly BootstrapEvidence[], existingIds: ReadonlySet<string>, minConfidence: number, includeGenericMarkdown: boolean, subjectKeys?: SubjectKeyRegistry): CandidateBuildResult;
|
|
4
5
|
//# sourceMappingURL=candidates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/candidates.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AAuHpB,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,sBAAsB,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/candidates.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AAuHpB,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"}
|
|
@@ -90,7 +90,7 @@ function providerCandidate(item, existingIds, minConfidence) {
|
|
|
90
90
|
}
|
|
91
91
|
// implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-kibi-operation-interface-parity
|
|
92
92
|
// implements REQ-KIBI-BOOTSTRAP-PLAN
|
|
93
|
-
export function buildBootstrapCandidates(evidence, existingIds, minConfidence, includeGenericMarkdown) {
|
|
93
|
+
export function buildBootstrapCandidates(evidence, existingIds, minConfidence, includeGenericMarkdown, subjectKeys) {
|
|
94
94
|
const candidates = [];
|
|
95
95
|
const sourceOnlySignals = [];
|
|
96
96
|
const diagnostics = [];
|
|
@@ -114,7 +114,7 @@ export function buildBootstrapCandidates(evidence, existingIds, minConfidence, i
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
if (item.kind === "generic_markdown" && includeGenericMarkdown) {
|
|
117
|
-
const built = markdownCandidates(item, existingIds, minConfidence);
|
|
117
|
+
const built = markdownCandidates(item, existingIds, minConfidence, subjectKeys);
|
|
118
118
|
candidates.push(...built.candidates);
|
|
119
119
|
sourceOnlySignals.push(...built.sourceOnlySignals);
|
|
120
120
|
diagnostics.push(...built.diagnostics);
|
|
@@ -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;AAWjF,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,CA6IA;AA+JD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAiH9B"}
|
|
@@ -8,6 +8,7 @@ import { buildBootstrapCandidates } 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";
|
|
11
|
+
import { SubjectKeyRegistry, shareSubjectFacts } from "./requirement-claims.js";
|
|
11
12
|
import { validateBootstrapPayload } from "./validation.js";
|
|
12
13
|
export function filterSourceOnlySignals(signals, entityTypes) {
|
|
13
14
|
return entityTypes && entityTypes.length > 0
|
|
@@ -316,8 +317,11 @@ export async function executePlanBootstrap(args, context) {
|
|
|
316
317
|
const bound = await expectedSnapshots(context, discovery.evidence
|
|
317
318
|
.map((evidence) => evidence.relativePath)
|
|
318
319
|
.filter((value) => Boolean(value)));
|
|
320
|
+
// One registry per plan keeps subject keys distinct across repository
|
|
321
|
+
// documents and declared intent claims.
|
|
322
|
+
const subjectKeys = new SubjectKeyRegistry();
|
|
319
323
|
const built = discovery.activation.allowCandidateGeneration
|
|
320
|
-
? buildBootstrapCandidates(discovery.evidence, new Set(), minConfidence, includeGenericMarkdown)
|
|
324
|
+
? buildBootstrapCandidates(discovery.evidence, new Set(), minConfidence, includeGenericMarkdown, subjectKeys)
|
|
321
325
|
: {
|
|
322
326
|
candidates: [],
|
|
323
327
|
sourceOnlySignals: [],
|
|
@@ -327,7 +331,7 @@ export async function executePlanBootstrap(args, context) {
|
|
|
327
331
|
// Intent harvested from declared knowledge sources joins the repository
|
|
328
332
|
// evidence under the same activation policy, filters, and selection.
|
|
329
333
|
const claimed = discovery.activation.allowCandidateGeneration
|
|
330
|
-
? buildIntentClaimCandidates(declared, existingIds, minConfidence)
|
|
334
|
+
? buildIntentClaimCandidates(declared, existingIds, minConfidence, subjectKeys)
|
|
331
335
|
: {
|
|
332
336
|
candidates: [],
|
|
333
337
|
sourceOnlySignals: [],
|
|
@@ -336,6 +340,8 @@ export async function executePlanBootstrap(args, context) {
|
|
|
336
340
|
};
|
|
337
341
|
const filteredSignals = filterSourceOnlySignals([...built.sourceOnlySignals, ...claimed.sourceOnlySignals], args.entityTypes);
|
|
338
342
|
const selected = selectBootstrapCandidates([...built.candidates, ...claimed.candidates].filter((candidate) => candidate.confidence >= minConfidence), existingIds, args.entityTypes, maxCandidates);
|
|
343
|
+
// Claims about the same subject share one subject fact.
|
|
344
|
+
const shared = shareSubjectFacts(selected.candidates);
|
|
339
345
|
const ignored = discovery.ignoredSources.map((sourcePath) => ({
|
|
340
346
|
candidateId: "",
|
|
341
347
|
reason: "ignored_source",
|
|
@@ -351,7 +357,7 @@ export async function executePlanBootstrap(args, context) {
|
|
|
351
357
|
...(args.bootstrapContext
|
|
352
358
|
? { bootstrapContext: args.bootstrapContext }
|
|
353
359
|
: {}),
|
|
354
|
-
candidates:
|
|
360
|
+
candidates: shared.candidates,
|
|
355
361
|
sourceOnlySignals: [
|
|
356
362
|
...filteredSignals,
|
|
357
363
|
...filterSourceOnlySignals(selected.sourceOnlySignals, args.entityTypes),
|
|
@@ -373,6 +379,7 @@ export async function executePlanBootstrap(args, context) {
|
|
|
373
379
|
...claimed.diagnostics,
|
|
374
380
|
...built.diagnostics,
|
|
375
381
|
...selected.diagnostics,
|
|
382
|
+
...shared.diagnostics,
|
|
376
383
|
],
|
|
377
384
|
});
|
|
378
385
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SubjectKeyRegistry } from "./requirement-claims.js";
|
|
1
2
|
import type { BootstrapDeclaredContext, Candidate, SourceOnlySignal } from "./types.js";
|
|
2
3
|
export type IntentClaimBuildResult = {
|
|
3
4
|
readonly candidates: readonly Candidate[];
|
|
@@ -13,5 +14,5 @@ export type IntentClaimBuildResult = {
|
|
|
13
14
|
* strict modeler cannot ground stays an explicit authoring follow-up instead
|
|
14
15
|
* of becoming unverifiable knowledge.
|
|
15
16
|
*/
|
|
16
|
-
export declare function buildIntentClaimCandidates(declared: BootstrapDeclaredContext, existingIds: ReadonlySet<string>, minConfidence: number): IntentClaimBuildResult;
|
|
17
|
+
export declare function buildIntentClaimCandidates(declared: BootstrapDeclaredContext, existingIds: ReadonlySet<string>, minConfidence: number, subjectKeys?: SubjectKeyRegistry): IntentClaimBuildResult;
|
|
17
18
|
//# sourceMappingURL=intent-claims.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAyOF;;;;;;;GAOG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,sBAAsB,CAyKxB"}
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { renderRequirementBody } from "../../entity-body-context.js";
|
|
3
3
|
import { buildStrictWriteSet } from "../../utils/strict-modeling.js";
|
|
4
4
|
import { confidenceBand, strictPlan, upsert } from "./candidate-helpers.js";
|
|
5
|
-
import { claimFor,
|
|
5
|
+
import { claimFor, planSubjectKey, } from "./requirement-claims.js";
|
|
6
6
|
/** How much a claim is trusted follows the authority the human assigned. */
|
|
7
7
|
const AUTHORITY_CONFIDENCE = {
|
|
8
8
|
authoritative: 0.9,
|
|
@@ -199,7 +199,7 @@ function conflictCandidates(declared, sources, existingIds, minConfidence) {
|
|
|
199
199
|
* of becoming unverifiable knowledge.
|
|
200
200
|
*/
|
|
201
201
|
// implements REQ-kibi-bootstrap-knowledge-sources, REQ-bootstrap-claim-kinds-and-conflicts
|
|
202
|
-
export function buildIntentClaimCandidates(declared, existingIds, minConfidence) {
|
|
202
|
+
export function buildIntentClaimCandidates(declared, existingIds, minConfidence, subjectKeys) {
|
|
203
203
|
const sources = new Map((declared.knowledgeSources ?? []).map((source) => [source.id, source]));
|
|
204
204
|
const candidates = [];
|
|
205
205
|
const sourceOnlySignals = [];
|
|
@@ -260,9 +260,11 @@ export function buildIntentClaimCandidates(declared, existingIds, minConfidence)
|
|
|
260
260
|
let writeSet = null;
|
|
261
261
|
try {
|
|
262
262
|
const modeled = claimFor(claim.statement, `knowledge-source:${source.id}`, confidence, provenance);
|
|
263
|
-
const
|
|
264
|
-
?
|
|
263
|
+
const planned = modeled
|
|
264
|
+
? planSubjectKey(modeled.subjectKey, modeled.propertyKey, claim.component ?? source.component, subjectKeys, `${source.id}:${claim.reference}`)
|
|
265
265
|
: null;
|
|
266
|
+
const subjectKey = planned?.resolution ?? null;
|
|
267
|
+
diagnostics.push(...(planned?.diagnostics ?? []));
|
|
266
268
|
writeSet =
|
|
267
269
|
modeled && subjectKey?.ok
|
|
268
270
|
? buildStrictWriteSet({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SubjectKeyRegistry } from "./requirement-claims.js";
|
|
1
2
|
import type { BootstrapEvidence, Candidate, SourceOnlySignal } from "./types.js";
|
|
2
3
|
export type CandidateBuildResult = {
|
|
3
4
|
readonly candidates: readonly Candidate[];
|
|
@@ -11,5 +12,5 @@ export type CandidateBuildResult = {
|
|
|
11
12
|
* covers recorder). A root README names no component.
|
|
12
13
|
*/
|
|
13
14
|
export declare function markdownComponentHint(relativePath: string): string | undefined;
|
|
14
|
-
export declare function markdownCandidates(item: BootstrapEvidence, existingIds: ReadonlySet<string>, minConfidence: number): CandidateBuildResult;
|
|
15
|
+
export declare function markdownCandidates(item: BootstrapEvidence, existingIds: ReadonlySet<string>, minConfidence: number, subjectKeys?: SubjectKeyRegistry): CandidateBuildResult;
|
|
15
16
|
//# sourceMappingURL=markdown-candidates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/markdown-candidates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/markdown-candidates.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CACnE,CAAC;AAyGF;;;;GAIG;AAEH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAYpB;AA4FD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,GAC/B,oBAAoB,CAoFtB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { buildStrictWriteSet } from "../../utils/strict-modeling.js";
|
|
3
3
|
import { bootstrapProvenance, confidenceBand, provenanceBody, provenanceRequirementBody, slug, strictPlan, upsert, withDocumentBody, } from "./candidate-helpers.js";
|
|
4
|
-
import { claimFor, normalizeClaimStatement,
|
|
4
|
+
import { claimFor, normalizeClaimStatement, planSubjectKey, } from "./requirement-claims.js";
|
|
5
5
|
function headingSignals(heading, sourcePath, textRef, minConfidence) {
|
|
6
6
|
const result = [];
|
|
7
7
|
for (const [kind, pattern, confidence] of [
|
|
@@ -102,7 +102,7 @@ export function markdownComponentHint(relativePath) {
|
|
|
102
102
|
}
|
|
103
103
|
return undefined;
|
|
104
104
|
}
|
|
105
|
-
function requirementCandidate(item, statement, line, heading, headingLine, existingIds, minConfidence) {
|
|
105
|
+
function requirementCandidate(item, statement, line, heading, headingLine, existingIds, minConfidence, subjectKeys, diagnostics) {
|
|
106
106
|
const relativePath = item.relativePath ?? item.label;
|
|
107
107
|
const base = /\bshall\b/i.test(statement)
|
|
108
108
|
? 0.86
|
|
@@ -119,7 +119,8 @@ function requirementCandidate(item, statement, line, heading, headingLine, exist
|
|
|
119
119
|
const claim = claimFor(statement, relativePath, confidence, `${relativePath}#L${line}`);
|
|
120
120
|
if (!claim)
|
|
121
121
|
return null;
|
|
122
|
-
const
|
|
122
|
+
const planned = planSubjectKey(claim.subjectKey, claim.propertyKey, markdownComponentHint(relativePath), subjectKeys, `${relativePath}#L${line}`);
|
|
123
|
+
const subjectKey = planned.resolution;
|
|
123
124
|
// Reported by the caller as an extraction failure with this reason,
|
|
124
125
|
// instead of writing a subject key outside component.aspect[.sub].
|
|
125
126
|
if (!subjectKey.ok)
|
|
@@ -130,6 +131,7 @@ function requirementCandidate(item, statement, line, heading, headingLine, exist
|
|
|
130
131
|
});
|
|
131
132
|
if (!writeSet.isStrict)
|
|
132
133
|
return null;
|
|
134
|
+
diagnostics.push(...planned.diagnostics);
|
|
133
135
|
return {
|
|
134
136
|
candidateId: `norm:${writeSet.req.id.toLowerCase()}`,
|
|
135
137
|
entityType: "req",
|
|
@@ -153,7 +155,7 @@ function requirementCandidate(item, statement, line, heading, headingLine, exist
|
|
|
153
155
|
};
|
|
154
156
|
}
|
|
155
157
|
// implements REQ-KIBI-BOOTSTRAP-PLAN
|
|
156
|
-
export function markdownCandidates(item, existingIds, minConfidence) {
|
|
158
|
+
export function markdownCandidates(item, existingIds, minConfidence, subjectKeys) {
|
|
157
159
|
const candidates = [];
|
|
158
160
|
const sourceOnlySignals = [];
|
|
159
161
|
const diagnostics = [];
|
|
@@ -182,7 +184,7 @@ export function markdownCandidates(item, existingIds, minConfidence) {
|
|
|
182
184
|
if (!statement || !/\b(must|shall|should)\b/i.test(statement))
|
|
183
185
|
continue;
|
|
184
186
|
try {
|
|
185
|
-
const candidate = requirementCandidate(item, statement, index + 1, heading, headingLine, existingIds, minConfidence);
|
|
187
|
+
const candidate = requirementCandidate(item, statement, index + 1, heading, headingLine, existingIds, minConfidence, subjectKeys, diagnostics);
|
|
186
188
|
if (candidate) {
|
|
187
189
|
if (!candidate.applyPlan.some((payload) => payload.type === "req" && existingIds.has(String(payload.id))))
|
|
188
190
|
candidates.push(candidate);
|
|
@@ -1,21 +1,79 @@
|
|
|
1
1
|
import { type SemanticClaim } from "../../utils/strict-modeling.js";
|
|
2
|
+
import type { Candidate } from "./types.js";
|
|
2
3
|
export declare function normalizeClaimStatement(statement: string): string;
|
|
3
4
|
export declare function claimFor(statement: string, source: string, confidence: number, provenance: string): SemanticClaim | null;
|
|
4
5
|
export type SubjectKeyResolution = {
|
|
5
6
|
readonly ok: true;
|
|
6
7
|
readonly subjectKey: string;
|
|
8
|
+
/** The key before its aspect was shortened, when it was. */
|
|
9
|
+
readonly shortenedFrom?: string;
|
|
7
10
|
} | {
|
|
8
11
|
readonly ok: false;
|
|
9
12
|
readonly reason: string;
|
|
10
13
|
};
|
|
14
|
+
/** The longest aspect a bootstrap key keeps as derived. */
|
|
15
|
+
export declare const MAX_ASPECT_WORDS = 4;
|
|
16
|
+
export declare const MAX_ASPECT_CHARS = 40;
|
|
17
|
+
/**
|
|
18
|
+
* A short noun-phrase aspect for a long one, deterministically: the words
|
|
19
|
+
* before the first clause boundary (when, while, for, and, ...), without
|
|
20
|
+
* leading or trailing stop words; if that is still longer than four words or
|
|
21
|
+
* forty characters, its content words (no stop words or -ly adverbs); if
|
|
22
|
+
* those are still too long, the first content word and the last two, where a
|
|
23
|
+
* noun phrase keeps its head noun. An aspect that already fits is returned
|
|
24
|
+
* unchanged.
|
|
25
|
+
*/
|
|
26
|
+
export declare function shortenSubjectAspect(aspect: string): string;
|
|
11
27
|
/**
|
|
12
28
|
* The bootstrap subject key in the component.aspect[.sub] shape that
|
|
13
29
|
* subject-key-shape checks. A subject that already has that shape is kept.
|
|
14
30
|
* Otherwise the component comes from the declared `component` (claim or
|
|
15
31
|
* knowledge source) and the aspect from the claim's subject; a one-word
|
|
16
32
|
* subject is itself the component and the constrained property becomes the
|
|
17
|
-
* aspect.
|
|
18
|
-
*
|
|
33
|
+
* aspect. An aspect longer than four words or forty characters is shortened
|
|
34
|
+
* to a noun phrase and the original key is returned in `shortenedFrom`. When
|
|
35
|
+
* no component can be named the claim is not resolved, so the caller reports
|
|
36
|
+
* it instead of writing a malformed key.
|
|
19
37
|
*/
|
|
20
38
|
export declare function resolveBootstrapSubjectKey(subject: string, propertyKey: string, component?: string): SubjectKeyResolution;
|
|
39
|
+
/**
|
|
40
|
+
* Keeps the subject keys of one bootstrap plan distinct. Claims about the
|
|
41
|
+
* same subject (the same full key) share a key; when shortening collapses two
|
|
42
|
+
* different subjects onto one key, the later one gets a third segment from
|
|
43
|
+
* its own wording (or a short digest) instead of colliding.
|
|
44
|
+
*/
|
|
45
|
+
export declare class SubjectKeyRegistry {
|
|
46
|
+
private readonly owners;
|
|
47
|
+
private readonly assigned;
|
|
48
|
+
/** The plan-wide key for a resolution, and the key it collided with, if any. */
|
|
49
|
+
assign(resolution: {
|
|
50
|
+
readonly subjectKey: string;
|
|
51
|
+
readonly shortenedFrom?: string;
|
|
52
|
+
}): {
|
|
53
|
+
readonly subjectKey: string;
|
|
54
|
+
readonly collidedWith?: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a claim's subject key for a plan and describe any renaming as a
|
|
59
|
+
* plan diagnostic, so the operator can pick a better name before applying.
|
|
60
|
+
*/
|
|
61
|
+
export declare function planSubjectKey(subject: string, propertyKey: string, component: string | undefined, registry: SubjectKeyRegistry | undefined, location: string): {
|
|
62
|
+
readonly resolution: SubjectKeyResolution;
|
|
63
|
+
readonly diagnostics: string[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* One subject fact per subject_key in a bootstrap plan. The registry keeps
|
|
67
|
+
* different subjects on different keys, so claims that share a key name the
|
|
68
|
+
* same subject: the first selected claim's subject fact is kept, every later
|
|
69
|
+
* requirement links to it through constrains instead of minting another
|
|
70
|
+
* subject fact (which subject-key-identity would report), and the later
|
|
71
|
+
* sources' provenance is added to the kept fact's tags and body. Each shared
|
|
72
|
+
* key is reported as a subject-key-shared diagnostic. The result depends only
|
|
73
|
+
* on the candidate order, so the plan hash stays deterministic.
|
|
74
|
+
*/
|
|
75
|
+
export declare function shareSubjectFacts(candidates: readonly Candidate[]): {
|
|
76
|
+
readonly candidates: Candidate[];
|
|
77
|
+
readonly diagnostics: string[];
|
|
78
|
+
};
|
|
21
79
|
//# sourceMappingURL=requirement-claims.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requirement-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/requirement-claims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requirement-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/requirement-claims.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED,wBAAgB,QAAQ,CACtB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,aAAa,GAAG,IAAI,CA0DtB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC,GACD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAWpD,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAsGnC;;;;;;;;GAQG;AAEH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA4B3D;AAmBD;;;;;;;;;;GAUG;AAEH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,oBAAoB,CA2BtB;AAED;;;;;GAKG;AAEH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAEtD,gFAAgF;IAChF,MAAM,CAAC,UAAU,EAAE;QACjB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;KACjC,GAAG;QAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE;CAyBpE;AAMD;;;GAGG;AAEH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EACxC,QAAQ,EAAE,MAAM,GACf;IACD,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;CAChC,CAyBA;AAuCD;;;;;;;;;GASG;AAEH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG;IACnE,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;CAChC,CAwEA"}
|