kibi-cli 2.20.0 → 2.21.2
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-operation-metadata.d.ts +1 -1
- package/dist/cli-operation-metadata.js +1 -1
- package/dist/commands/doctor.js +13 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +15 -3
- package/dist/commands/legacy-storage-migration.d.ts.map +1 -1
- package/dist/commands/legacy-storage-migration.js +26 -1
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +155 -11
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +14 -2
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +4 -0
- package/dist/decision-firmness.d.ts +39 -0
- package/dist/decision-firmness.d.ts.map +1 -0
- package/dist/decision-firmness.js +115 -0
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +16 -1
- package/dist/operations/migration/kb-sources.d.ts +5 -1
- package/dist/operations/migration/kb-sources.d.ts.map +1 -1
- package/dist/operations/migration/kb-sources.js +28 -1
- package/dist/operations/migration/schema6.d.ts +2 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +44 -1
- package/dist/operations/migration/supersedes-reason.d.ts +26 -0
- package/dist/operations/migration/supersedes-reason.d.ts.map +1 -0
- package/dist/operations/migration/supersedes-reason.js +69 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +10 -2
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +11 -0
- package/dist/operations/modeling/predicate-types.d.ts +32 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +175 -35
- package/dist/operations/mutation/delete.d.ts +5 -1
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +223 -17
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +1 -0
- package/dist/operations/mutation/source-authoring.d.ts +8 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +33 -0
- package/dist/operations/mutation/types.d.ts +37 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +54 -2
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +2 -1
- package/dist/operations/planning/apply-plan.d.ts +6 -1
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +8 -2
- package/dist/operations/semantic-advisor/clauses.d.ts +9 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +24 -0
- package/dist/public/operations/catalog.d.ts +14 -5
- 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 +3 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +29 -1
- package/dist/public/operations/decision-firmness.d.ts +34 -0
- package/dist/public/operations/decision-firmness.d.ts.map +1 -0
- package/dist/public/operations/decision-firmness.js +216 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +16 -2
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +37 -7
- 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 +5 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +7 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +13 -17
- package/dist/public/operations/specs/mutation.d.ts +6 -2
- package/dist/public/operations/specs/mutation.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation.js +6 -2
- package/dist/public/operations/specs/upsert.d.ts +7 -2
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +13 -13
- package/dist/public/skills/kibi-traceability/SKILL.md +6 -4
- package/dist/public/skills/kibi-usage/SKILL.md +52 -10
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/dist/public/skills/kibi-usage/resources/source-authoring.md +4 -2
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +2 -2
- package/dist/public/skills/kibi-usage/resources/workflows.md +1 -1
- package/dist/relationships/shards.d.ts +10 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +27 -11
- package/dist/schemas/entity.schema.json +30 -25
- package/dist/search-answer.d.ts +31 -2
- package/dist/search-answer.d.ts.map +1 -1
- package/dist/search-answer.js +115 -17
- package/dist/types/entities.d.ts +4 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/kb-manifest.d.ts +6 -0
- package/dist/utils/kb-manifest.d.ts.map +1 -1
- package/dist/utils/kb-manifest.js +6 -0
- package/dist/utils/rule-registry.generated.d.ts +21 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +25 -0
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.d.ts.map +1 -1
- package/dist/utils/schema-version.js +3 -1
- package/package.json +2 -2
- package/schema/entities.pl +6 -0
- package/src/public/operations/check-executor.ts +6 -0
- package/src/public/operations/contracts.ts +33 -1
- package/src/public/operations/decision-firmness.ts +280 -0
- package/src/public/operations/discovery-executors.ts +17 -2
- package/src/public/operations/migration-plan.ts +41 -9
- package/src/public/operations/specs/check-rules.generated.ts +5 -1
- package/src/public/operations/specs/mutation-schemas.ts +14 -17
- package/src/public/operations/specs/mutation.ts +7 -2
- package/src/public/schemas/entity.ts +14 -13
- package/src/public/skills/kibi-traceability/SKILL.md +6 -4
- package/src/public/skills/kibi-usage/SKILL.md +52 -10
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/src/public/skills/kibi-usage/resources/source-authoring.md +4 -2
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +2 -2
- package/src/public/skills/kibi-usage/resources/workflows.md +1 -1
- package/src/schemas/entity.schema.json +30 -25
|
@@ -197,15 +197,21 @@ export function renderShardWithout(text, selectors, shardPath) {
|
|
|
197
197
|
}
|
|
198
198
|
return document.toString();
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Render every shard that holds a selected relationship without writing it,
|
|
202
|
+
* so a dry run can report the exact bytes a delete would publish.
|
|
203
|
+
*/
|
|
204
|
+
// implements REQ-kibi-operation-interface-parity
|
|
205
|
+
export function planRelationshipShardRemovals(kbRoot, selectors) {
|
|
201
206
|
const wanted = new Set(selectors.map((selector) => `${selector.type}\0${selector.from}\0${selector.to}`));
|
|
202
207
|
const removed = new Map();
|
|
208
|
+
const bodies = new Map();
|
|
203
209
|
for (const shardPath of listShards(kbRoot)) {
|
|
204
210
|
const records = readShard(shardPath);
|
|
205
211
|
const matching = records.filter((record) => wanted.has(`${record.type}\0${record.from}\0${record.to}`));
|
|
206
212
|
if (matching.length === 0)
|
|
207
213
|
continue;
|
|
208
|
-
|
|
214
|
+
bodies.set(shardPath, renderShardWithout(fs.readFileSync(shardPath, "utf8"), selectors, shardPath));
|
|
209
215
|
for (const record of matching) {
|
|
210
216
|
const key = `${record.type}\0${record.from}\0${record.to}`;
|
|
211
217
|
const entry = removed.get(key) ?? { paths: [], sources: [] };
|
|
@@ -214,15 +220,25 @@ export function removeRelationshipsFromShards(kbRoot, selectors) {
|
|
|
214
220
|
removed.set(key, entry);
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
selector
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
return {
|
|
224
|
+
bodies,
|
|
225
|
+
removals: selectors.map((selector) => {
|
|
226
|
+
const entry = removed.get(`${selector.type}\0${selector.from}\0${selector.to}`);
|
|
227
|
+
return {
|
|
228
|
+
selector,
|
|
229
|
+
shardPaths: entry?.paths ?? [],
|
|
230
|
+
sources: entry?.sources ?? [],
|
|
231
|
+
removed: entry !== undefined,
|
|
232
|
+
};
|
|
233
|
+
}),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
export function removeRelationshipsFromShards(kbRoot, selectors) {
|
|
237
|
+
const planned = planRelationshipShardRemovals(kbRoot, selectors);
|
|
238
|
+
for (const [shardPath, body] of planned.bodies) {
|
|
239
|
+
atomicWriteText(shardPath, body);
|
|
240
|
+
}
|
|
241
|
+
return planned.removals;
|
|
226
242
|
}
|
|
227
243
|
/**
|
|
228
244
|
* Serializes records to YAML format.
|
|
@@ -514,6 +514,15 @@
|
|
|
514
514
|
},
|
|
515
515
|
"additionalProperties": false
|
|
516
516
|
},
|
|
517
|
+
"firmness": {
|
|
518
|
+
"type": "string",
|
|
519
|
+
"enum": [
|
|
520
|
+
"firm",
|
|
521
|
+
"default",
|
|
522
|
+
"exploratory"
|
|
523
|
+
],
|
|
524
|
+
"description": "Requirement and ADR only. How firmly the decision was made. firm: a human stated it as a rule; it needs a ref (origin.ref, or approval_ref on a requirement) to their words, and only a human may change it. default (assumed when absent): a delegated or agent choice; a later agent may supersede it with evidence. exploratory: a flagged guess, expected to be revisited."
|
|
525
|
+
},
|
|
517
526
|
"expects": {
|
|
518
527
|
"type": "string",
|
|
519
528
|
"enum": [
|
|
@@ -1657,6 +1666,25 @@
|
|
|
1657
1666
|
}
|
|
1658
1667
|
}
|
|
1659
1668
|
},
|
|
1669
|
+
{
|
|
1670
|
+
"if": {
|
|
1671
|
+
"properties": {
|
|
1672
|
+
"type": {
|
|
1673
|
+
"enum": [
|
|
1674
|
+
"req",
|
|
1675
|
+
"adr"
|
|
1676
|
+
]
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
},
|
|
1680
|
+
"else": {
|
|
1681
|
+
"not": {
|
|
1682
|
+
"required": [
|
|
1683
|
+
"firmness"
|
|
1684
|
+
]
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
},
|
|
1660
1688
|
{
|
|
1661
1689
|
"if": {
|
|
1662
1690
|
"properties": {
|
|
@@ -1675,35 +1703,12 @@
|
|
|
1675
1703
|
},
|
|
1676
1704
|
{
|
|
1677
1705
|
"if": {
|
|
1678
|
-
"
|
|
1679
|
-
|
|
1680
|
-
"required": [
|
|
1681
|
-
"claim_key"
|
|
1682
|
-
]
|
|
1683
|
-
},
|
|
1684
|
-
{
|
|
1685
|
-
"required": [
|
|
1686
|
-
"claim_text"
|
|
1687
|
-
],
|
|
1688
|
-
"not": {
|
|
1689
|
-
"properties": {
|
|
1690
|
-
"fact_kind": {
|
|
1691
|
-
"enum": [
|
|
1692
|
-
"observation",
|
|
1693
|
-
"meta"
|
|
1694
|
-
]
|
|
1695
|
-
}
|
|
1696
|
-
},
|
|
1697
|
-
"required": [
|
|
1698
|
-
"fact_kind"
|
|
1699
|
-
]
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1706
|
+
"required": [
|
|
1707
|
+
"claim_key"
|
|
1702
1708
|
]
|
|
1703
1709
|
},
|
|
1704
1710
|
"then": {
|
|
1705
1711
|
"required": [
|
|
1706
|
-
"claim_key",
|
|
1707
1712
|
"claim_text"
|
|
1708
1713
|
]
|
|
1709
1714
|
}
|
package/dist/search-answer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Firmness } from "./decision-firmness.js";
|
|
1
2
|
import type { IntentSearchMatch } from "./intent-search.js";
|
|
2
3
|
import type { PrologPort } from "./public/operations/runtime-types.js";
|
|
3
4
|
/**
|
|
@@ -19,6 +20,12 @@ export type SearchAnswerEntity = Readonly<{
|
|
|
19
20
|
id: string;
|
|
20
21
|
title: string;
|
|
21
22
|
status?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Requirements and ADRs: how firmly the decision was made. `firm` (a human
|
|
25
|
+
* stated it; ask before changing), `default` (supersede it with evidence),
|
|
26
|
+
* `exploratory` (a guess to revisit).
|
|
27
|
+
*/
|
|
28
|
+
firmness?: Firmness;
|
|
22
29
|
}>;
|
|
23
30
|
/**
|
|
24
31
|
* A test verifying a governing requirement. `via` is `"direct"` for a test
|
|
@@ -69,8 +76,13 @@ export type SearchAnswerException = SearchAnswerEntity & Readonly<{
|
|
|
69
76
|
/**
|
|
70
77
|
* A linked fact says what it states in its typed form, so an agent can read
|
|
71
78
|
* `has_role(alice, admin)` or `user.role_assignment max_roles lte 2` without
|
|
72
|
-
* opening the entity, and `ask` is the
|
|
73
|
-
*
|
|
79
|
+
* opening the entity, and `ask` is the kb_query that reproduces the fact's
|
|
80
|
+
* own tuple as precisely as kb_query supports: a property or subject fact by
|
|
81
|
+
* its keys; a predicate fact by name plus, when a project `predicate_schema`
|
|
82
|
+
* or the built-in signature declares its arguments, `where` over the key
|
|
83
|
+
* arguments (the declared `key_arguments`, else the argument named `subject`,
|
|
84
|
+
* else the first), otherwise its full positional `args`. Pasted, it returns
|
|
85
|
+
* the fact and only facts sharing those key arguments.
|
|
74
86
|
*/
|
|
75
87
|
export type SearchAnswerFact = SearchAnswerEntity & Readonly<{
|
|
76
88
|
factKind?: string;
|
|
@@ -142,6 +154,23 @@ export declare const SEARCH_ANSWER_LIMITS: {
|
|
|
142
154
|
/** Characters of a witness or unknown detail kept. */
|
|
143
155
|
readonly detailChars: 240;
|
|
144
156
|
};
|
|
157
|
+
/**
|
|
158
|
+
* The declared arguments of a predicate fact's schema: a project
|
|
159
|
+
* `predicate_schema` or the built-in signature kb_query resolves `where`
|
|
160
|
+
* names against. `keyArguments` is empty when the schema declares none.
|
|
161
|
+
*/
|
|
162
|
+
export type PredicateFactSchema = Readonly<{
|
|
163
|
+
argumentNames: readonly string[];
|
|
164
|
+
keyArguments: readonly string[];
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* The `where` filter that selects the facts sharing a predicate fact's key
|
|
168
|
+
* arguments: the schema's `key_arguments`, else the argument named `subject`,
|
|
169
|
+
* else the first argument. Undefined when the schema does not fit the fact
|
|
170
|
+
* (arity) or no key argument has a value, so the caller falls back to
|
|
171
|
+
* positional args.
|
|
172
|
+
*/
|
|
173
|
+
export declare function predicateKeyFilter(args: readonly string[], schema: PredicateFactSchema): Record<string, string> | undefined;
|
|
145
174
|
/**
|
|
146
175
|
* The opening sentences of an ADR's Decision section (falling back to
|
|
147
176
|
* Rationale, then to the first prose paragraph), as plain text of at most
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-answer.d.ts","sourceRoot":"","sources":["../src/search-answer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"search-answer.d.ts","sourceRoot":"","sources":["../src/search-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAY5D,OAAO,KAAK,EACV,UAAU,EAEX,MAAM,sCAAsC,CAAC;AAI9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH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C,EAAE,OAAO,CAAC;CACrB,CAAC,CAAC;AAkCH,4EAA4E;AAE5E,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,GAAG,SAAS,EAC3B,cAAc,GAAE,MAA4C,GAC3D;IACD,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,SAAS,EAAE,OAAO,CAAC;CACpB,CAyGA;AA6ED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EACrC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC,CAiUvB;AAmED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,EACpB,QAAQ,GAAE,MAAsC,GAC/C,YAAY,CAmGd"}
|
package/dist/search-answer.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { effectiveFirmness } from "./decision-firmness.js";
|
|
2
|
+
import { escapeAtom, normalizeEntityId, parseAtomList, parseEntityFromList, parseListOfLists, parseTriples, } from "./prolog/codec.js";
|
|
2
3
|
import { isProvenanceStub } from "./provenance-stub.js";
|
|
3
4
|
import { entityRowsGoal } from "./public/operations/discovery-entities.js";
|
|
4
5
|
import { runOperationJsonQuery } from "./public/operations/prolog-json.js";
|
|
@@ -41,6 +42,7 @@ const ROW_KEYS = [
|
|
|
41
42
|
"status",
|
|
42
43
|
"fact_kind",
|
|
43
44
|
"approved_by",
|
|
45
|
+
"firmness",
|
|
44
46
|
"source",
|
|
45
47
|
"sourceFile",
|
|
46
48
|
"predicate_namespace",
|
|
@@ -84,30 +86,68 @@ function unique(ids) {
|
|
|
84
86
|
}
|
|
85
87
|
function brief(entity) {
|
|
86
88
|
const status = text(entity.status);
|
|
89
|
+
const firmness = effectiveFirmness(entity.type, entity.firmness);
|
|
87
90
|
return {
|
|
88
91
|
id: text(entity.id),
|
|
89
92
|
title: text(entity.title),
|
|
90
93
|
...(status ? { status } : {}),
|
|
94
|
+
...(firmness ? { firmness } : {}),
|
|
91
95
|
};
|
|
92
96
|
}
|
|
93
97
|
function queryCall(args) {
|
|
94
98
|
return `kb_query(${JSON.stringify(args)})`;
|
|
95
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The `where` filter that selects the facts sharing a predicate fact's key
|
|
102
|
+
* arguments: the schema's `key_arguments`, else the argument named `subject`,
|
|
103
|
+
* else the first argument. Undefined when the schema does not fit the fact
|
|
104
|
+
* (arity) or no key argument has a value, so the caller falls back to
|
|
105
|
+
* positional args.
|
|
106
|
+
*/
|
|
107
|
+
// implements REQ-kibi-query-fact-filters
|
|
108
|
+
export function predicateKeyFilter(args, schema) {
|
|
109
|
+
const names = schema.argumentNames;
|
|
110
|
+
if (names.length === 0 || names.length !== args.length)
|
|
111
|
+
return undefined;
|
|
112
|
+
const declared = schema.keyArguments.filter((key) => names.includes(key));
|
|
113
|
+
const keys = declared.length > 0
|
|
114
|
+
? declared
|
|
115
|
+
: [names.includes("subject") ? "subject" : names[0]];
|
|
116
|
+
const where = {};
|
|
117
|
+
for (const key of keys) {
|
|
118
|
+
const value = args[names.indexOf(key)] ?? "";
|
|
119
|
+
if (value !== "")
|
|
120
|
+
where[key] = value;
|
|
121
|
+
}
|
|
122
|
+
return Object.keys(where).length > 0 ? where : undefined;
|
|
123
|
+
}
|
|
96
124
|
/** Typed statement and follow-up query of a linked fact, by fact kind. */
|
|
97
125
|
// implements REQ-kibi-query-fact-filters
|
|
98
|
-
function factDetail(fact) {
|
|
126
|
+
function factDetail(fact, schema) {
|
|
99
127
|
const factKind = text(fact.fact_kind);
|
|
100
128
|
const base = factKind ? { factKind } : {};
|
|
101
129
|
const predicate = text(fact.predicate_name);
|
|
102
130
|
if (factKind === "predicate" && predicate) {
|
|
103
131
|
const args = Array.isArray(fact.predicate_args)
|
|
104
|
-
? fact.predicate_args.map(text)
|
|
105
|
-
:
|
|
132
|
+
? fact.predicate_args.map(text)
|
|
133
|
+
: undefined;
|
|
106
134
|
const polarity = text(fact.polarity) === "deny" ? " [deny]" : "";
|
|
135
|
+
const namespace = text(fact.predicate_namespace);
|
|
136
|
+
const call = {
|
|
137
|
+
predicate,
|
|
138
|
+
...(namespace && namespace !== "default" ? { namespace } : {}),
|
|
139
|
+
};
|
|
140
|
+
if (args !== undefined && args.length > 0) {
|
|
141
|
+
const where = schema ? predicateKeyFilter(args, schema) : undefined;
|
|
142
|
+
if (where)
|
|
143
|
+
call.where = where;
|
|
144
|
+
else
|
|
145
|
+
call.args = args.map((value) => (value === "" ? null : value));
|
|
146
|
+
}
|
|
107
147
|
return {
|
|
108
148
|
...base,
|
|
109
|
-
claim: `${predicate}(${args})${polarity}`,
|
|
110
|
-
ask: queryCall(
|
|
149
|
+
claim: `${predicate}(${args?.join(", ") ?? text(fact.predicate_args)})${polarity}`,
|
|
150
|
+
ask: queryCall(call),
|
|
111
151
|
};
|
|
112
152
|
}
|
|
113
153
|
const subjectKey = text(fact.subject_key);
|
|
@@ -128,6 +168,27 @@ function edgesGoal(ids) {
|
|
|
128
168
|
const idList = ids.map((id) => `'${escapeAtom(id)}'`).join(",");
|
|
129
169
|
return `findall([Rel,From,To], (member(Rel, [${ANSWER_RELATIONSHIPS.join(",")}]), kb_relationship(Rel, From, To), (member(From, [${idList}]); member(To, [${idList}]))), Edges)`;
|
|
130
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* For each predicate fact among `ids`, the argument names and key arguments
|
|
173
|
+
* of the schema kb_query resolves its `where` names against: the project
|
|
174
|
+
* `predicate_schema` of its namespace and name, else the built-in signature.
|
|
175
|
+
* Facts of other kinds, and predicates without a schema, yield no row.
|
|
176
|
+
*/
|
|
177
|
+
// implements REQ-kibi-query-fact-filters
|
|
178
|
+
function factSchemasGoal(ids) {
|
|
179
|
+
const idList = ids.map((id) => `'${escapeAtom(id)}'`).join(",");
|
|
180
|
+
return `findall([FactId,Names,Keys], (member(FactId, [${idList}]), kb:predicate_fact(FactId, Ns, Name, _, _), ((kb:predicate_schema(SchemaId, Ns, Name, _, Names, _) -> ((kb_entity(SchemaId, fact, Props), memberchk(key_arguments=KeysRaw, Props), kb:normalize_term_atom_list(KeysRaw, Keys)) -> true ; Keys = [])) ; (kb:builtin_decision_predicate(Ns, Name, _, KeyPositions, _), kb:builtin_predicate_signature(Name, _, Names), findall(Key, (member(P, KeyPositions), nth1(P, Names, Key)), Keys)))), Schemas)`;
|
|
181
|
+
}
|
|
182
|
+
function parseFactSchemas(raw) {
|
|
183
|
+
const schemas = new Map();
|
|
184
|
+
for (const [id, names, keys] of parseTriples(raw ?? "[]")) {
|
|
185
|
+
schemas.set(normalizeEntityId(id), {
|
|
186
|
+
argumentNames: parseAtomList(names),
|
|
187
|
+
keyArguments: parseAtomList(keys),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return schemas;
|
|
191
|
+
}
|
|
131
192
|
/**
|
|
132
193
|
* The part of the KB graph the answer reads, fetched in batches: each
|
|
133
194
|
* `fetch` is one engine round trip for every id whose edges or row are not
|
|
@@ -489,6 +550,29 @@ async function fetchVerdicts(prolog, graph, rowIds, reqIds) {
|
|
|
489
550
|
return undefined;
|
|
490
551
|
}
|
|
491
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* The rows the answer still needs plus the schemas of the predicate facts
|
|
555
|
+
* among `factIds`, in one round trip. A schema lookup the engine cannot run
|
|
556
|
+
* leaves the rows loaded and every ask positional.
|
|
557
|
+
*/
|
|
558
|
+
// implements REQ-kibi-query-fact-filters
|
|
559
|
+
async function fetchFactSchemas(graph, factIds, request) {
|
|
560
|
+
if (factIds.length === 0) {
|
|
561
|
+
await graph.fetch(request);
|
|
562
|
+
return new Map();
|
|
563
|
+
}
|
|
564
|
+
try {
|
|
565
|
+
const bindings = await graph.fetch({
|
|
566
|
+
...request,
|
|
567
|
+
alsoGoal: factSchemasGoal(factIds),
|
|
568
|
+
});
|
|
569
|
+
return parseFactSchemas(bindings.Schemas);
|
|
570
|
+
}
|
|
571
|
+
catch {
|
|
572
|
+
await graph.fetch(request);
|
|
573
|
+
return new Map();
|
|
574
|
+
}
|
|
575
|
+
}
|
|
492
576
|
// implements REQ-bootstrap-provenance-stubs
|
|
493
577
|
export async function buildSearchAnswer(prolog, matches, options = {}) {
|
|
494
578
|
const limits = SEARCH_ANSWER_LIMITS;
|
|
@@ -551,13 +635,9 @@ export async function buildSearchAnswer(prolog, matches, options = {}) {
|
|
|
551
635
|
continue;
|
|
552
636
|
}
|
|
553
637
|
if (owners.length === 0 && ["fact", "scenario", "symbol"].includes(type)) {
|
|
638
|
+
// A fact's claim and ask are filled in once its schema is known.
|
|
554
639
|
if (ungoverned.length < limits.ungoverned)
|
|
555
|
-
ungoverned.push({
|
|
556
|
-
...brief(entity),
|
|
557
|
-
...(type === "fact" ? factDetail(entity) : {}),
|
|
558
|
-
type,
|
|
559
|
-
rank: index + 1,
|
|
560
|
-
});
|
|
640
|
+
ungoverned.push({ ...brief(entity), type, rank: index + 1 });
|
|
561
641
|
else
|
|
562
642
|
truncated = true;
|
|
563
643
|
continue;
|
|
@@ -689,7 +769,13 @@ export async function buildSearchAnswer(prolog, matches, options = {}) {
|
|
|
689
769
|
exceptions: firstOf(into("exempts")),
|
|
690
770
|
};
|
|
691
771
|
});
|
|
692
|
-
|
|
772
|
+
// The schemas of the linked and ungoverned predicate facts share this
|
|
773
|
+
// round trip, so each fact's ask can name its key arguments.
|
|
774
|
+
const factIds = unique([
|
|
775
|
+
...ungoverned.filter((entry) => entry.type === "fact").map((e) => e.id),
|
|
776
|
+
...plans.flatMap((plan) => plan.facts),
|
|
777
|
+
]);
|
|
778
|
+
const schemas = await fetchFactSchemas(graph, factIds, {
|
|
693
779
|
edges: plans.flatMap((plan) => plan.scenarios),
|
|
694
780
|
rows: plans.flatMap((plan) => [
|
|
695
781
|
...plan.facts,
|
|
@@ -699,6 +785,18 @@ export async function buildSearchAnswer(prolog, matches, options = {}) {
|
|
|
699
785
|
...plan.directTests.slice(0, limits.perRequirement),
|
|
700
786
|
]),
|
|
701
787
|
});
|
|
788
|
+
const detailedUngoverned = ungoverned.map((entry) => {
|
|
789
|
+
const row = entry.type === "fact" ? graph.row(entry.id) : null;
|
|
790
|
+
if (row === null)
|
|
791
|
+
return entry;
|
|
792
|
+
const { type, rank } = entry;
|
|
793
|
+
return {
|
|
794
|
+
...brief(row),
|
|
795
|
+
...factDetail(row, schemas.get(entry.id)),
|
|
796
|
+
type,
|
|
797
|
+
rank,
|
|
798
|
+
};
|
|
799
|
+
});
|
|
702
800
|
// Tests linked to the requirement itself come first, then tests that
|
|
703
801
|
// verify one of its scenarios; a test reached both ways counts as direct.
|
|
704
802
|
const testVias = plans.map((plan) => {
|
|
@@ -738,7 +836,7 @@ export async function buildSearchAnswer(prolog, matches, options = {}) {
|
|
|
738
836
|
via: req.via,
|
|
739
837
|
facts: rowsOf(plan.facts).map((fact) => ({
|
|
740
838
|
...brief(fact),
|
|
741
|
-
...factDetail(fact),
|
|
839
|
+
...factDetail(fact, schemas.get(text(fact.id))),
|
|
742
840
|
})),
|
|
743
841
|
scenarios: rowsOf(plan.scenarios).map(brief),
|
|
744
842
|
tests: rowsOf(testIds[index] ?? []).map((row) => ({
|
|
@@ -769,17 +867,17 @@ export async function buildSearchAnswer(prolog, matches, options = {}) {
|
|
|
769
867
|
? verdicts.scope.syncedAt
|
|
770
868
|
: null,
|
|
771
869
|
};
|
|
772
|
-
|
|
870
|
+
detailedUngoverned.sort((left, right) => left.rank - right.rank);
|
|
773
871
|
const answer = {
|
|
774
872
|
version: "kibi.search-answer.v1",
|
|
775
873
|
governing,
|
|
776
874
|
rationale,
|
|
777
875
|
notGoverning,
|
|
778
876
|
observations: observations.slice(0, limits.observations),
|
|
779
|
-
ungoverned,
|
|
877
|
+
ungoverned: detailedUngoverned,
|
|
780
878
|
scope,
|
|
781
879
|
truncated: truncated || graph.truncated,
|
|
782
|
-
note: answerNote(governing.length,
|
|
880
|
+
note: answerNote(governing.length, detailedUngoverned),
|
|
783
881
|
};
|
|
784
882
|
return fitSearchAnswer(answer, limits.maxBytes);
|
|
785
883
|
}
|
package/dist/types/entities.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export type Requirement = BaseEntity & {
|
|
|
67
67
|
approval_ref?: string;
|
|
68
68
|
/** Why the requirement exists; explanation, not checked meaning. */
|
|
69
69
|
rationale?: string;
|
|
70
|
+
/** How firmly it was decided; absent reads as default. */
|
|
71
|
+
firmness?: "firm" | "default" | "exploratory";
|
|
70
72
|
/** Exception requirements only: claim keys of the exempted requirement it waives. */
|
|
71
73
|
exempts_claims?: string[];
|
|
72
74
|
};
|
|
@@ -78,6 +80,8 @@ export type TestEntity = BaseEntity & TestVerificationFields & {
|
|
|
78
80
|
};
|
|
79
81
|
export type ADR = BaseEntity & {
|
|
80
82
|
type: "adr";
|
|
83
|
+
/** How firmly it was decided; absent reads as default. */
|
|
84
|
+
firmness?: "firm" | "default" | "exploratory";
|
|
81
85
|
};
|
|
82
86
|
export type Flag = BaseEntity & {
|
|
83
87
|
type: "flag";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB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,CAAC;AACrD,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,MAAM,GACd,WAAW,GACX,QAAQ,GACR,UAAU,GACV,GAAG,GACH,IAAI,GACJ,KAAK,GACL,MAAM,GACN,IAAI,CAAC"}
|
|
@@ -20,6 +20,12 @@ export interface KbManifest {
|
|
|
20
20
|
* Only these ids may carry `review:context-missing` without a violation.
|
|
21
21
|
*/
|
|
22
22
|
contextAcknowledged?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Supersede edges (`FROM -> TO`) the schema 9 migration acknowledged as
|
|
25
|
+
* lacking a "Why this changed" section. An entity is exempt from
|
|
26
|
+
* supersedes-reason-missing only while every edge it has is listed here.
|
|
27
|
+
*/
|
|
28
|
+
supersedesReasonAcknowledged?: string[];
|
|
23
29
|
}
|
|
24
30
|
export declare function defaultKbManifest(): KbManifest;
|
|
25
31
|
export type KbManifestStatus = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kb-manifest.d.ts","sourceRoot":"","sources":["../../src/utils/kb-manifest.ts"],"names":[],"mappings":"AA8BA;;;;;;;GAOG;AAEH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,WAAW,GACX,gBAAgB,CAAC;AAErB,MAAM,WAAW,UAAU;IACzB,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"kb-manifest.d.ts","sourceRoot":"","sources":["../../src/utils/kb-manifest.ts"],"names":[],"mappings":"AA8BA;;;;;;;GAOG;AAEH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,WAAW,GACX,gBAAgB,CAAC;AAErB,MAAM,WAAW,UAAU;IACzB,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,MAAM,EAAE,CAAC;CACzC;AAED,wBAAgB,iBAAiB,IAAI,UAAU,CAM9C;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAClE;IACE,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxC,QAAQ,EAAE,IAAI,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA+DN,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,gBAAgB,CAyD5E;AAED,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAGvE;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAEzE;AASD,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,UAAU,GACnB,MAAM,CAIR"}
|
|
@@ -71,6 +71,7 @@ function validateManifest(parsed) {
|
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
const acknowledged = parsed.contextAcknowledged;
|
|
74
|
+
const supersedesAcknowledged = parsed.supersedesReasonAcknowledged;
|
|
74
75
|
return {
|
|
75
76
|
manifestVersion,
|
|
76
77
|
schemaVersion,
|
|
@@ -80,6 +81,11 @@ function validateManifest(parsed) {
|
|
|
80
81
|
contextAcknowledged: acknowledged.filter((id) => typeof id === "string"),
|
|
81
82
|
}
|
|
82
83
|
: {}),
|
|
84
|
+
...(Array.isArray(supersedesAcknowledged)
|
|
85
|
+
? {
|
|
86
|
+
supersedesReasonAcknowledged: supersedesAcknowledged.filter((id) => typeof id === "string"),
|
|
87
|
+
}
|
|
88
|
+
: {}),
|
|
83
89
|
};
|
|
84
90
|
}
|
|
85
91
|
export function readKbManifestStatus(workspaceRoot) {
|
|
@@ -228,6 +228,27 @@ export declare const GENERATED_RULES: readonly [{
|
|
|
228
228
|
readonly enforcementClass: "advisory";
|
|
229
229
|
readonly category: "lifecycle";
|
|
230
230
|
readonly diagnosticSeverity: "info";
|
|
231
|
+
}, {
|
|
232
|
+
readonly name: "decision-firm-unreferenced";
|
|
233
|
+
readonly description: "A requirement or ADR marked firmness: firm must name the human words it rests on: origin.ref (or approval_ref on a requirement); Kibi checks that the reference is present, not that it is genuine";
|
|
234
|
+
readonly enforcementClass: "canonical";
|
|
235
|
+
readonly category: "integrity";
|
|
236
|
+
}, {
|
|
237
|
+
readonly name: "decision-firm-superseded";
|
|
238
|
+
readonly description: "A requirement or ADR that supersedes a firm decision, retired or not, must itself be firm (and so carry a ref to the human who changed the rule); a default or exploratory replacement cannot overrule a firm decision";
|
|
239
|
+
readonly enforcementClass: "canonical";
|
|
240
|
+
readonly category: "lifecycle";
|
|
241
|
+
}, {
|
|
242
|
+
readonly name: "supersedes-reason-missing";
|
|
243
|
+
readonly description: "A current requirement or ADR that supersedes another must explain why under a 'Why this changed' heading (at least 12 words of prose naming the evidence and answering the old decision's reasoning); supersede edges recorded before schema 9 are acknowledged in the manifest and exempt";
|
|
244
|
+
readonly enforcementClass: "canonical";
|
|
245
|
+
readonly category: "lifecycle";
|
|
246
|
+
}, {
|
|
247
|
+
readonly name: "supersedes-reason-acknowledged";
|
|
248
|
+
readonly description: "Informational: how many current superseding requirements and ADRs have only supersede edges the schema 9 migration acknowledged without a 'Why this changed' section; one summary finding per check";
|
|
249
|
+
readonly enforcementClass: "advisory";
|
|
250
|
+
readonly category: "lifecycle";
|
|
251
|
+
readonly diagnosticSeverity: "info";
|
|
231
252
|
}, {
|
|
232
253
|
readonly name: "policy-ownership";
|
|
233
254
|
readonly description: "When a plugin activated for kibi.check-policy.v1 declares ownership rules, every production symbol in a rule's file set must implement a current requirement grounded (requires_predicate) in one of the rule's predicates; projects without an activated check policy are unaffected";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-registry.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.generated.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"rule-registry.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.generated.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyWlB,CAAC"}
|
|
@@ -283,6 +283,31 @@ export const GENERATED_RULES = [
|
|
|
283
283
|
category: "lifecycle",
|
|
284
284
|
diagnosticSeverity: "info",
|
|
285
285
|
},
|
|
286
|
+
{
|
|
287
|
+
name: "decision-firm-unreferenced",
|
|
288
|
+
description: "A requirement or ADR marked firmness: firm must name the human words it rests on: origin.ref (or approval_ref on a requirement); Kibi checks that the reference is present, not that it is genuine",
|
|
289
|
+
enforcementClass: "canonical",
|
|
290
|
+
category: "integrity",
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "decision-firm-superseded",
|
|
294
|
+
description: "A requirement or ADR that supersedes a firm decision, retired or not, must itself be firm (and so carry a ref to the human who changed the rule); a default or exploratory replacement cannot overrule a firm decision",
|
|
295
|
+
enforcementClass: "canonical",
|
|
296
|
+
category: "lifecycle",
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "supersedes-reason-missing",
|
|
300
|
+
description: "A current requirement or ADR that supersedes another must explain why under a 'Why this changed' heading (at least 12 words of prose naming the evidence and answering the old decision's reasoning); supersede edges recorded before schema 9 are acknowledged in the manifest and exempt",
|
|
301
|
+
enforcementClass: "canonical",
|
|
302
|
+
category: "lifecycle",
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "supersedes-reason-acknowledged",
|
|
306
|
+
description: "Informational: how many current superseding requirements and ADRs have only supersede edges the schema 9 migration acknowledged without a 'Why this changed' section; one summary finding per check",
|
|
307
|
+
enforcementClass: "advisory",
|
|
308
|
+
category: "lifecycle",
|
|
309
|
+
diagnosticSeverity: "info",
|
|
310
|
+
},
|
|
286
311
|
{
|
|
287
312
|
name: "policy-ownership",
|
|
288
313
|
description: "When a plugin activated for kibi.check-policy.v1 declares ownership rules, every production symbol in a rule's file set must implement a current requirement grounded (requires_predicate) in one of the rule's predicates; projects without an activated check policy are unaffected",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-version.d.ts","sourceRoot":"","sources":["../../src/utils/schema-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-version.d.ts","sourceRoot":"","sources":["../../src/utils/schema-version.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IAC9D,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GACrD,IAAI,GACJ,SAAS,CAAC;AAGd,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAChD,MAAM,GAAG,IAAI,CAgBf;AAGD,wBAAgB,sBAAsB,CACpC,MAAM,CAAC,EAAE,mBAAmB,GAC3B,mBAAmB,CAgDrB"}
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
// implements REQ-003
|
|
19
19
|
// Schema 8 requires body context on current entities and pins requirement
|
|
20
20
|
// semantic_text so context sections never change a requirement's meaning.
|
|
21
|
-
|
|
21
|
+
// Schema 9 adds decision firmness on requirements and ADRs and requires a
|
|
22
|
+
// "Why this changed" section on new supersedes.
|
|
23
|
+
export const LATEST_KB_SCHEMA_VERSION = 9;
|
|
22
24
|
// implements REQ-003
|
|
23
25
|
export function normalizeSchemaVersion(schemaVersion) {
|
|
24
26
|
if (schemaVersion === undefined || schemaVersion === null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Kibi CLI for knowledge base management",
|
|
6
6
|
"engines": {
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
"fast-glob": "^3.2.12",
|
|
236
236
|
"gray-matter": "^4.0.3",
|
|
237
237
|
"js-yaml": "^4.1.0",
|
|
238
|
-
"kibi-core": "^0.21.
|
|
238
|
+
"kibi-core": "^0.21.1",
|
|
239
239
|
"kibi-plugin-builtin": "^0.5.1",
|
|
240
240
|
"kibi-plugin-sdk": "^0.5.0",
|
|
241
241
|
"kibi-swipl": "^1.0.1",
|
package/schema/entities.pl
CHANGED
|
@@ -51,6 +51,10 @@ entity_property(req, approval_ref, string).
|
|
|
51
51
|
entity_property(req, rationale, string).
|
|
52
52
|
% Claim keys of the exempted requirement an exception waives (all when absent).
|
|
53
53
|
entity_property(req, exempts_claims, list).
|
|
54
|
+
% How firmly a requirement or ADR was decided: firm, default or exploratory.
|
|
55
|
+
% Absent reads as default.
|
|
56
|
+
entity_property(req, firmness, atom).
|
|
57
|
+
entity_property(adr, firmness, atom).
|
|
54
58
|
% Intended outcome of a scenario: success, rejection or error.
|
|
55
59
|
entity_property(scenario, expects, atom).
|
|
56
60
|
|
|
@@ -143,6 +147,8 @@ optional_property(req, approved_by).
|
|
|
143
147
|
optional_property(req, approval_ref).
|
|
144
148
|
optional_property(req, rationale).
|
|
145
149
|
optional_property(req, exempts_claims).
|
|
150
|
+
optional_property(req, firmness).
|
|
151
|
+
optional_property(adr, firmness).
|
|
146
152
|
optional_property(test, verification_scope).
|
|
147
153
|
optional_property(test, verification_perspective).
|
|
148
154
|
optional_property(test, proof_contract).
|