kibi-cli 2.14.0 → 2.16.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-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +16 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +5 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +83 -4
- package/dist/commands/prove.js +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +5 -2
- package/dist/operations/bootstrap/discovery.d.ts.map +1 -1
- package/dist/operations/bootstrap/discovery.js +6 -1
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +1 -0
- package/dist/operations/bootstrap/guidance-actions.d.ts +2 -1
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +10 -1
- package/dist/operations/bootstrap/guidance.d.ts +2 -0
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +1 -1
- package/dist/operations/bootstrap/plugin-offers.d.ts +16 -0
- package/dist/operations/bootstrap/plugin-offers.d.ts.map +1 -0
- package/dist/operations/bootstrap/plugin-offers.js +66 -0
- package/dist/operations/bootstrap/presentation.d.ts +2 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +2 -0
- package/dist/operations/bootstrap/types.d.ts +2 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.d.ts +5 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +17 -5
- package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applicability.js +27 -1
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +16 -6
- package/dist/operations/modeling/predicate-binding-hints.d.ts +10 -0
- package/dist/operations/modeling/predicate-binding-hints.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-binding-hints.js +74 -0
- package/dist/operations/modeling/predicate-catalog-5.d.ts +2 -2
- package/dist/operations/modeling/predicate-catalog-5.js +2 -2
- package/dist/operations/modeling/predicate-catalog-6.d.ts +9 -0
- package/dist/operations/modeling/predicate-catalog-6.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-6.js +106 -0
- package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog.js +2 -0
- package/dist/operations/modeling/predicate-usage-hints-4.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-usage-hints-4.js +32 -0
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +32 -11
- package/dist/operations/mutation/contradictions.d.ts +8 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +13 -0
- package/dist/operations/mutation/source-authoring.d.ts +13 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +70 -2
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +9 -3
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +30 -4
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +15 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.js +20 -1
- package/dist/plugins/approved-source-analyzers.generated.d.ts +5 -5
- package/dist/plugins/approved-source-analyzers.generated.js +5 -5
- package/dist/plugins/check-policies.d.ts +24 -0
- package/dist/plugins/check-policies.d.ts.map +1 -0
- package/dist/plugins/check-policies.js +73 -0
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +10 -1
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +8 -1
- package/dist/proof/inspect.d.ts +18 -1
- package/dist/proof/inspect.d.ts.map +1 -1
- package/dist/proof/inspect.js +17 -8
- package/dist/proof/integration-plan.d.ts +57 -0
- package/dist/proof/integration-plan.d.ts.map +1 -0
- package/dist/proof/integration-plan.js +331 -0
- package/dist/proof/integrations.js +1 -1
- package/dist/public/operations/catalog.d.ts +2 -2
- package/dist/public/operations/check-executor.d.ts +16 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +83 -0
- package/dist/public/operations/check-policy-rules.d.ts +49 -0
- package/dist/public/operations/check-policy-rules.d.ts.map +1 -0
- package/dist/public/operations/check-policy-rules.js +305 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +5 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +13 -3
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +28 -0
- package/dist/public/operations/source-relationship-parity.d.ts.map +1 -1
- package/dist/public/operations/source-relationship-parity.js +16 -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 +4 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/composite.d.ts +16 -3
- package/dist/public/operations/specs/composite.d.ts.map +1 -1
- package/dist/public/operations/specs/composite.js +79 -2
- package/dist/public/operations/specs/modeling.d.ts +1 -1
- package/dist/public/operations/specs/modeling.js +1 -1
- package/dist/public/operations/specs/reporting.d.ts +9 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +6 -2
- package/dist/public/skills/kibi-bootstrap/SKILL.md +3 -2
- package/dist/public/skills/kibi-usage/SKILL.md +82 -3
- package/dist/public/skills/kibi-usage/resources/proof.md +15 -3
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +42 -3
- package/dist/report/html-report.d.ts.map +1 -1
- package/dist/report/html-report.js +13 -2
- package/dist/utils/branch-store.d.ts +32 -0
- package/dist/utils/branch-store.d.ts.map +1 -1
- package/dist/utils/branch-store.js +122 -1
- package/dist/utils/rule-registry.generated.d.ts +15 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +18 -0
- package/dist/utils/strict-modeling.d.ts +12 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +12 -1
- package/package.json +4 -4
- package/src/public/operations/check-executor.ts +112 -0
- package/src/public/operations/check-policy-rules.ts +462 -0
- package/src/public/operations/contracts.ts +6 -0
- package/src/public/operations/discovery-executors.ts +19 -2
- package/src/public/operations/migration-plan.ts +35 -0
- package/src/public/operations/source-relationship-parity.ts +17 -2
- package/src/public/operations/specs/check-rules.generated.ts +4 -1
- package/src/public/operations/specs/composite.ts +110 -11
- package/src/public/operations/specs/modeling.ts +1 -1
- package/src/public/operations/specs/reporting.ts +13 -2
- package/src/public/skills/kibi-bootstrap/SKILL.md +3 -2
- package/src/public/skills/kibi-usage/SKILL.md +82 -3
- package/src/public/skills/kibi-usage/resources/proof.md +15 -3
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +42 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
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
|
+
import { factSourcePath, isConventionalSubjectKey, normalizeSubjectKey, } from "../../utils/strict-modeling.js";
|
|
4
4
|
import { modeledClaimRole, normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
|
|
5
5
|
import { detectConditionalRule } from "../semantic-advisor/conditional-rules.js";
|
|
6
6
|
import { advisorPropositionRole } from "../semantic-advisor/proposition-role.js";
|
|
@@ -11,7 +11,10 @@ import { estimateNormativeSignalConfidence, extractRequirementClaim, } from "./r
|
|
|
11
11
|
import { normalizeOptionalString, normalizeSourceFiles, } from "./requirement-utils.js";
|
|
12
12
|
import { alignRequirementVocabulary, } from "./vocabulary-alignment.js";
|
|
13
13
|
const NEW_SUBJECT_REVIEW_SCORE = 0.3;
|
|
14
|
-
|
|
14
|
+
// implements REQ-kibi-subject-vocabulary
|
|
15
|
+
// The write set describes the existing subject fact, so its id and its source
|
|
16
|
+
// both name that fact; the minted fact (and its file) is never created.
|
|
17
|
+
export function reuseExistingSubject(writeSet, existingFactId) {
|
|
15
18
|
if (!writeSet.isStrict)
|
|
16
19
|
return { writeSet, replacedSubjectId: null };
|
|
17
20
|
const replacedSubjectId = writeSet.subjectFact.id;
|
|
@@ -22,7 +25,11 @@ function reuseExistingSubject(writeSet, existingFactId) {
|
|
|
22
25
|
subjectFact: {
|
|
23
26
|
...writeSet.subjectFact,
|
|
24
27
|
id: existingFactId,
|
|
25
|
-
properties: {
|
|
28
|
+
properties: {
|
|
29
|
+
...writeSet.subjectFact.properties,
|
|
30
|
+
id: existingFactId,
|
|
31
|
+
source: factSourcePath(existingFactId),
|
|
32
|
+
},
|
|
26
33
|
},
|
|
27
34
|
relationships: writeSet.relationships.map((relationship) => relationship.type === "constrains"
|
|
28
35
|
? { ...relationship, to: existingFactId }
|
|
@@ -57,10 +64,11 @@ function possibleDuplicateObservation(claimKey, statement, source, candidates) {
|
|
|
57
64
|
* when the keys match. Otherwise the plan explicitly declares a new subject.
|
|
58
65
|
*/
|
|
59
66
|
// implements REQ-kibi-subject-vocabulary
|
|
60
|
-
async function applyVocabularyAlignment(context, extracted, claimKey) {
|
|
67
|
+
async function applyVocabularyAlignment(context, extracted, claimKey, requirementId) {
|
|
61
68
|
const initial = buildStrictWriteSet({
|
|
62
69
|
claim: extracted.claim,
|
|
63
70
|
statement: extracted.statement,
|
|
71
|
+
...(requirementId !== undefined ? { requirementId } : {}),
|
|
64
72
|
});
|
|
65
73
|
const unchanged = {
|
|
66
74
|
writeSet: initial,
|
|
@@ -90,6 +98,7 @@ async function applyVocabularyAlignment(context, extracted, claimKey) {
|
|
|
90
98
|
const rebuilt = buildStrictWriteSet({
|
|
91
99
|
claim: { ...extracted.claim, subjectKey: subject.subjectKey },
|
|
92
100
|
statement: extracted.statement,
|
|
101
|
+
...(requirementId !== undefined ? { requirementId } : {}),
|
|
93
102
|
});
|
|
94
103
|
({ writeSet, replacedSubjectId } = reuseExistingSubject(rebuilt, subject.existingFactId));
|
|
95
104
|
}
|
|
@@ -431,7 +440,10 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot, con
|
|
|
431
440
|
if (conditional?.kind === "unparsed")
|
|
432
441
|
return unresolvedConditionalResult(args, extracted, conditional.reason, workspaceRoot);
|
|
433
442
|
const claimKey = semanticClaimKey(extracted.statement);
|
|
434
|
-
|
|
443
|
+
// implements REQ-kibi-subject-vocabulary
|
|
444
|
+
// A caller-named requirement keeps its id: the strict write set updates it
|
|
445
|
+
// instead of minting REQ-AUTO-<hash>.
|
|
446
|
+
const aligned = await applyVocabularyAlignment(context, extracted, claimKey, normalizeOptionalString(args.requirementId));
|
|
435
447
|
const writeSet = aligned.writeSet;
|
|
436
448
|
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
437
449
|
const plan = aligned.adjustPlan(strictWriteSetToApplyPlan(writeSet));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAqW1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,GACX,qBAAqB,CA2EvB"}
|
|
@@ -163,7 +163,11 @@ const INTENT_RULES = {
|
|
|
163
163
|
[/use|avoid/i],
|
|
164
164
|
[/api|apis|code|framework|hook|pattern|signal|schema|type|computed/i],
|
|
165
165
|
],
|
|
166
|
-
|
|
166
|
+
// On-screen views and visual patterns are UI design claims (ui_pattern,
|
|
167
|
+
// same_pattern), not developer coding standards.
|
|
168
|
+
prohibited: [
|
|
169
|
+
/user|admin|access|permission|mfa|customer|\bviews?\b|screens?|timeline/i,
|
|
170
|
+
],
|
|
167
171
|
},
|
|
168
172
|
release_gate_rule: {
|
|
169
173
|
allOf: [
|
|
@@ -263,6 +267,28 @@ const INTENT_RULES = {
|
|
|
263
267
|
],
|
|
264
268
|
prohibited: [/deletion|soft\s+delete/i],
|
|
265
269
|
},
|
|
270
|
+
ui_pattern: {
|
|
271
|
+
allOf: [
|
|
272
|
+
[/pattern|timeline|card|list|grid|carousel|table|layout|design/i],
|
|
273
|
+
[/use|show|present|render|display|design/i],
|
|
274
|
+
],
|
|
275
|
+
prohibited: [/aligned\s+with|colou?r|hex|font/i],
|
|
276
|
+
},
|
|
277
|
+
same_pattern: {
|
|
278
|
+
allOf: [
|
|
279
|
+
[/same|consistent|match|identical|one\s+\w+\s+for/i],
|
|
280
|
+
[/both|each|every|variant|role|view|presentation/i],
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
pattern_marker: {
|
|
284
|
+
allOf: [[/marker|marked|class|test\s*id|data-testid|selector/i]],
|
|
285
|
+
},
|
|
286
|
+
ui_container: {
|
|
287
|
+
allOf: [
|
|
288
|
+
[/container|panel|sheet|pane|region/i],
|
|
289
|
+
[/scroll|overflow|half[- ]page|full[- ]height|clip/i],
|
|
290
|
+
],
|
|
291
|
+
},
|
|
266
292
|
};
|
|
267
293
|
function round(value) {
|
|
268
294
|
return Math.round(Math.max(0, Math.min(0.98, value)) * 100) / 100;
|
|
@@ -1 +1 @@
|
|
|
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,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;IAC1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,GACA,mBAAmB,
|
|
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,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;IAC1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,GACA,mBAAmB,CA2KrB;AAGD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0ChC;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,CAuBhC;AAoBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,0BAA0B,CAoE5B"}
|
|
@@ -74,17 +74,27 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
74
74
|
constrainedSubjects,
|
|
75
75
|
}),
|
|
76
76
|
]));
|
|
77
|
-
// The
|
|
78
|
-
// constrains
|
|
79
|
-
//
|
|
80
|
-
|
|
77
|
+
// The subjects the planned predicate must be about: those the requirement
|
|
78
|
+
// constrains, or, for a requirement that is not written yet or constrains
|
|
79
|
+
// nothing, the explicit subjectHint. The hint is then the subject fact the
|
|
80
|
+
// agent is about to link, so the planned fact carries its subject_key and
|
|
81
|
+
// kb_check pairs the two once the requirement is written.
|
|
82
|
+
const plannedSubjects = constrainedSubjects.length > 0
|
|
83
|
+
? constrainedSubjects
|
|
84
|
+
: explicitSubject
|
|
85
|
+
? [subject]
|
|
86
|
+
: [];
|
|
87
|
+
// The subject the planned predicate fact is about: the `subject`
|
|
88
|
+
// argument's value, or for a schema without one the reviewed subject,
|
|
89
|
+
// recorded as the fact's subject_key.
|
|
90
|
+
const subjectKey = plannedSubjects.length === 0
|
|
81
91
|
? null
|
|
82
92
|
: subjectArgument >= 0
|
|
83
93
|
? (predicateArgs[subjectArgument] ?? null)
|
|
84
94
|
: (reviewedSubject ?? null);
|
|
85
|
-
const subjectPairing =
|
|
95
|
+
const subjectPairing = plannedSubjects.length === 0
|
|
86
96
|
? "not_required"
|
|
87
|
-
: subjectKey !== null &&
|
|
97
|
+
: subjectKey !== null && plannedSubjects.includes(subjectKey)
|
|
88
98
|
? "paired"
|
|
89
99
|
: "unpaired";
|
|
90
100
|
const bindingProvenance = aggregateBindingProvenance(Object.values(bindingProvenanceByArgument));
|
|
@@ -6,6 +6,16 @@ import type { BindingHint, PredicateSuggestion } from "./predicate-types.js";
|
|
|
6
6
|
* instead of guessing.
|
|
7
7
|
*/
|
|
8
8
|
export declare function buildBindingHints(candidate: PredicateSuggestion, text: string, requirementSubjects?: readonly string[]): BindingHint[];
|
|
9
|
+
/**
|
|
10
|
+
* The unbound participant arguments (`actor`, `actor_scope`, `role`,
|
|
11
|
+
* `owner`) of a candidate that the claim names no participant for: the
|
|
12
|
+
* current value is empty or a placeholder, the requirement's subject key, or
|
|
13
|
+
* a clause of the claim that opens with a gerund (an activity, not a
|
|
14
|
+
* participant), and none of the argument's declared constants or schema
|
|
15
|
+
* example values occurs in the claim text. The agent cannot bind such an
|
|
16
|
+
* argument from the claim, so the schema does not fit the claim.
|
|
17
|
+
*/
|
|
18
|
+
export declare function unnamedParticipantArguments(candidate: PredicateSuggestion, text: string, requirementSubjects?: readonly string[]): string[];
|
|
9
19
|
/** One line per hint for the text summary: `name (type, e.g. a, b)`. */
|
|
10
20
|
export declare function describeBindingHints(hints: readonly BindingHint[]): string;
|
|
11
21
|
//# sourceMappingURL=predicate-binding-hints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAoF7E;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,MAAM,EACZ,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,WAAW,EAAE,CA6Df;AAqCD;;;;;;;;GAQG;AAEH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,MAAM,EACZ,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,EAAE,CA8BV;AAED,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAW1E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bindingCanBeApplied, clauseBindingReason, isGenericPlaceholder, isParticipantArgumentType, nameOrStopWordReason, subjectKeyParticipantReason, } from "./predicate-bindings.js";
|
|
2
|
+
import { escapeRegExp } from "./predicate-utils.js";
|
|
2
3
|
const MAX_EXAMPLES = 5;
|
|
3
4
|
/** Split `name(a, b(c), d)` into its top-level arguments, or [] when it is not a call. */
|
|
4
5
|
function exampleArguments(example) {
|
|
@@ -134,6 +135,79 @@ export function buildBindingHints(candidate, text, requirementSubjects = []) {
|
|
|
134
135
|
};
|
|
135
136
|
});
|
|
136
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Whether the claim text names `value`: its words in order, any separator,
|
|
140
|
+
* with a plural ending allowed on the last word (`guest` names `guests`).
|
|
141
|
+
*/
|
|
142
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
143
|
+
function claimNamesValue(text, value) {
|
|
144
|
+
const words = value
|
|
145
|
+
.toLowerCase()
|
|
146
|
+
.split(/[\s_.-]+/)
|
|
147
|
+
.filter(Boolean);
|
|
148
|
+
if (words.length === 0)
|
|
149
|
+
return false;
|
|
150
|
+
// Lookarounds instead of \b: a value may start or end with a symbol
|
|
151
|
+
// (`svc(ci)`, `c++`), where a word boundary never matches.
|
|
152
|
+
return new RegExp(`(?<!\\w)${words.map(escapeRegExp).join("[\\s_-]+")}(?:e?s)?(?!\\w)`, "i").test(text);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Whether a clause lifted from the claim describes an action rather than a
|
|
156
|
+
* participant: it opens with a gerund ("Discarding a draft while …"). A
|
|
157
|
+
* clause that opens with a noun ("Administrators who were granted …") may
|
|
158
|
+
* still name the participant in its first words, so it is left to the agent.
|
|
159
|
+
*/
|
|
160
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
161
|
+
function clauseIsActivity(clause) {
|
|
162
|
+
const head = clause
|
|
163
|
+
.toLowerCase()
|
|
164
|
+
.split(/[\s_-]+/)
|
|
165
|
+
.find(Boolean) ?? "";
|
|
166
|
+
return head.length > 4 && head.endsWith("ing");
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The unbound participant arguments (`actor`, `actor_scope`, `role`,
|
|
170
|
+
* `owner`) of a candidate that the claim names no participant for: the
|
|
171
|
+
* current value is empty or a placeholder, the requirement's subject key, or
|
|
172
|
+
* a clause of the claim that opens with a gerund (an activity, not a
|
|
173
|
+
* participant), and none of the argument's declared constants or schema
|
|
174
|
+
* example values occurs in the claim text. The agent cannot bind such an
|
|
175
|
+
* argument from the claim, so the schema does not fit the claim.
|
|
176
|
+
*/
|
|
177
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
178
|
+
export function unnamedParticipantArguments(candidate, text, requirementSubjects = []) {
|
|
179
|
+
const schema = candidate.schema;
|
|
180
|
+
const parsedExamples = schema.examples.map(exampleArguments);
|
|
181
|
+
return candidate.unbound_arguments.filter((name) => {
|
|
182
|
+
const position = schema.argument_names.indexOf(name);
|
|
183
|
+
if (position < 0)
|
|
184
|
+
return false;
|
|
185
|
+
const type = schema.argument_types[position];
|
|
186
|
+
if (!isParticipantArgumentType(type))
|
|
187
|
+
return false;
|
|
188
|
+
const constants = schema.argument_constants?.[name];
|
|
189
|
+
const current = candidate.predicate_args[position] ?? "";
|
|
190
|
+
const unnamed = !current.trim() ||
|
|
191
|
+
isGenericPlaceholder(current) ||
|
|
192
|
+
subjectKeyParticipantReason(current, {
|
|
193
|
+
argumentType: type,
|
|
194
|
+
constants,
|
|
195
|
+
constrainedSubjects: requirementSubjects,
|
|
196
|
+
}) !== null ||
|
|
197
|
+
(clauseBindingReason(current, { argumentType: type, constants }) !==
|
|
198
|
+
null &&
|
|
199
|
+
clauseIsActivity(current));
|
|
200
|
+
if (!unnamed)
|
|
201
|
+
return false;
|
|
202
|
+
const known = [
|
|
203
|
+
...(constants ?? []),
|
|
204
|
+
...parsedExamples
|
|
205
|
+
.map((args) => args[position])
|
|
206
|
+
.filter((value) => typeof value === "string"),
|
|
207
|
+
];
|
|
208
|
+
return !known.some((value) => claimNamesValue(text, value));
|
|
209
|
+
});
|
|
210
|
+
}
|
|
137
211
|
/** One line per hint for the text summary: `name (type, e.g. a, b)`. */
|
|
138
212
|
export function describeBindingHints(hints) {
|
|
139
213
|
return hints
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PredicateSchemaCandidate } from "./predicate-types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Predicate families added from consumer escalation evidence (
|
|
4
|
-
* dogfooding, 2026-08/09): fail-closed authorization, deployment
|
|
3
|
+
* Predicate families added from consumer escalation evidence (test
|
|
4
|
+
* project dogfooding, 2026-08/09): fail-closed authorization, deployment
|
|
5
5
|
* preconditions, migration sequencing, diagnostic visibility, mutation
|
|
6
6
|
* authority, request deduplication, async boundaries, canonical
|
|
7
7
|
* identifiers, responsive breakpoints, and operational pauses.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Predicate families added from consumer escalation evidence (
|
|
3
|
-
* dogfooding, 2026-08/09): fail-closed authorization, deployment
|
|
2
|
+
* Predicate families added from consumer escalation evidence (test
|
|
3
|
+
* project dogfooding, 2026-08/09): fail-closed authorization, deployment
|
|
4
4
|
* preconditions, migration sequencing, diagnostic visibility, mutation
|
|
5
5
|
* authority, request deduplication, async boundaries, canonical
|
|
6
6
|
* identifiers, responsive breakpoints, and operational pauses.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PredicateSchemaCandidate } from "./predicate-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* UI design patterns: which visual pattern a concept uses, which variants
|
|
4
|
+
* must share it, which code markers make it recognisable, and the layout
|
|
5
|
+
* shell it sits in. `kibi-plugin-ui` enforces these through its check policy;
|
|
6
|
+
* without that plugin they are ordinary predicates.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PREDICATE_CATALOG_6: PredicateSchemaCandidate[];
|
|
9
|
+
//# sourceMappingURL=predicate-catalog-6.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicate-catalog-6.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-catalog-6.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE;;;;;GAKG;AAEH,eAAO,MAAM,mBAAmB,EAAE,wBAAwB,EAsGzD,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI design patterns: which visual pattern a concept uses, which variants
|
|
3
|
+
* must share it, which code markers make it recognisable, and the layout
|
|
4
|
+
* shell it sits in. `kibi-plugin-ui` enforces these through its check policy;
|
|
5
|
+
* without that plugin they are ordinary predicates.
|
|
6
|
+
*/
|
|
7
|
+
// implements REQ-mcp-suggest-predicates, REQ-ui-pattern-vocabulary
|
|
8
|
+
export const PREDICATE_CATALOG_6 = [
|
|
9
|
+
{
|
|
10
|
+
id: "FACT-SCHEMA-UI-PATTERN",
|
|
11
|
+
predicate_name: "ui_pattern",
|
|
12
|
+
title: "UI pattern",
|
|
13
|
+
description: "A UI concept must be presented with a named visual pattern, such as a line-and-dots timeline or a card list.",
|
|
14
|
+
argument_names: ["subject", "pattern"],
|
|
15
|
+
argument_types: ["ui_entity", "ui_pattern"],
|
|
16
|
+
argument_descriptions: [
|
|
17
|
+
"The UI concept or region, such as an annotation list.",
|
|
18
|
+
"The agreed visual pattern for that concept.",
|
|
19
|
+
],
|
|
20
|
+
keywords: [
|
|
21
|
+
"pattern",
|
|
22
|
+
"design pattern",
|
|
23
|
+
"presented as",
|
|
24
|
+
"rendered as",
|
|
25
|
+
"displayed as",
|
|
26
|
+
"timeline",
|
|
27
|
+
"card list",
|
|
28
|
+
"layout pattern",
|
|
29
|
+
],
|
|
30
|
+
aliases: ["visual pattern", "design direction"],
|
|
31
|
+
examples: ["ui_pattern(annotation_list, line_dots_timeline)"],
|
|
32
|
+
tags: ["ui", "design", "pattern"],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "FACT-SCHEMA-SAME-PATTERN",
|
|
36
|
+
predicate_name: "same_pattern",
|
|
37
|
+
title: "Same pattern across variants",
|
|
38
|
+
description: "Two variants of a UI concept (roles, viewports, presentations) must use the same visual pattern.",
|
|
39
|
+
argument_names: ["subject", "variant", "other_variant"],
|
|
40
|
+
argument_types: ["ui_entity", "ui_variant", "ui_variant"],
|
|
41
|
+
argument_descriptions: [
|
|
42
|
+
"The UI concept whose variants must not diverge.",
|
|
43
|
+
"One variant, such as a role or presentation.",
|
|
44
|
+
"The variant that must match it.",
|
|
45
|
+
],
|
|
46
|
+
keywords: [
|
|
47
|
+
"same pattern",
|
|
48
|
+
"same design",
|
|
49
|
+
"consistent",
|
|
50
|
+
"for both",
|
|
51
|
+
"same timeline",
|
|
52
|
+
"must match",
|
|
53
|
+
],
|
|
54
|
+
aliases: ["consistent across roles", "no divergent variant"],
|
|
55
|
+
examples: ["same_pattern(annotation_list, editor_view, read_only_view)"],
|
|
56
|
+
tags: ["ui", "design", "consistency"],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "FACT-SCHEMA-PATTERN-MARKER",
|
|
60
|
+
predicate_name: "pattern_marker",
|
|
61
|
+
title: "Pattern marker",
|
|
62
|
+
description: "A visual pattern is recognisable in code by a stable marker such as a CSS class or test id.",
|
|
63
|
+
argument_names: ["subject", "marker"],
|
|
64
|
+
argument_types: ["ui_pattern", "ui_marker"],
|
|
65
|
+
argument_descriptions: [
|
|
66
|
+
"The visual pattern the marker belongs to.",
|
|
67
|
+
"Literal class name or test id that implementations of the pattern contain.",
|
|
68
|
+
],
|
|
69
|
+
keywords: [
|
|
70
|
+
"marker",
|
|
71
|
+
"marked by",
|
|
72
|
+
"class name",
|
|
73
|
+
"test id",
|
|
74
|
+
"data-testid",
|
|
75
|
+
"css class",
|
|
76
|
+
],
|
|
77
|
+
aliases: ["pattern anchor"],
|
|
78
|
+
examples: ["pattern_marker(line_dots_timeline, timeline_dot)"],
|
|
79
|
+
tags: ["ui", "design", "pattern"],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "FACT-SCHEMA-UI-CONTAINER",
|
|
83
|
+
predicate_name: "ui_container",
|
|
84
|
+
title: "UI container",
|
|
85
|
+
description: "A UI region must sit in a container of a given size with a given overflow behaviour.",
|
|
86
|
+
argument_names: ["subject", "size", "overflow"],
|
|
87
|
+
argument_types: ["ui_entity", "ui_size", "ui_overflow"],
|
|
88
|
+
argument_descriptions: [
|
|
89
|
+
"The UI region the container holds.",
|
|
90
|
+
"Container size, such as half_page or full_height.",
|
|
91
|
+
"Overflow behaviour, such as scroll or clip.",
|
|
92
|
+
],
|
|
93
|
+
keywords: [
|
|
94
|
+
"container",
|
|
95
|
+
"half page",
|
|
96
|
+
"half-page",
|
|
97
|
+
"scrollbar",
|
|
98
|
+
"scrollable",
|
|
99
|
+
"panel",
|
|
100
|
+
"overflow",
|
|
101
|
+
],
|
|
102
|
+
aliases: ["layout shell"],
|
|
103
|
+
examples: ["ui_container(review_panel, half_page, scroll)"],
|
|
104
|
+
tags: ["ui", "design", "layout"],
|
|
105
|
+
},
|
|
106
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-catalog.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"predicate-catalog.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-catalog.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAO9B,eAAO,MAAM,mBAAmB,EAAE,mBAOjC,CAAC;AAGF,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAKxE,CAAC;AAGF,eAAO,MAAM,0BAA0B,EAAE,wBAAwB,EAOhE,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { PREDICATE_CATALOG_2 } from "./predicate-catalog-2.js";
|
|
|
3
3
|
import { PREDICATE_CATALOG_3 } from "./predicate-catalog-3.js";
|
|
4
4
|
import { PREDICATE_CATALOG_4 } from "./predicate-catalog-4.js";
|
|
5
5
|
import { PREDICATE_CATALOG_5 } from "./predicate-catalog-5.js";
|
|
6
|
+
import { PREDICATE_CATALOG_6 } from "./predicate-catalog-6.js";
|
|
6
7
|
import { PREDICATE_USAGE_HINTS_1 } from "./predicate-usage-hints-1.js";
|
|
7
8
|
import { PREDICATE_USAGE_HINTS_2 } from "./predicate-usage-hints-2.js";
|
|
8
9
|
import { PREDICATE_USAGE_HINTS_3 } from "./predicate-usage-hints-3.js";
|
|
@@ -30,4 +31,5 @@ export const BUILT_IN_PREDICATE_SCHEMAS = [
|
|
|
30
31
|
...PREDICATE_CATALOG_3,
|
|
31
32
|
...PREDICATE_CATALOG_4,
|
|
32
33
|
...PREDICATE_CATALOG_5,
|
|
34
|
+
...PREDICATE_CATALOG_6,
|
|
33
35
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-usage-hints-4.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-usage-hints-4.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"predicate-usage-hints-4.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-usage-hints-4.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAkHvE,CAAC"}
|
|
@@ -81,4 +81,36 @@ export const PREDICATE_USAGE_HINTS_4 = {
|
|
|
81
81
|
],
|
|
82
82
|
// implements REQ-mcp-suggest-predicates
|
|
83
83
|
},
|
|
84
|
+
ui_pattern: {
|
|
85
|
+
use_when: [
|
|
86
|
+
"Use when a UI concept must be presented with a named visual pattern that other screens or variants must not replace.",
|
|
87
|
+
],
|
|
88
|
+
do_not_use_when: [
|
|
89
|
+
"Do not use for alignment between two elements (visual_layout_rule) or for colours and spacing a linter can check.",
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
same_pattern: {
|
|
93
|
+
use_when: [
|
|
94
|
+
"Use when two variants of one UI concept, such as roles or presentations, must render the same visual pattern.",
|
|
95
|
+
],
|
|
96
|
+
do_not_use_when: [
|
|
97
|
+
"Do not use when the variants are intentionally different; record that difference in the requirement instead.",
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
pattern_marker: {
|
|
101
|
+
use_when: [
|
|
102
|
+
"Use to name a stable class or test id that every implementation of a visual pattern contains.",
|
|
103
|
+
],
|
|
104
|
+
do_not_use_when: [
|
|
105
|
+
"Do not use for markers that change with content or styling, such as generated class names.",
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
ui_container: {
|
|
109
|
+
use_when: [
|
|
110
|
+
"Use when a UI region must sit in a container of a named size with a named overflow behaviour, such as a half-page scroll panel.",
|
|
111
|
+
],
|
|
112
|
+
do_not_use_when: [
|
|
113
|
+
"Do not use for exact pixel sizes or brand tokens a linter or stylesheet already enforces.",
|
|
114
|
+
],
|
|
115
|
+
},
|
|
84
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"suggest-predicates.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/suggest-predicates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACX,MAAM,0CAA0C,CAAC;AA0BlD,OAAO,KAAK,EAGV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AA6H9B,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,EACzE,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,gBAAgB,CAAC,GACzE,MAAM,CAIR;AAED,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,IAAI,CACR,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,EACD,KAAK,EAAE,IAAI,CACT,mBAAmB,EACnB,qBAAqB,GAAG,OAAO,GAAG,gBAAgB,CACnD,GACA,MAAM,CAKR;AA+HD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,uBAAuB,CAAC,CAmTlC;AA2ID,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
|
|
@@ -6,7 +6,7 @@ import { semanticClaimKey } from "../semantic-advisor/clauses.js";
|
|
|
6
6
|
import { composeOntologyCatalogForOperation } from "../semantic-advisor/plugin-orchestration.js";
|
|
7
7
|
import { STRONG_APPLICABILITY_SCORE, WEAK_CANDIDATE_MARGIN, evaluateSemanticApplicability, } from "./predicate-applicability.js";
|
|
8
8
|
import { buildGapApplyPlan, buildPredicateApplyPlan, buildPredicateSchemaDraft, buildRelationshipPlan, buildSuggestion, } from "./predicate-applyplan.js";
|
|
9
|
-
import { buildBindingHints, describeBindingHints, } from "./predicate-binding-hints.js";
|
|
9
|
+
import { buildBindingHints, describeBindingHints, unnamedParticipantArguments, } from "./predicate-binding-hints.js";
|
|
10
10
|
import { BUILT_IN_PREDICATE_SCHEMAS } from "./predicate-catalog.js";
|
|
11
11
|
import { inferSubject } from "./predicate-inference.js";
|
|
12
12
|
import { loadExistingPredicateSchemas } from "./predicate-loader.js";
|
|
@@ -326,6 +326,20 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
326
326
|
const completeCandidate = recommendedCandidate && recommendedCandidate.binding_status === "complete"
|
|
327
327
|
? recommendedCandidate
|
|
328
328
|
: undefined;
|
|
329
|
+
// implements REQ-model-predicates-participant-not-subject
|
|
330
|
+
// A schema whose participant argument (actor, role, owner) the claim never
|
|
331
|
+
// names does not fit the claim: no binding the agent could supply would be
|
|
332
|
+
// read from the claim. When every unbound argument of the recommended
|
|
333
|
+
// candidate is such a participant, the claim is an ontology gap, not a
|
|
334
|
+
// binding request. An argument unbound for another reason (a value the
|
|
335
|
+
// claim does name but in other words, a closed vocabulary) still asks for
|
|
336
|
+
// bindings.
|
|
337
|
+
const unnamedParticipants = recommendedCandidate && !completeCandidate
|
|
338
|
+
? unnamedParticipantArguments(recommendedCandidate, text, requirementSubjects)
|
|
339
|
+
: [];
|
|
340
|
+
const schemaDoesNotFit = unnamedParticipants.length > 0 &&
|
|
341
|
+
unnamedParticipants.length ===
|
|
342
|
+
(recommendedCandidate?.unbound_arguments.length ?? 0);
|
|
329
343
|
// The action names the predicate state; existingGrounding (non-empty) is
|
|
330
344
|
// the separate "already grounded" signal. A complete candidate for a claim
|
|
331
345
|
// that is already grounded becomes a replacement, never a second link.
|
|
@@ -337,7 +351,9 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
337
351
|
? alreadyGrounded
|
|
338
352
|
? "replace_grounding"
|
|
339
353
|
: "apply_requires_predicate"
|
|
340
|
-
:
|
|
354
|
+
: schemaDoesNotFit
|
|
355
|
+
? "record_ontology_gap"
|
|
356
|
+
: "provide_argument_bindings";
|
|
341
357
|
const predicatePlan = completeCandidate
|
|
342
358
|
? buildPredicateApplyPlan(completeCandidate, args)
|
|
343
359
|
: [];
|
|
@@ -349,7 +365,7 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
349
365
|
? alreadyGrounded
|
|
350
366
|
? []
|
|
351
367
|
: predicatePlan
|
|
352
|
-
: !recommendedCandidate && !unavailableSchema
|
|
368
|
+
: (!recommendedCandidate && !unavailableSchema) || schemaDoesNotFit
|
|
353
369
|
? buildGapApplyPlan(text, args)
|
|
354
370
|
: [];
|
|
355
371
|
const plannedFactId = typeof predicatePlan[0]?.id === "string" ? predicatePlan[0].id : null;
|
|
@@ -368,7 +384,10 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
368
384
|
if (alreadyGrounded) {
|
|
369
385
|
warnings.push(`${args.requirementId} already grounds this claim (${claimKey}) through ${groundingSummary}. A modeled claim takes exactly one logical grounding relationship, so adding requires_predicate beside it fails the proposition-complete rule. ${replacementPlan ? "Keep the existing grounding, or follow replacementPlan to swap it for the predicate." : "Keep the existing grounding; no predicate replacement is available yet."}`);
|
|
370
386
|
}
|
|
371
|
-
|
|
387
|
+
// The hints stay on a schema that does not fit, so the agent can see which
|
|
388
|
+
// participant the claim would have to name.
|
|
389
|
+
const bindingHints = (recommendedAction === "provide_argument_bindings" || schemaDoesNotFit) &&
|
|
390
|
+
recommendedCandidate
|
|
372
391
|
? buildBindingHints(recommendedCandidate, text, requirementSubjects)
|
|
373
392
|
: [];
|
|
374
393
|
if (recommendedCandidate?.subject_pairing === "unpaired") {
|
|
@@ -385,13 +404,15 @@ export async function handleKbSuggestPredicates(prolog, args, context) {
|
|
|
385
404
|
? `To use ${completeCandidate?.predicate_name} instead, follow replacementPlan and link requires_predicate to ${plannedFactId}; otherwise keep the existing grounding.`
|
|
386
405
|
: completeCandidate
|
|
387
406
|
? `Suggested ${candidates.length} predicate candidate(s). Top applicable match: ${completeCandidate.predicate_name}. Apply the predicate fact ${plannedFactId}, then link requires_predicate to that fact id (not a candidate id).`
|
|
388
|
-
: recommendedCandidate
|
|
389
|
-
? `Matched ${recommendedCandidate.predicate_name}, but
|
|
390
|
-
:
|
|
391
|
-
? `
|
|
392
|
-
:
|
|
393
|
-
?
|
|
394
|
-
:
|
|
407
|
+
: schemaDoesNotFit && recommendedCandidate
|
|
408
|
+
? `Matched ${recommendedCandidate.predicate_name}, but the claim names no ${unnamedParticipants.join(" or ")} (${describeBindingHints(bindingHints)}), so this schema does not fit the claim. Record the ontology-gap observation in applyPlan instead of inventing a participant; a predicate_schema whose arguments the claim names would fit.`
|
|
409
|
+
: recommendedCandidate
|
|
410
|
+
? `Matched ${recommendedCandidate.predicate_name}, but exact reviewed values are still required for: ${recommendedCandidate.unbound_arguments.join(", ")}. Bind them from the claim text: ${describeBindingHints(bindingHints)}. A value that repeats an argument name or a stop word stays unbound. No apply plan was generated.`
|
|
411
|
+
: unavailableSchema
|
|
412
|
+
? `Requested predicate schema ${args.schemaId} is unavailable or semantically inapplicable. No apply plan was generated.`
|
|
413
|
+
: alreadyGrounded
|
|
414
|
+
? "No predicate candidate passed the semantic applicability gate; keep the existing grounding and record the ontology-gap observation in applyPlan so the missing schema stays visible."
|
|
415
|
+
: "No predicate candidate passed the semantic applicability gate; record an ontology gap and review the generated schema draft instead of silently writing prose.");
|
|
395
416
|
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
396
417
|
return {
|
|
397
418
|
content: [{ type: "text", text: textSummary }],
|
|
@@ -6,6 +6,14 @@ type TransactionInput = {
|
|
|
6
6
|
readonly skipContradictionCheck: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare function buildUpsertCommitGoal(input: TransactionInput): string;
|
|
9
|
+
/**
|
|
10
|
+
* Goal that stages the same entity and relationships the commit goal would
|
|
11
|
+
* and runs the commit-time contradiction check inside a transaction that is
|
|
12
|
+
* always rolled back (kb_preview_upsert_contradiction/3). It succeeds when
|
|
13
|
+
* the commit would pass the check and fails with the commit's error when it
|
|
14
|
+
* would not; it never writes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildUpsertContradictionPreviewGoal(input: TransactionInput): string;
|
|
9
17
|
type WhatIfInput = TransactionInput & {
|
|
10
18
|
readonly relationshipsOnly?: boolean;
|
|
11
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AASrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAOrE;AAiBD,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAgB/E;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAGD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAED,oEAAoE;AAEpE,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,MAAM,CAKR;AAGD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAe9B;AAGD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAOR"}
|
|
1
|
+
{"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AASrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAOrE;AAGD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,gBAAgB,GACtB,MAAM,CAOR;AAiBD,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAgB/E;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAGD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAED,oEAAoE;AAEpE,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,MAAM,CAKR;AAGD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAe9B;AAGD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAOR"}
|
|
@@ -7,6 +7,19 @@ export function buildUpsertCommitGoal(input) {
|
|
|
7
7
|
const relationships = input.relationships.map((relationship) => `rel(${String(relationship.type)}, '${escapeAtom(String(relationship.from))}', '${escapeAtom(String(relationship.to))}', ${buildRelationshipMetadata(relationship)})`);
|
|
8
8
|
return `kb_commit_upsert(${type}, ${buildPropertyList(input.entity)}, [${relationships.join(", ")}], ${input.skipContradictionCheck ? "true" : "false"}, ChangeKind)`;
|
|
9
9
|
}
|
|
10
|
+
// implements REQ-kibi-operation-interface-parity
|
|
11
|
+
/**
|
|
12
|
+
* Goal that stages the same entity and relationships the commit goal would
|
|
13
|
+
* and runs the commit-time contradiction check inside a transaction that is
|
|
14
|
+
* always rolled back (kb_preview_upsert_contradiction/3). It succeeds when
|
|
15
|
+
* the commit would pass the check and fails with the commit's error when it
|
|
16
|
+
* would not; it never writes.
|
|
17
|
+
*/
|
|
18
|
+
export function buildUpsertContradictionPreviewGoal(input) {
|
|
19
|
+
const type = String(input.entity.type);
|
|
20
|
+
const relationships = input.relationships.map((relationship) => `rel(${String(relationship.type)}, '${escapeAtom(String(relationship.from))}', '${escapeAtom(String(relationship.to))}', ${buildRelationshipMetadata(relationship)})`);
|
|
21
|
+
return `kb_preview_upsert_contradiction(${type}, ${buildPropertyList(input.entity)}, [${relationships.join(", ")}])`;
|
|
22
|
+
}
|
|
10
23
|
function upsertBatchEntry(input) {
|
|
11
24
|
const type = String(input.entity.type);
|
|
12
25
|
const relationships = input.relationships.map((relationship) => `rel(${String(relationship.type)}, '${escapeAtom(String(relationship.from))}', '${escapeAtom(String(relationship.to))}', ${buildRelationshipMetadata(relationship)})`);
|