kibi-cli 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +3 -2
- package/dist/commands/aggregated-checks.d.ts +7 -0
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +25 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +21 -13
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +105 -24
- package/dist/commands/github-init.d.ts +1 -1
- package/dist/commands/github-init.d.ts.map +1 -1
- package/dist/commands/github-init.js +1 -1
- package/dist/commands/init-helpers.d.ts +17 -2
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +123 -23
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +110 -15
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +10 -18
- package/dist/commands/sync/cache.d.ts +20 -1
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +51 -2
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +1 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -3
- package/dist/engine.d.ts +26 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +126 -29
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +66 -28
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +14 -3
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +1 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +68 -29
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +4 -3
- package/dist/operations/modeling/model-requirement.d.ts +1 -1
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +176 -10
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +14 -2
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +24 -0
- package/dist/operations/modeling/predicate-types.d.ts +4 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
- package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-vocabulary.js +169 -0
- package/dist/operations/modeling/requirement-types.d.ts +5 -0
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
- package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
- package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
- package/dist/operations/modeling/vocabulary-alignment.js +178 -0
- package/dist/operations/mutation/contradictions.d.ts +3 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +29 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +33 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
- package/dist/operations/mutation/relationships.d.ts +1 -1
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +1 -0
- package/dist/operations/mutation/saga.d.ts +5 -0
- package/dist/operations/mutation/saga.d.ts.map +1 -1
- package/dist/operations/mutation/saga.js +10 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +2 -0
- package/dist/operations/mutation/source-authoring.d.ts +6 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +65 -26
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +5 -0
- package/dist/operations/mutation/types.d.ts +17 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +6 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +72 -4
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +24 -1
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +16 -3
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +61 -17
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +3 -1
- package/dist/operations/proof/code-scope.d.ts +17 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -0
- package/dist/operations/proof/code-scope.js +60 -0
- package/dist/operations/proof/ingest-proof.d.ts +4 -2
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +207 -74
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
- package/dist/operations/proof/migrate-legacy-receipts.js +7 -5
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +7 -5
- package/dist/plugins/compose-semantic-classifier.d.ts +6 -1
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -1
- package/dist/plugins/compose-semantic-classifier.js +8 -3
- package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
- package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
- package/dist/plugins/compose-vocabulary-alignment.js +141 -0
- package/dist/plugins/external-allowlist.d.ts +7 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -1
- package/dist/plugins/external-allowlist.js +13 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/registry.d.ts +2 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +22 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -0
- package/dist/prolog.d.ts +36 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +78 -9
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +7 -25
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +4 -12
- package/dist/public/operations/catalog.d.ts +36 -7
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +10 -2
- package/dist/public/operations/check-helpers.d.ts +6 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +21 -1
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +16 -0
- package/dist/public/operations/discovery-entities.d.ts +42 -2
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +195 -22
- package/dist/public/operations/discovery-executors.d.ts +1 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +75 -46
- package/dist/public/operations/migration-plan.d.ts +2 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +50 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
- package/dist/public/operations/predicate-schema-conformance.js +242 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +9 -3
- package/dist/public/operations/result-envelope.d.ts +34 -1
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +78 -2
- package/dist/public/operations/runtime-types.d.ts +1 -1
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +8 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +7 -1
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +7 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +21 -3
- package/dist/public/operations/specs/reporting.d.ts +8 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +46 -15
- package/dist/public/operations/specs/upsert.d.ts +28 -5
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +1 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +8 -3
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +22 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skills/kibi-usage/SKILL.md +7 -3
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +21 -5
- package/dist/relationships/shards.d.ts +6 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +26 -19
- package/dist/schemas/entity.schema.json +32 -0
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-entity-id-style.d.ts +12 -0
- package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
- package/dist/traceability/staged-entity-id-style.js +68 -0
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +8 -0
- package/dist/traceability/validate.js +1 -1
- package/dist/types/entities.d.ts +2 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/entity-id-style.d.ts +27 -0
- package/dist/utils/entity-id-style.d.ts.map +1 -0
- package/dist/utils/entity-id-style.js +81 -0
- package/dist/utils/git-repository-context.d.ts +50 -0
- package/dist/utils/git-repository-context.d.ts.map +1 -0
- package/dist/utils/git-repository-context.js +259 -0
- package/dist/utils/rule-registry.d.ts +5 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.d.ts +37 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +44 -0
- package/dist/utils/strict-modeling.d.ts +7 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +11 -0
- package/package.json +4 -4
- package/schema/entities.pl +60 -1
- package/schema/relationships.pl +17 -4
- package/schema/validation.pl +118 -20
- package/src/public/diagnostic-usage.ts +16 -24
- package/src/public/impact/full-kb-quality.ts +4 -16
- package/src/public/operations/check-executor.ts +12 -1
- package/src/public/operations/check-helpers.ts +27 -1
- package/src/public/operations/contracts.ts +19 -0
- package/src/public/operations/discovery-entities.ts +292 -23
- package/src/public/operations/discovery-executors.ts +91 -55
- package/src/public/operations/migration-plan.ts +57 -0
- package/src/public/operations/predicate-schema-conformance.ts +362 -0
- package/src/public/operations/prolog-json.ts +9 -3
- package/src/public/operations/result-envelope.ts +114 -2
- package/src/public/operations/runtime-types.ts +1 -1
- package/src/public/operations/specs/check-rules.generated.ts +8 -1
- package/src/public/operations/specs/discovery.ts +8 -1
- package/src/public/operations/specs/mutation-schemas.ts +23 -3
- package/src/public/operations/specs/reporting.ts +69 -22
- package/src/public/operations/specs/upsert.ts +1 -1
- package/src/public/operations/symbol-repair-plan.ts +13 -3
- package/src/public/schemas/entity.ts +22 -0
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skills/kibi-usage/SKILL.md +7 -3
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/src/public/telemetry-acceptance.ts +37 -6
- package/src/schemas/entity.schema.json +32 -0
- package/src/schemas/relationship.schema.json +1 -0
package/dist/intent-search.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { escapeAtom, normalizeEntityId, parseTriples } from "./prolog/codec.js";
|
|
3
|
-
import { loadEntities, loadSearchCandidates, } from "./public/operations/discovery-entities.js";
|
|
3
|
+
import { SEARCH_CANDIDATE_PAGE_SIZE, listSearchCandidates, loadEntities, loadSearchCandidates, } from "./public/operations/discovery-entities.js";
|
|
4
4
|
import { loadMarkdownBody } from "./search-ranking.js";
|
|
5
5
|
const GRAPH_RELATIONSHIPS = [
|
|
6
6
|
"implements",
|
|
@@ -343,41 +343,80 @@ async function loadIntentCandidates(prolog, options) {
|
|
|
343
343
|
...facetValues(options.semanticFacets).map((facet) => facet.value),
|
|
344
344
|
].filter((term, index, all) => term.trim() && all.indexOf(term) === index);
|
|
345
345
|
const candidates = new Map();
|
|
346
|
-
|
|
347
|
-
(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
...(options.type !== undefined ? { type: options.type } : {}),
|
|
353
|
-
maxCandidates: MAX_CANDIDATES,
|
|
354
|
-
});
|
|
355
|
-
for (const entity of page) {
|
|
356
|
-
candidates.set(`${String(entity.type ?? "")}::${String(entity.id ?? "")}`, { ...entity });
|
|
357
|
-
}
|
|
346
|
+
const addCandidates = (entities) => {
|
|
347
|
+
for (const entity of entities) {
|
|
348
|
+
const key = `${String(entity.type ?? "")}::${String(entity.id ?? "")}`;
|
|
349
|
+
if (!candidates.has(key) && candidates.size >= MAX_CANDIDATES)
|
|
350
|
+
break;
|
|
351
|
+
candidates.set(key, { ...entity });
|
|
358
352
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
353
|
+
};
|
|
354
|
+
const sourceLocations = options.sourceLocations ?? [];
|
|
355
|
+
if (sourceLocations.length > 0 && prolog.queryEntities) {
|
|
356
|
+
for (const location of sourceLocations) {
|
|
357
|
+
if (candidates.size >= MAX_CANDIDATES)
|
|
358
|
+
break;
|
|
359
|
+
let offset = 0;
|
|
360
|
+
let total = Number.POSITIVE_INFINITY;
|
|
361
|
+
while (offset < total && candidates.size < MAX_CANDIDATES) {
|
|
362
|
+
const limit = Math.min(SEARCH_CANDIDATE_PAGE_SIZE, MAX_CANDIDATES - candidates.size);
|
|
363
|
+
const page = await prolog.queryEntities({
|
|
364
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
365
|
+
sourceFile: location.path,
|
|
366
|
+
limit,
|
|
367
|
+
offset,
|
|
368
|
+
});
|
|
369
|
+
if (page.entities.length === 0)
|
|
370
|
+
break;
|
|
371
|
+
addCandidates(page.entities);
|
|
372
|
+
total = page.count;
|
|
373
|
+
offset += page.entities.length;
|
|
368
374
|
}
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
377
|
+
// Lexical candidates are projected rows (no receipt histories or other
|
|
378
|
+
// large structured properties); ports without the engine method run the
|
|
379
|
+
// same bounded Prolog search through `query`.
|
|
380
|
+
for (const term of terms) {
|
|
381
|
+
if (candidates.size >= MAX_CANDIDATES)
|
|
382
|
+
break;
|
|
383
|
+
const page = await loadSearchCandidates(prolog, {
|
|
384
|
+
query: term,
|
|
385
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
386
|
+
maxCandidates: MAX_CANDIDATES - candidates.size,
|
|
387
|
+
});
|
|
388
|
+
addCandidates(page);
|
|
389
|
+
}
|
|
390
|
+
if (!prolog.searchEntities && sourceLocations.length === 0) {
|
|
391
|
+
addCandidates(await listSearchCandidates(prolog, {
|
|
392
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
393
|
+
maxCandidates: MAX_CANDIDATES,
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
else if (sourceLocations.length > 0 && !prolog.queryEntities) {
|
|
397
|
+
for (const location of sourceLocations) {
|
|
398
|
+
if (candidates.size >= MAX_CANDIDATES)
|
|
399
|
+
break;
|
|
400
|
+
addCandidates(await loadEntities(prolog, {
|
|
401
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
402
|
+
sourceFile: location.path,
|
|
403
|
+
}));
|
|
375
404
|
}
|
|
376
405
|
}
|
|
377
|
-
|
|
378
|
-
|
|
406
|
+
// An unfamiliar host-agent alias may not exist in the lexical index at all.
|
|
407
|
+
// For small facet-bearing corpora, scan the bounded entity set so a zero
|
|
408
|
+
// lexical hit does not turn a valid semantic query into a false abstention.
|
|
409
|
+
// Source-located searches stay on their source-indexed candidate set.
|
|
410
|
+
if (prolog.searchEntities &&
|
|
411
|
+
sourceLocations.length === 0 &&
|
|
412
|
+
facetValues(options.semanticFacets).length > 0 &&
|
|
413
|
+
candidates.size < 20) {
|
|
414
|
+
addCandidates(await listSearchCandidates(prolog, {
|
|
415
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
416
|
+
maxCandidates: MAX_CANDIDATES,
|
|
417
|
+
}));
|
|
379
418
|
}
|
|
380
|
-
return Array.from(candidates.values());
|
|
419
|
+
return Array.from(candidates.values()).slice(0, MAX_CANDIDATES);
|
|
381
420
|
}
|
|
382
421
|
// implements REQ-kibi-intent-aware-source-discovery
|
|
383
422
|
export async function executeIntentSearch(options, prolog, workspaceRoot) {
|
|
@@ -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;AAKjF,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA2BD,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;CACnE,CAiDA;
|
|
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;AAKjF,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA2BD,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;CACnE,CAiDA;AA+GD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAyD9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
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 { buildBootstrapCandidates } from "./candidates.js";
|
|
@@ -81,8 +81,9 @@ async function existingEntityIds(context) {
|
|
|
81
81
|
if (!context.prolog)
|
|
82
82
|
return new Set();
|
|
83
83
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
// Ids only: materializing every entity (receipt histories included)
|
|
85
|
+
// just to build this set exceeds the bounded engine output.
|
|
86
|
+
return new Set((await loadEntityIds(context.prolog)).filter(Boolean));
|
|
86
87
|
}
|
|
87
88
|
catch {
|
|
88
89
|
return new Set();
|
|
@@ -10,6 +10,6 @@ export declare function annotateModelRequirementStep(step: Record<string, unknow
|
|
|
10
10
|
logicClaims: string[];
|
|
11
11
|
}): Record<string, unknown>;
|
|
12
12
|
export declare function getWorkspaceMigrationWarning(workspaceRoot: string): Promise<string | null>;
|
|
13
|
-
export declare function handleKbModelRequirement(_prolog: unknown, args: ModelRequirementArgs, workspaceRoot: string): Promise<ModelRequirementResult>;
|
|
13
|
+
export declare function handleKbModelRequirement(_prolog: unknown, args: ModelRequirementArgs, workspaceRoot: string, context?: OperationContext): Promise<ModelRequirementResult>;
|
|
14
14
|
export declare function executeModelRequirement(args: ModelRequirementArgs, context: OperationContext): Promise<ModelRequirementResult>;
|
|
15
15
|
//# sourceMappingURL=model-requirement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-requirement.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/model-requirement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-requirement.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/model-requirement.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAYjF,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAUhC,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAkNhC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GACxB,CAAC;AAIF,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,GACA,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgDzB;AAED,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIxB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,oBAAoB,EAC1B,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,sBAAsB,CAAC,CAoIjC;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,oBAAoB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAajC"}
|
|
@@ -1,11 +1,167 @@
|
|
|
1
|
-
import { buildStrictWriteSet } from "../../public/check-types.js";
|
|
1
|
+
import { buildStrictWriteSet, } from "../../public/check-types.js";
|
|
2
2
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
3
|
+
import { isConventionalSubjectKey, normalizeSubjectKey, } from "../../utils/strict-modeling.js";
|
|
3
4
|
import { normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
|
|
4
5
|
import { semanticSourceHash } from "../semantic-advisor/shared.js";
|
|
5
6
|
import { buildLogicApplyPlan } from "./logic-modeling.js";
|
|
6
7
|
import { strictWriteSetToApplyPlan, writeSetPrimaryEntityId, } from "./requirement-applyplan.js";
|
|
7
8
|
import { estimateNormativeSignalConfidence, extractRequirementClaim, } from "./requirement-modeler.js";
|
|
8
9
|
import { normalizeOptionalString, normalizeSourceFiles, } from "./requirement-utils.js";
|
|
10
|
+
import { alignRequirementVocabulary, } from "./vocabulary-alignment.js";
|
|
11
|
+
const NEW_SUBJECT_REVIEW_SCORE = 0.3;
|
|
12
|
+
function reuseExistingSubject(writeSet, existingFactId) {
|
|
13
|
+
if (!writeSet.isStrict)
|
|
14
|
+
return { writeSet, replacedSubjectId: null };
|
|
15
|
+
const replacedSubjectId = writeSet.subjectFact.id;
|
|
16
|
+
return {
|
|
17
|
+
replacedSubjectId,
|
|
18
|
+
writeSet: {
|
|
19
|
+
...writeSet,
|
|
20
|
+
subjectFact: {
|
|
21
|
+
...writeSet.subjectFact,
|
|
22
|
+
id: existingFactId,
|
|
23
|
+
properties: { ...writeSet.subjectFact.properties, id: existingFactId },
|
|
24
|
+
},
|
|
25
|
+
relationships: writeSet.relationships.map((relationship) => relationship.type === "constrains"
|
|
26
|
+
? { ...relationship, to: existingFactId }
|
|
27
|
+
: relationship),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function possibleDuplicateObservation(claimKey, statement, source, candidates) {
|
|
32
|
+
const id = `FACT-OBS-POSSIBLE-DUPLICATE-${claimKey.replace(/^CLAIM-/, "")}`;
|
|
33
|
+
return {
|
|
34
|
+
type: "fact",
|
|
35
|
+
id,
|
|
36
|
+
properties: {
|
|
37
|
+
id,
|
|
38
|
+
title: `Possible duplicate: ${statement}`,
|
|
39
|
+
status: "active",
|
|
40
|
+
source,
|
|
41
|
+
fact_kind: "observation",
|
|
42
|
+
tags: ["review:possible-duplicate", "vocabulary-alignment"],
|
|
43
|
+
},
|
|
44
|
+
relationships: candidates.map((candidate) => ({
|
|
45
|
+
type: "relates_to",
|
|
46
|
+
from: id,
|
|
47
|
+
to: candidate.factId,
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the clause subject against the existing KB vocabulary. A heuristic
|
|
53
|
+
* subject converges onto the chosen existing subject; an explicitly provided
|
|
54
|
+
* subject is kept (the caller owns it) but reuses the existing subject fact
|
|
55
|
+
* when the keys match. Otherwise the plan explicitly declares a new subject.
|
|
56
|
+
*/
|
|
57
|
+
// implements REQ-kibi-subject-vocabulary
|
|
58
|
+
async function applyVocabularyAlignment(context, extracted, claimKey) {
|
|
59
|
+
const initial = buildStrictWriteSet({
|
|
60
|
+
claim: extracted.claim,
|
|
61
|
+
statement: extracted.statement,
|
|
62
|
+
});
|
|
63
|
+
const unchanged = {
|
|
64
|
+
writeSet: initial,
|
|
65
|
+
outcome: null,
|
|
66
|
+
warnings: [],
|
|
67
|
+
reviewPlan: [],
|
|
68
|
+
adjustPlan: (plan) => plan,
|
|
69
|
+
};
|
|
70
|
+
if (!context?.prolog || !initial.isStrict)
|
|
71
|
+
return unchanged;
|
|
72
|
+
const proposedSubjectKey = normalizeSubjectKey(extracted.claim.subjectKey);
|
|
73
|
+
const outcome = await alignRequirementVocabulary(context, {
|
|
74
|
+
claimKey,
|
|
75
|
+
statement: extracted.statement,
|
|
76
|
+
proposedSubjectKey,
|
|
77
|
+
});
|
|
78
|
+
if (outcome === null)
|
|
79
|
+
return unchanged;
|
|
80
|
+
const warnings = [];
|
|
81
|
+
let writeSet = initial;
|
|
82
|
+
let replacedSubjectId = null;
|
|
83
|
+
const subject = outcome.subject;
|
|
84
|
+
if (subject.decision === "reuse_existing" && subject.existingFactId) {
|
|
85
|
+
const followsVocabulary = extracted.extractionMode !== "provided" ||
|
|
86
|
+
proposedSubjectKey === subject.subjectKey;
|
|
87
|
+
if (followsVocabulary) {
|
|
88
|
+
const rebuilt = buildStrictWriteSet({
|
|
89
|
+
claim: { ...extracted.claim, subjectKey: subject.subjectKey },
|
|
90
|
+
statement: extracted.statement,
|
|
91
|
+
});
|
|
92
|
+
({ writeSet, replacedSubjectId } = reuseExistingSubject(rebuilt, subject.existingFactId));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
warnings.push({
|
|
96
|
+
kind: "subject_reuse_review",
|
|
97
|
+
message: `Provided subjectKey ${proposedSubjectKey} is new, but existing subject ${subject.subjectKey} (${subject.existingFactId}) matches this clause.`,
|
|
98
|
+
nextAction: `Reuse subjectKey ${subject.subjectKey} so this requirement can be compared with the others on that subject, or keep ${proposedSubjectKey} if it is genuinely a different component.`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (!isConventionalSubjectKey(subject.subjectKey)) {
|
|
104
|
+
warnings.push({
|
|
105
|
+
kind: "subject_key_shape_review",
|
|
106
|
+
message: `New subject key ${subject.subjectKey} does not follow the component.aspect[.sub] convention checked by subject-key-shape.`,
|
|
107
|
+
nextAction: "Pass subjectKey as a dotted key with lowercase snake segments (for example kibi.cli.gc) so later requirements about the same component can reuse it.",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const nearest = subject.candidates[0];
|
|
111
|
+
if (nearest && nearest.score >= NEW_SUBJECT_REVIEW_SCORE) {
|
|
112
|
+
warnings.push({
|
|
113
|
+
kind: "new_subject_declared",
|
|
114
|
+
message: `Declaring new subject ${subject.subjectKey}; nearest existing subject is ${nearest.subjectKey} (score ${nearest.score}).`,
|
|
115
|
+
nextAction: "Confirm the new subject is a different component, or pass subjectKey set to the existing subject to reuse it.",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const reviewPlan = outcome.redundancyCandidates.length > 0
|
|
120
|
+
? [
|
|
121
|
+
possibleDuplicateObservation(claimKey, extracted.statement, extracted.source, outcome.redundancyCandidates),
|
|
122
|
+
]
|
|
123
|
+
: [];
|
|
124
|
+
if (outcome.redundancyCandidates.length > 0) {
|
|
125
|
+
warnings.push({
|
|
126
|
+
kind: "possible_duplicate",
|
|
127
|
+
message: `This clause may restate existing claim(s) ${outcome.redundancyCandidates
|
|
128
|
+
.map((candidate) => candidate.factId)
|
|
129
|
+
.join(", ")} on ${subject.subjectKey}.`,
|
|
130
|
+
nextAction: "Review the candidates: reuse the existing fact, supersede or restate the existing requirement, or record the returned review:possible-duplicate observation. This is advice, not a check verdict.",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const declaredNew = subject.decision === "declare_new";
|
|
134
|
+
return {
|
|
135
|
+
writeSet,
|
|
136
|
+
outcome,
|
|
137
|
+
warnings,
|
|
138
|
+
reviewPlan,
|
|
139
|
+
adjustPlan: (plan) => plan
|
|
140
|
+
.filter((step) => !(replacedSubjectId !== null &&
|
|
141
|
+
writeSet.isStrict &&
|
|
142
|
+
step.id === writeSet.subjectFact.id &&
|
|
143
|
+
step.type === "fact" &&
|
|
144
|
+
step.properties
|
|
145
|
+
?.fact_kind === "subject"))
|
|
146
|
+
.map((step) => {
|
|
147
|
+
if (!declaredNew ||
|
|
148
|
+
step.type !== "fact" ||
|
|
149
|
+
step.properties
|
|
150
|
+
?.fact_kind !== "subject") {
|
|
151
|
+
return step;
|
|
152
|
+
}
|
|
153
|
+
const properties = step.properties;
|
|
154
|
+
const tags = Array.isArray(properties.tags) ? properties.tags : [];
|
|
155
|
+
return {
|
|
156
|
+
...step,
|
|
157
|
+
properties: {
|
|
158
|
+
...properties,
|
|
159
|
+
tags: [...tags, "vocabulary:new-subject"],
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
9
165
|
export { estimateNormativeSignalConfidence, extractRequirementClaim, strictWriteSetToApplyPlan, writeSetPrimaryEntityId, };
|
|
10
166
|
// implements REQ-kibi-logical-requirement-coverage
|
|
11
167
|
// covered_by TEST-kibi-logical-requirement-coverage
|
|
@@ -61,7 +217,7 @@ export async function getWorkspaceMigrationWarning(workspaceRoot) {
|
|
|
61
217
|
return null;
|
|
62
218
|
return status.warning;
|
|
63
219
|
}
|
|
64
|
-
export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
|
|
220
|
+
export async function handleKbModelRequirement(_prolog, args, workspaceRoot, context) {
|
|
65
221
|
const extracted = extractRequirementClaim({
|
|
66
222
|
...args,
|
|
67
223
|
source: normalizeOptionalString(args.source) ??
|
|
@@ -123,20 +279,20 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
|
|
|
123
279
|
migrationWarning,
|
|
124
280
|
};
|
|
125
281
|
}
|
|
126
|
-
const writeSet = buildStrictWriteSet({
|
|
127
|
-
claim: extracted.claim,
|
|
128
|
-
statement: extracted.statement,
|
|
129
|
-
});
|
|
130
282
|
const claimKey = semanticClaimKey(extracted.statement);
|
|
283
|
+
const aligned = await applyVocabularyAlignment(context, extracted, claimKey);
|
|
284
|
+
const writeSet = aligned.writeSet;
|
|
131
285
|
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
132
|
-
const applyPlan =
|
|
286
|
+
const applyPlan = aligned
|
|
287
|
+
.adjustPlan(strictWriteSetToApplyPlan(writeSet))
|
|
288
|
+
.map((step) => annotateModelRequirementStep(step, {
|
|
133
289
|
claimKey,
|
|
134
290
|
statement: extracted.statement,
|
|
135
291
|
logicClaims,
|
|
136
292
|
}));
|
|
137
293
|
const migrationWarning = await getWorkspaceMigrationWarning(workspaceRoot);
|
|
138
294
|
const warnings = writeSet.isStrict
|
|
139
|
-
? []
|
|
295
|
+
? [...aligned.warnings]
|
|
140
296
|
: [
|
|
141
297
|
{
|
|
142
298
|
kind: "low_confidence_observation_downgrade",
|
|
@@ -162,6 +318,14 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
|
|
|
162
318
|
extractionWarnings: extracted.extractionWarnings,
|
|
163
319
|
warnings,
|
|
164
320
|
migrationWarning,
|
|
321
|
+
...(aligned.outcome !== null
|
|
322
|
+
? {
|
|
323
|
+
vocabularyAlignment: {
|
|
324
|
+
...aligned.outcome,
|
|
325
|
+
reviewPlan: aligned.reviewPlan,
|
|
326
|
+
},
|
|
327
|
+
}
|
|
328
|
+
: {}),
|
|
165
329
|
};
|
|
166
330
|
return {
|
|
167
331
|
content: [
|
|
@@ -182,6 +346,8 @@ export async function executeModelRequirement(args, context) {
|
|
|
182
346
|
// kb_model_requirement is intentionally off the external semantic-classifier
|
|
183
347
|
// allowlist: classification after modeling only produced provenance warnings
|
|
184
348
|
// and is not worth a metered provider call. Use kb_semantic_advisor when
|
|
185
|
-
// classifier routing is needed.
|
|
186
|
-
|
|
349
|
+
// classifier routing is needed. It is on the vocabulary-alignment allowlist:
|
|
350
|
+
// choosing an existing subject is exactly the modeling-time decision that
|
|
351
|
+
// provider is for, and it only runs when explicitly activated.
|
|
352
|
+
return handleKbModelRequirement(context.prolog, args, context.workspaceRoot, context);
|
|
187
353
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAQ9B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,EACvD,YAAY,CAAC,EAAE,QAAQ,GAAG,MAAM,EAChC,WAAW,CAAC,EAAE;IACZ,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACtC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GACA,mBAAmB,CA8FrB;AAGD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqChC;AAGD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAwBhC;AAGD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+BhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,0BAA0B,CAoE5B"}
|
|
@@ -4,16 +4,27 @@ import { aggregateBindingProvenance, bindingCanBeApplied, classifyBinding, isGen
|
|
|
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
|
+
import { applyArgumentRewrites, predicateArgumentConformance, } from "./predicate-vocabulary.js";
|
|
7
8
|
// implements REQ-mcp-suggest-predicates
|
|
8
9
|
export function buildSuggestion(schema, text, subject, score, argumentBindings = {}, polarityHint, diagnostics) {
|
|
9
10
|
const inferredArgs = inferArgs(schema, text, subject);
|
|
10
11
|
const canonicalLauncherArgs = exactLauncherPredicateArgs(schema.predicate_name, text);
|
|
11
|
-
const
|
|
12
|
+
const boundArgs = schema.argument_names.map((name, index) => {
|
|
12
13
|
const exactBinding = argumentBindings[name];
|
|
13
14
|
return typeof exactBinding === "string" && exactBinding.trim().length > 0
|
|
14
15
|
? exactBinding.trim()
|
|
15
16
|
: (inferredArgs[index] ?? "unknown");
|
|
16
17
|
});
|
|
18
|
+
// A schema with closed argument vocabularies only accepts its declared
|
|
19
|
+
// constants: aliases converge onto the constant, anything else stays
|
|
20
|
+
// unbound so the plan asks for a declared value instead of minting an atom.
|
|
21
|
+
const vocabulary = {
|
|
22
|
+
constants: schema.argument_constants ?? {},
|
|
23
|
+
aliases: schema.argument_aliases ?? {},
|
|
24
|
+
};
|
|
25
|
+
const conformance = predicateArgumentConformance(schema.argument_names, boundArgs, vocabulary);
|
|
26
|
+
const predicateArgs = applyArgumentRewrites(boundArgs, conformance.rewrites);
|
|
27
|
+
const undeclaredArguments = new Set(conformance.undeclared.map((value) => value.argumentName));
|
|
17
28
|
const bindingProvenanceByArgument = Object.fromEntries(schema.argument_names.map((name, index) => [
|
|
18
29
|
name,
|
|
19
30
|
classifyBinding(predicateArgs[index] ?? "unknown", text, (typeof argumentBindings[name] === "string" &&
|
|
@@ -25,7 +36,8 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
25
36
|
typeof argumentBindings[name] !== "string")),
|
|
26
37
|
]));
|
|
27
38
|
const bindingProvenance = aggregateBindingProvenance(Object.values(bindingProvenanceByArgument));
|
|
28
|
-
const unboundArguments = schema.argument_names.filter((name) =>
|
|
39
|
+
const unboundArguments = schema.argument_names.filter((name) => undeclaredArguments.has(name) ||
|
|
40
|
+
!bindingCanBeApplied(bindingProvenanceByArgument[name] ?? "placeholder"));
|
|
29
41
|
const canonicalKey = `${schema.predicate_name}(${predicateArgs.join(",")})`;
|
|
30
42
|
// Permission-style inference carries the deontic decision as its final
|
|
31
43
|
// argument. Preserve that polarity in the typed suggestion instead of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-loader.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAK3E,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-loader.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAK3E,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAExE;AAGD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CACxE,wBAAwB,EACxB,UAAU,CACX,GAAG;IACF,WAAW,EAAE,mBAAmB,CAAC;CAClC,CA4BA;AAGD,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,sBAAsB,EAAE,OAAO,EAC/B,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAwBrC;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,wBAAwB,EAAE,CAwD5B;AAGD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,mBAAmB,GAAG,SAAS,CAOjC;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAQpD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseEntityFromList, parseListOfLists } from "../../prolog/codec.js";
|
|
2
2
|
import { DEFAULT_USAGE_HINTS, USAGE_HINTS_BY_PREDICATE, } from "./predicate-catalog.js";
|
|
3
3
|
import { hashId, normalizeOptionalString } from "./predicate-utils.js";
|
|
4
|
+
import { predicateVocabularyFromEntity } from "./predicate-vocabulary.js";
|
|
4
5
|
export function optionalPredicateName(value) {
|
|
5
6
|
return typeof value === "string" ? value : undefined;
|
|
6
7
|
}
|
|
@@ -16,6 +17,12 @@ export function schemaForCandidate(schema) {
|
|
|
16
17
|
...(schema.argument_descriptions
|
|
17
18
|
? { argument_descriptions: schema.argument_descriptions }
|
|
18
19
|
: {}),
|
|
20
|
+
...(schema.argument_constants
|
|
21
|
+
? { argument_constants: schema.argument_constants }
|
|
22
|
+
: {}),
|
|
23
|
+
...(schema.argument_aliases
|
|
24
|
+
? { argument_aliases: schema.argument_aliases }
|
|
25
|
+
: {}),
|
|
19
26
|
...(schema.aliases ? { aliases: schema.aliases } : {}),
|
|
20
27
|
...(schema.paraphrase_templates
|
|
21
28
|
? { paraphrase_templates: schema.paraphrase_templates }
|
|
@@ -57,6 +64,7 @@ export function predicateSchemaFromEntity(entity) {
|
|
|
57
64
|
return [];
|
|
58
65
|
const usageHints = usageHintsFromEntity(entity);
|
|
59
66
|
const argumentDescriptions = stringArray(entity.argument_descriptions);
|
|
67
|
+
const vocabulary = predicateVocabularyFromEntity(entity);
|
|
60
68
|
return [
|
|
61
69
|
{
|
|
62
70
|
id: String(entity.id ?? hashId("FACT-SCHEMA", [predicateName])),
|
|
@@ -69,6 +77,22 @@ export function predicateSchemaFromEntity(entity) {
|
|
|
69
77
|
...(argumentDescriptions.length > 0
|
|
70
78
|
? { argument_descriptions: argumentDescriptions }
|
|
71
79
|
: {}),
|
|
80
|
+
...(Object.keys(vocabulary.constants).length > 0
|
|
81
|
+
? {
|
|
82
|
+
argument_constants: Object.fromEntries(Object.entries(vocabulary.constants).map(([name, values]) => [
|
|
83
|
+
name,
|
|
84
|
+
[...values],
|
|
85
|
+
])),
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
...(Object.keys(vocabulary.aliases).length > 0
|
|
89
|
+
? {
|
|
90
|
+
argument_aliases: Object.fromEntries(Object.entries(vocabulary.aliases).map(([name, mapping]) => [
|
|
91
|
+
name,
|
|
92
|
+
{ ...mapping },
|
|
93
|
+
])),
|
|
94
|
+
}
|
|
95
|
+
: {}),
|
|
72
96
|
keywords: [
|
|
73
97
|
predicateName,
|
|
74
98
|
...stringArray(entity.aliases),
|
|
@@ -12,6 +12,10 @@ export interface PredicateSchemaCandidate {
|
|
|
12
12
|
argument_types: string[];
|
|
13
13
|
/** Optional human-readable descriptions aligned with argument_names. */
|
|
14
14
|
argument_descriptions?: string[];
|
|
15
|
+
/** Closed vocabularies: allowed constants keyed by argument name. */
|
|
16
|
+
argument_constants?: Record<string, string[]>;
|
|
17
|
+
/** Legacy spellings keyed by argument name, each mapped to a constant. */
|
|
18
|
+
argument_aliases?: Record<string, Record<string, string>>;
|
|
15
19
|
keywords: string[];
|
|
16
20
|
/** Human-language aliases and controlled paraphrase templates used for deterministic retrieval. */
|
|
17
21
|
aliases?: string[];
|
|
@@ -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,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AAGD,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO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AM,EAAE,MAAM,CAAC,CAAC;IAC3C,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,uBAAuB;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,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,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closed argument vocabularies for predicate schemas.
|
|
3
|
+
*
|
|
4
|
+
* A `predicate_schema` may declare, per argument name, the constants that
|
|
5
|
+
* argument accepts (`argument_constants`) and legacy spellings that map onto
|
|
6
|
+
* one of them (`argument_aliases`). Arguments without an entry stay open.
|
|
7
|
+
* Declaring constants is what makes paraphrased claims converge: two facts
|
|
8
|
+
* can only share a ground term when they use the same atoms.
|
|
9
|
+
*/
|
|
10
|
+
export type PredicateVocabulary = Readonly<{
|
|
11
|
+
constants: Readonly<Record<string, readonly string[]>>;
|
|
12
|
+
aliases: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
13
|
+
}>;
|
|
14
|
+
export type ArgumentRewrite = Readonly<{
|
|
15
|
+
index: number;
|
|
16
|
+
argumentName: string;
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
}>;
|
|
20
|
+
export type UndeclaredArgument = Readonly<{
|
|
21
|
+
index: number;
|
|
22
|
+
argumentName: string;
|
|
23
|
+
value: string;
|
|
24
|
+
allowed: readonly string[];
|
|
25
|
+
}>;
|
|
26
|
+
export type ArgumentConformance = Readonly<{
|
|
27
|
+
/** Alias spellings with their declared canonical constant. */
|
|
28
|
+
rewrites: readonly ArgumentRewrite[];
|
|
29
|
+
/** Values that are neither a declared constant nor an alias. */
|
|
30
|
+
undeclared: readonly UndeclaredArgument[];
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Read a schema's vocabulary. Malformed entries are ignored here; use
|
|
34
|
+
* {@link predicateVocabularyErrors} to report them.
|
|
35
|
+
*/
|
|
36
|
+
export declare function predicateVocabularyFromEntity(entity: Readonly<Record<string, unknown>>): PredicateVocabulary;
|
|
37
|
+
export declare function hasPredicateVocabulary(vocabulary: PredicateVocabulary): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Cross-field errors in a predicate schema's vocabulary: every key must be an
|
|
40
|
+
* argument name, aliases need declared constants for their argument, alias
|
|
41
|
+
* targets must be declared, and an alias may not shadow a constant.
|
|
42
|
+
*/
|
|
43
|
+
export declare function predicateVocabularyErrors(entity: Readonly<Record<string, unknown>>): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Compare predicate arguments with a schema vocabulary. Open arguments always
|
|
46
|
+
* conform; an alias is reported as a rewrite, anything else not declared is
|
|
47
|
+
* reported as undeclared.
|
|
48
|
+
*/
|
|
49
|
+
export declare function predicateArgumentConformance(argumentNames: readonly string[], args: readonly string[], vocabulary: PredicateVocabulary): ArgumentConformance;
|
|
50
|
+
/** Arguments with every alias replaced by its declared constant. */
|
|
51
|
+
export declare function applyArgumentRewrites(args: readonly string[], rewrites: readonly ArgumentRewrite[]): string[];
|
|
52
|
+
/** Canonical key convention shared with predicate apply plans. */
|
|
53
|
+
export declare function predicateCanonicalKey(predicateName: string, args: readonly string[]): string;
|
|
54
|
+
//# sourceMappingURL=predicate-vocabulary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicate-vocabulary.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-vocabulary.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AAGH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACrE,CAAC,CAAC;AAGH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC,CAAC;AAGH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,CAAC,CAAC;AAGH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,8DAA8D;IAC9D,QAAQ,EAAE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