kibi-cli 0.17.0 → 0.18.1
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-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +87 -11
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +8 -0
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +5 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +1 -0
- package/dist/commands/coverage.d.ts +5 -0
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +5 -0
- package/dist/commands/discovery-table.d.ts.map +1 -1
- package/dist/commands/discovery-table.js +96 -5
- package/dist/commands/sync/cache.d.ts +2 -0
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +8 -0
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +58 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +72 -15
- package/dist/commands/usage-metrics.d.ts +66 -2
- package/dist/commands/usage-metrics.d.ts.map +1 -1
- package/dist/commands/usage-metrics.js +34 -24
- package/dist/commands/usage-remediation.d.ts +9 -0
- package/dist/commands/usage-remediation.d.ts.map +1 -0
- package/dist/commands/usage-remediation.js +52 -0
- package/dist/extractors/markdown.d.ts +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +69 -2
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +14 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +27 -2
- package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +18 -6
- package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-inference.js +5 -17
- package/dist/operations/modeling/predicate-loader.js +1 -1
- package/dist/operations/modeling/predicate-types.d.ts +9 -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 +35 -11
- package/dist/operations/mutation/audit.js +1 -1
- package/dist/operations/mutation/contradictions.d.ts +1 -1
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +23 -18
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +6 -3
- package/dist/operations/mutation/upsert.d.ts +3 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +51 -12
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +18 -2
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +8 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +76 -61
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +7 -7
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
- package/dist/operations/semantic-advisor/shared.d.ts +8 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/shared.js +37 -3
- package/dist/operations/semantic-advisor/types.d.ts +5 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +9 -2
- package/dist/prolog.d.ts +6 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +240 -61
- package/dist/public/diagnostic-usage.d.ts +17 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -0
- package/dist/public/diagnostic-usage.js +152 -0
- package/dist/public/distribution-parity.d.ts +90 -0
- package/dist/public/distribution-parity.d.ts.map +1 -0
- package/dist/public/distribution-parity.js +367 -0
- package/dist/public/impact/full-kb-quality.d.ts +2 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +53 -1
- package/dist/public/impact-diagnostics.d.ts +2 -0
- package/dist/public/impact-diagnostics.d.ts.map +1 -1
- package/dist/public/impact-diagnostics.js +1 -0
- package/dist/public/operations/catalog.d.ts +151 -6
- 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 +4 -0
- package/dist/public/operations/discovery-executors.d.ts +6 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +18 -2
- package/dist/public/operations/index.d.ts +4 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +4 -0
- package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
- package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
- package/dist/public/operations/legacy-migration-plan.js +409 -0
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +90 -0
- package/dist/public/operations/repair-plan.d.ts +184 -0
- package/dist/public/operations/repair-plan.d.ts.map +1 -0
- package/dist/public/operations/repair-plan.js +397 -0
- package/dist/public/operations/runtime-types.d.ts +7 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check.d.ts +2 -2
- package/dist/public/operations/specs/check.js +2 -2
- package/dist/public/operations/specs/discovery.d.ts +1 -1
- package/dist/public/operations/specs/discovery.js +1 -1
- package/dist/public/operations/specs/modeling.d.ts +19 -1
- package/dist/public/operations/specs/modeling.d.ts.map +1 -1
- package/dist/public/operations/specs/modeling.js +16 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +96 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +40 -1
- package/dist/public/operations/specs/reporting.d.ts +42 -1
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +70 -6
- package/dist/public/operations/specs/semantic.js +1 -1
- package/dist/public/operations/specs/upsert.d.ts +96 -1
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/workspace-snapshot.d.ts +10 -0
- package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
- package/dist/public/operations/workspace-snapshot.js +20 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +43 -1
- package/dist/public/skills/kibi-traceability/SKILL.md +7 -1
- package/dist/public/skills/kibi-usage/SKILL.md +10 -4
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +1 -1
- package/dist/public/skills/kibi-usage/resources/workflows.md +19 -2
- package/dist/public/telemetry-acceptance.d.ts +89 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -0
- package/dist/public/telemetry-acceptance.js +597 -0
- package/dist/public/telemetry-remediation.d.ts +33 -0
- package/dist/public/telemetry-remediation.d.ts.map +1 -0
- package/dist/public/telemetry-remediation.js +257 -0
- package/dist/public/verification-receipt.d.ts +75 -0
- package/dist/public/verification-receipt.d.ts.map +1 -0
- package/dist/public/verification-receipt.js +129 -0
- package/dist/schemas/entity.schema.json +96 -2
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +36 -3
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/rule-registry.d.ts +2 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/package.json +30 -2
- package/src/public/diagnostic-usage.ts +206 -0
- package/src/public/distribution-parity.ts +580 -0
- package/src/public/impact/full-kb-quality.ts +74 -1
- package/src/public/impact-diagnostics.ts +16 -0
- package/src/public/operations/check-executor.ts +4 -0
- package/src/public/operations/discovery-executors.ts +24 -2
- package/src/public/operations/index.ts +4 -0
- package/src/public/operations/legacy-migration-plan.ts +688 -0
- package/src/public/operations/node-ports.ts +109 -0
- package/src/public/operations/repair-plan.ts +562 -0
- package/src/public/operations/runtime-types.ts +8 -0
- package/src/public/operations/specs/check.ts +2 -2
- package/src/public/operations/specs/discovery.ts +1 -1
- package/src/public/operations/specs/modeling.ts +19 -1
- package/src/public/operations/specs/mutation-schemas.ts +47 -1
- package/src/public/operations/specs/reporting.ts +91 -6
- package/src/public/operations/specs/semantic.ts +1 -1
- package/src/public/operations/workspace-snapshot.ts +28 -0
- package/src/public/schemas/entity.ts +44 -1
- package/src/public/skills/kibi-traceability/SKILL.md +7 -1
- package/src/public/skills/kibi-usage/SKILL.md +10 -4
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/src/public/skills/kibi-usage/resources/logic-ir.md +1 -1
- package/src/public/skills/kibi-usage/resources/workflows.md +19 -2
- package/src/public/telemetry-acceptance.ts +859 -0
- package/src/public/telemetry-remediation.ts +462 -0
- package/src/public/verification-receipt.ts +170 -0
- package/src/schemas/entity.schema.json +96 -2
|
@@ -31,8 +31,16 @@ export interface FilesystemPort {
|
|
|
31
31
|
export interface GitPort {
|
|
32
32
|
revParse(...args: readonly string[]): Promise<string>;
|
|
33
33
|
showToplevel(): Promise<string>;
|
|
34
|
+
workspaceSnapshot?(workspaceRoot: string): Promise<WorkspaceSnapshot>;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
export type WorkspaceSnapshot = Readonly<{
|
|
38
|
+
version: "kibi.workspace-snapshot.v1";
|
|
39
|
+
hash: string;
|
|
40
|
+
dirty: boolean;
|
|
41
|
+
fileCount: number;
|
|
42
|
+
}>;
|
|
43
|
+
|
|
36
44
|
export interface NetworkPort {
|
|
37
45
|
fetch(input: string | URL, init?: RequestInit): Promise<Response>;
|
|
38
46
|
}
|
|
@@ -5,7 +5,7 @@ export const checkSpec = {
|
|
|
5
5
|
name: "kb_check",
|
|
6
6
|
cliName: "check",
|
|
7
7
|
description:
|
|
8
|
-
"Run KB validation rules and return violations. Use before or after mutations, and after meaningful source edits with impact options to surface symbol granularity and semantic-review diagnostics. Do not use for point lookups. No write side effects. Prefer explicit rules for faster iteration; omit rules for final full validation plus full-KB qualityDiagnostics review.",
|
|
8
|
+
"Run KB validation rules and return violations. Use before or after mutations, and after meaningful source edits with impact options to surface symbol granularity and semantic-review diagnostics. Do not use for point lookups. No write side effects. Prefer explicit rules for faster iteration; omit rules for final full validation plus full-KB qualityDiagnostics review, including telemetry acceptance when .kb/usage.log exists.",
|
|
9
9
|
businessInputSchema: {
|
|
10
10
|
type: "object",
|
|
11
11
|
properties: {
|
|
@@ -33,7 +33,7 @@ export const checkSpec = {
|
|
|
33
33
|
],
|
|
34
34
|
},
|
|
35
35
|
description:
|
|
36
|
-
"Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, no-cycles, required-fields, deprecated-adr-no-successor, domain-contradictions, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, logic-coverage, rule-safety, rule-verifiability, semantic-completeness, query-plan-safety. If omitted, server runs all rules plus the full-KB qualityDiagnostics audit scan; if supplied, server preserves scoped validation and skips the full-KB advisory scan.",
|
|
36
|
+
"Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, no-cycles, required-fields, deprecated-adr-no-successor, domain-contradictions, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, logic-coverage, rule-safety, rule-verifiability, semantic-completeness, query-plan-safety. If omitted, server runs all rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; if supplied, server preserves scoped validation and skips the full-KB advisory scan.",
|
|
37
37
|
},
|
|
38
38
|
sourceFiles: {
|
|
39
39
|
type: "array",
|
|
@@ -118,7 +118,7 @@ export const statusSpec = {
|
|
|
118
118
|
name: "kb_status",
|
|
119
119
|
cliName: "status",
|
|
120
120
|
description:
|
|
121
|
-
"Report current branch, snapshot
|
|
121
|
+
"Report current branch, KB snapshot and freshness metadata, plus the deterministic workspace snapshot used to validate execution receipts. Read-only status inspection with no mutation side effects.",
|
|
122
122
|
businessInputSchema: { type: "object", properties: {} },
|
|
123
123
|
requiresProlog: true,
|
|
124
124
|
effects: ["kb-read", "workspace-read"],
|
|
@@ -109,7 +109,7 @@ export const suggestPredicatesSpec = {
|
|
|
109
109
|
name: "kb_suggest_predicates",
|
|
110
110
|
cliName: "suggest-predicates",
|
|
111
111
|
description:
|
|
112
|
-
"Suggest ontology predicate schemas for prose requirements before agents write facts. Read-only guidance returns ranked candidates,
|
|
112
|
+
"Suggest ontology predicate schemas for prose requirements before agents write facts. Read-only guidance returns ranked candidates, an applicable predicate-fact plan only when every ordered argument is bound, a separate requires_predicate relationship plan when a requirement ID is supplied, or an explicit ontology-gap observation when no predicate fits.",
|
|
113
113
|
businessInputSchema: {
|
|
114
114
|
type: "object",
|
|
115
115
|
required: ["text"],
|
|
@@ -156,6 +156,24 @@ export const suggestPredicatesSpec = {
|
|
|
156
156
|
description:
|
|
157
157
|
"Whether to include existing KB fact_kind=predicate_schema facts alongside Kibi's built-in predicate catalog. Default: true.",
|
|
158
158
|
},
|
|
159
|
+
schemaId: {
|
|
160
|
+
type: "string",
|
|
161
|
+
minLength: 1,
|
|
162
|
+
description:
|
|
163
|
+
"Optional exact reviewed predicate schema ID. When supplied, Kibi selects that schema instead of lexical rank order and fails closed if it is unavailable.",
|
|
164
|
+
},
|
|
165
|
+
argumentBindings: {
|
|
166
|
+
type: "object",
|
|
167
|
+
additionalProperties: { type: "string", minLength: 1 },
|
|
168
|
+
description:
|
|
169
|
+
"Optional exact predicate argument values keyed by a candidate schema's argument_names. Required before applying a candidate whose binding_status is incomplete; Kibi never substitutes guessed values for unbound arguments.",
|
|
170
|
+
},
|
|
171
|
+
polarityHint: {
|
|
172
|
+
type: "string",
|
|
173
|
+
enum: ["assert", "deny"],
|
|
174
|
+
description:
|
|
175
|
+
"Optional reviewed polarity override for claims whose surface negation does not express predicate denial. Use only after reviewing the selected schema and full claim scope.",
|
|
176
|
+
},
|
|
159
177
|
existingLogicClaims: {
|
|
160
178
|
type: "array",
|
|
161
179
|
items: { type: "string", pattern: "^CLAIM-[A-F0-9]{16}$" },
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { VERIFICATION_RECEIPT_SCHEMA } from "../../verification-receipt.js";
|
|
2
|
+
|
|
1
3
|
export const ENTITY_TYPES = [
|
|
2
4
|
"req",
|
|
3
5
|
"scenario",
|
|
@@ -67,6 +69,11 @@ export const ENTITY_PROPERTIES_SCHEMA = {
|
|
|
67
69
|
description:
|
|
68
70
|
"Optional text anchor/reference. Example: 'requirements.md#L40'.",
|
|
69
71
|
},
|
|
72
|
+
semantic_text: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description:
|
|
75
|
+
"Requirement-only authored prose used for semantic inventory hashes and UTF-8 spans. Keep text_ref available for independent document or code evidence.",
|
|
76
|
+
},
|
|
70
77
|
logic_claims: {
|
|
71
78
|
type: "array",
|
|
72
79
|
minItems: 1,
|
|
@@ -75,6 +82,31 @@ export const ENTITY_PROPERTIES_SCHEMA = {
|
|
|
75
82
|
description:
|
|
76
83
|
"Requirement-only manifest of every atomic normative claim key returned by kb_semantic_advisor. A requirement is logic-complete only when every key is grounded by a linked property_value or predicate fact with the same claim_key.",
|
|
77
84
|
},
|
|
85
|
+
semantic_clauses: {
|
|
86
|
+
type: "array",
|
|
87
|
+
minItems: 1,
|
|
88
|
+
items: { type: "string", minLength: 1 },
|
|
89
|
+
description:
|
|
90
|
+
"Optional complete atomic decomposition used by kb_semantic_advisor and proposition-complete ingestion. Preserve it when automatic sentence splitting needs a reviewed override.",
|
|
91
|
+
},
|
|
92
|
+
semantic_inventory_version: {
|
|
93
|
+
type: "string",
|
|
94
|
+
const: "kibi.semantic-inventory.v1",
|
|
95
|
+
description:
|
|
96
|
+
"Requirement-only proposition ledger contract version returned by kb_semantic_advisor.",
|
|
97
|
+
},
|
|
98
|
+
semantic_source_field: {
|
|
99
|
+
type: "string",
|
|
100
|
+
enum: ["semantic_text", "text_ref", "title"],
|
|
101
|
+
description:
|
|
102
|
+
"Requirement field whose exact UTF-8 bytes anchor semantic_inventory spans.",
|
|
103
|
+
},
|
|
104
|
+
semantic_source_hash: {
|
|
105
|
+
type: "string",
|
|
106
|
+
pattern: "^[a-f0-9]{64}$",
|
|
107
|
+
description:
|
|
108
|
+
"SHA-256 of the exact semantic source text returned in the advisor inventory contract.",
|
|
109
|
+
},
|
|
78
110
|
sourceFile: {
|
|
79
111
|
type: "string",
|
|
80
112
|
description:
|
|
@@ -116,6 +148,13 @@ export const ENTITY_PROPERTIES_SCHEMA = {
|
|
|
116
148
|
description:
|
|
117
149
|
"Optional typed verification perspective for test entities. Example: 'consumer'.",
|
|
118
150
|
},
|
|
151
|
+
verification_receipts: {
|
|
152
|
+
type: "array",
|
|
153
|
+
maxItems: 50,
|
|
154
|
+
items: VERIFICATION_RECEIPT_SCHEMA,
|
|
155
|
+
description:
|
|
156
|
+
"Append-only test execution evidence. Proof accepts only the newest valid passed receipt bound to the current code snapshot and within the seven-day freshness window.",
|
|
157
|
+
},
|
|
119
158
|
fact_kind: {
|
|
120
159
|
type: "string",
|
|
121
160
|
enum: [
|
|
@@ -276,7 +315,14 @@ export const ENTITY_PROPERTIES_SCHEMA = {
|
|
|
276
315
|
claim_span_start: { type: "integer", minimum: 0 },
|
|
277
316
|
claim_span_end: { type: "integer", minimum: 0 },
|
|
278
317
|
},
|
|
279
|
-
allOf: [
|
|
318
|
+
allOf: [
|
|
319
|
+
CLAIM_PROVENANCE_CONDITIONAL,
|
|
320
|
+
{
|
|
321
|
+
if: { required: ["verification_receipts"] },
|
|
322
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema conditional keyword.
|
|
323
|
+
then: { required: ["verification_scope"] },
|
|
324
|
+
},
|
|
325
|
+
],
|
|
280
326
|
required: ["title", "status"],
|
|
281
327
|
} as const;
|
|
282
328
|
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { VERIFICATION_RECEIPT_MAX_AGE_SECONDS } from "../../verification-receipt.js";
|
|
2
|
+
import {
|
|
3
|
+
type LegacyMigrationPlan,
|
|
4
|
+
buildLegacyMigrationPlanFromContext,
|
|
5
|
+
} from "../legacy-migration-plan.js";
|
|
1
6
|
import {
|
|
2
7
|
runOperationJsonQuery,
|
|
3
8
|
toPrologAtom,
|
|
4
9
|
toPrologList,
|
|
5
10
|
} from "../prolog-json.js";
|
|
11
|
+
import { type RepairPlan, buildRepairPlan } from "../repair-plan.js";
|
|
6
12
|
import type { OperationContext } from "../runtime-types.js";
|
|
7
13
|
import type { OperationResult, OperationSpec } from "../types.js";
|
|
14
|
+
import { readWorkspaceSnapshot } from "../workspace-snapshot.js";
|
|
8
15
|
|
|
9
16
|
const ENTITY_TYPES = [
|
|
10
17
|
"req",
|
|
@@ -41,11 +48,18 @@ export type CoverageInput = {
|
|
|
41
48
|
readonly includeTransitive?: boolean;
|
|
42
49
|
readonly limit?: number;
|
|
43
50
|
readonly offset?: number;
|
|
51
|
+
readonly includeMigrationPreview?: boolean;
|
|
52
|
+
readonly migrationLimit?: number;
|
|
53
|
+
readonly migrationOffset?: number;
|
|
54
|
+
readonly migrationPredicateLimit?: number;
|
|
55
|
+
readonly migrationPredicateMinScore?: number;
|
|
44
56
|
};
|
|
45
57
|
|
|
46
58
|
export type CoveragePayload = {
|
|
47
59
|
readonly summary: Readonly<Record<string, number>>;
|
|
48
60
|
readonly rows: readonly Readonly<Record<string, unknown>>[];
|
|
61
|
+
readonly repairPlan?: RepairPlan;
|
|
62
|
+
readonly legacyMigrationPlan?: LegacyMigrationPlan;
|
|
49
63
|
readonly meta?: Readonly<Record<string, unknown>>;
|
|
50
64
|
};
|
|
51
65
|
|
|
@@ -142,22 +156,57 @@ export async function executeCoverage(
|
|
|
142
156
|
context: OperationContext,
|
|
143
157
|
): Promise<OperationResult<CoveragePayload>> {
|
|
144
158
|
try {
|
|
159
|
+
const snapshotEvidence = await readWorkspaceSnapshot(context);
|
|
160
|
+
const codeSnapshot = snapshotEvidence.available
|
|
161
|
+
? snapshotEvidence.snapshot.hash
|
|
162
|
+
: "unknown";
|
|
163
|
+
const checkedAt = context.clock().toISOString();
|
|
145
164
|
const payload = await runOperationJsonQuery<CoveragePayload>(
|
|
146
165
|
requireProlog(context),
|
|
147
166
|
"discovery.pl",
|
|
148
|
-
`discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, ${input.includeTransitive ?? true}, ${input.limit ?? 100}, ${input.offset ?? 0}, JsonString)`,
|
|
167
|
+
`discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, ${input.includeTransitive ?? true}, ${input.limit ?? 100}, ${input.offset ?? 0}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${VERIFICATION_RECEIPT_MAX_AGE_SECONDS}, JsonString)`,
|
|
149
168
|
"Coverage execution",
|
|
150
169
|
);
|
|
151
|
-
const
|
|
152
|
-
const
|
|
170
|
+
const repairPlan = buildRepairPlan(payload, input, codeSnapshot);
|
|
171
|
+
const legacyMigrationPlan =
|
|
172
|
+
input.includeMigrationPreview === true && repairPlan !== undefined
|
|
173
|
+
? await buildLegacyMigrationPlanFromContext(
|
|
174
|
+
repairPlan,
|
|
175
|
+
input,
|
|
176
|
+
codeSnapshot,
|
|
177
|
+
context,
|
|
178
|
+
)
|
|
179
|
+
: undefined;
|
|
180
|
+
const enrichedPayload = {
|
|
181
|
+
...payload,
|
|
182
|
+
...(repairPlan !== undefined ? { repairPlan } : {}),
|
|
183
|
+
...(legacyMigrationPlan !== undefined ? { legacyMigrationPlan } : {}),
|
|
184
|
+
meta: {
|
|
185
|
+
...(payload.meta ?? {}),
|
|
186
|
+
verificationReceiptMaxAgeSeconds: VERIFICATION_RECEIPT_MAX_AGE_SECONDS,
|
|
187
|
+
verificationSnapshot: codeSnapshot,
|
|
188
|
+
verificationSnapshotAvailable: snapshotEvidence.available,
|
|
189
|
+
...(snapshotEvidence.available
|
|
190
|
+
? {
|
|
191
|
+
verificationSnapshotDirty: snapshotEvidence.snapshot.dirty,
|
|
192
|
+
verificationSnapshotFileCount:
|
|
193
|
+
snapshotEvidence.snapshot.fileCount,
|
|
194
|
+
verificationSnapshotVersion: snapshotEvidence.snapshot.version,
|
|
195
|
+
}
|
|
196
|
+
: { verificationSnapshotError: snapshotEvidence.error }),
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
const fullyCovered = Number(enrichedPayload.summary?.fullyCovered ?? 0);
|
|
200
|
+
const proofProven = Number(enrichedPayload.summary?.proofProven ?? 0);
|
|
201
|
+
const total = Number(enrichedPayload.summary?.total ?? 0);
|
|
153
202
|
return {
|
|
154
203
|
content: [
|
|
155
204
|
{
|
|
156
205
|
type: "text",
|
|
157
|
-
text: `Coverage summary: ${fullyCovered}
|
|
206
|
+
text: `Coverage summary: ${fullyCovered} structurally covered and ${proofProven} proven out of ${total}.`,
|
|
158
207
|
},
|
|
159
208
|
],
|
|
160
|
-
structuredContent:
|
|
209
|
+
structuredContent: enrichedPayload,
|
|
161
210
|
};
|
|
162
211
|
} catch (error) {
|
|
163
212
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -169,7 +218,7 @@ export const coverageSpec = {
|
|
|
169
218
|
name: "kb_coverage",
|
|
170
219
|
cliName: "coverage",
|
|
171
220
|
description:
|
|
172
|
-
"Generate curated coverage reports for requirements, symbols, or grouped types.
|
|
221
|
+
"Generate curated structural coverage and conservative end-to-end requirement proof reports for requirements, symbols, or grouped types. Requirement reports include a deterministic, dependency-ordered, read-only repair plan; optional legacy migration previews reconstruct authored proposition inventories and rank exact schema candidates without producing executable writes. Paginated plans identify incomplete scope. Requirement rows keep coverageStatus separate from proofStatus and require fresh snapshot-bound E2E receipts before proof. No mutation side effects.",
|
|
173
222
|
businessInputSchema: {
|
|
174
223
|
type: "object",
|
|
175
224
|
properties: {
|
|
@@ -179,6 +228,42 @@ export const coverageSpec = {
|
|
|
179
228
|
includeTransitive: { type: "boolean", default: true },
|
|
180
229
|
limit: { type: "integer", default: 100 },
|
|
181
230
|
offset: { type: "integer", default: 0 },
|
|
231
|
+
includeMigrationPreview: {
|
|
232
|
+
type: "boolean",
|
|
233
|
+
default: false,
|
|
234
|
+
description:
|
|
235
|
+
"Opt in to a deterministic, read-only kibi.legacy-migration-plan.v1 preview for ready semantic-inventory repair batches.",
|
|
236
|
+
},
|
|
237
|
+
migrationLimit: {
|
|
238
|
+
type: "integer",
|
|
239
|
+
minimum: 1,
|
|
240
|
+
maximum: 10,
|
|
241
|
+
default: 1,
|
|
242
|
+
description:
|
|
243
|
+
"Maximum requirement migration batches to preview. Defaults to one review batch.",
|
|
244
|
+
},
|
|
245
|
+
migrationOffset: {
|
|
246
|
+
type: "integer",
|
|
247
|
+
minimum: 0,
|
|
248
|
+
default: 0,
|
|
249
|
+
description: "Zero-based offset into ready semantic-inventory batches.",
|
|
250
|
+
},
|
|
251
|
+
migrationPredicateLimit: {
|
|
252
|
+
type: "integer",
|
|
253
|
+
minimum: 1,
|
|
254
|
+
maximum: 20,
|
|
255
|
+
default: 5,
|
|
256
|
+
description:
|
|
257
|
+
"Maximum exact predicate-schema candidates retained per assertive proposition.",
|
|
258
|
+
},
|
|
259
|
+
migrationPredicateMinScore: {
|
|
260
|
+
type: "number",
|
|
261
|
+
minimum: 0,
|
|
262
|
+
maximum: 1,
|
|
263
|
+
default: 0.35,
|
|
264
|
+
description:
|
|
265
|
+
"Minimum deterministic predicate-schema rank score retained in migration previews.",
|
|
266
|
+
},
|
|
182
267
|
},
|
|
183
268
|
},
|
|
184
269
|
requiresProlog: true,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OperationContext, WorkspaceSnapshot } from "./runtime-types.js";
|
|
2
|
+
|
|
3
|
+
export type WorkspaceSnapshotEvidence =
|
|
4
|
+
| Readonly<{ available: true; snapshot: WorkspaceSnapshot }>
|
|
5
|
+
| Readonly<{ available: false; error: string }>;
|
|
6
|
+
|
|
7
|
+
export async function readWorkspaceSnapshot(
|
|
8
|
+
context: OperationContext,
|
|
9
|
+
): Promise<WorkspaceSnapshotEvidence> {
|
|
10
|
+
if (!context.git?.workspaceSnapshot) {
|
|
11
|
+
return {
|
|
12
|
+
available: false,
|
|
13
|
+
error:
|
|
14
|
+
"The active operation runtime does not expose workspace snapshots.",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
return {
|
|
19
|
+
available: true,
|
|
20
|
+
snapshot: await context.git.workspaceSnapshot(context.workspaceRoot),
|
|
21
|
+
};
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return {
|
|
24
|
+
available: false,
|
|
25
|
+
error: error instanceof Error ? error.message : String(error),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
// Typed fact field enums per proposal
|
|
20
20
|
import { SYMBOL_ROLES, type SymbolRole } from "../symbol-granularity.js";
|
|
21
|
+
import { VERIFICATION_RECEIPT_SCHEMA } from "../verification-receipt.js";
|
|
21
22
|
|
|
22
23
|
type FactKind =
|
|
23
24
|
| "subject"
|
|
@@ -355,12 +356,34 @@ const entitySchema: Record<string, unknown> = {
|
|
|
355
356
|
severity: { type: "string" },
|
|
356
357
|
links: { type: "array", items: { type: "string" } },
|
|
357
358
|
text_ref: { type: "string" },
|
|
359
|
+
semantic_text: {
|
|
360
|
+
type: "string",
|
|
361
|
+
description:
|
|
362
|
+
"Requirement-only authored prose whose exact UTF-8 bytes anchor the semantic inventory without replacing text_ref evidence.",
|
|
363
|
+
},
|
|
358
364
|
logic_claims: {
|
|
359
365
|
type: "array",
|
|
360
366
|
minItems: 1,
|
|
361
367
|
uniqueItems: true,
|
|
362
368
|
items: { type: "string", pattern: "^CLAIM-[A-F0-9]{16}$" },
|
|
363
369
|
},
|
|
370
|
+
semantic_clauses: {
|
|
371
|
+
type: "array",
|
|
372
|
+
minItems: 1,
|
|
373
|
+
items: { type: "string", minLength: 1 },
|
|
374
|
+
},
|
|
375
|
+
semantic_inventory_version: {
|
|
376
|
+
type: "string",
|
|
377
|
+
const: "kibi.semantic-inventory.v1",
|
|
378
|
+
},
|
|
379
|
+
semantic_source_field: {
|
|
380
|
+
type: "string",
|
|
381
|
+
enum: ["semantic_text", "text_ref", "title"],
|
|
382
|
+
},
|
|
383
|
+
semantic_source_hash: {
|
|
384
|
+
type: "string",
|
|
385
|
+
pattern: "^[a-f0-9]{64}$",
|
|
386
|
+
},
|
|
364
387
|
semantic_inventory: {
|
|
365
388
|
type: "array",
|
|
366
389
|
items: {
|
|
@@ -430,6 +453,11 @@ const entitySchema: Record<string, unknown> = {
|
|
|
430
453
|
type: "string",
|
|
431
454
|
enum: ["internal", "consumer"] satisfies VerificationPerspective[],
|
|
432
455
|
},
|
|
456
|
+
verification_receipts: {
|
|
457
|
+
type: "array",
|
|
458
|
+
maxItems: 50,
|
|
459
|
+
items: VERIFICATION_RECEIPT_SCHEMA,
|
|
460
|
+
},
|
|
433
461
|
type: {
|
|
434
462
|
type: "string",
|
|
435
463
|
enum: [
|
|
@@ -569,16 +597,31 @@ const entitySchema: Record<string, unknown> = {
|
|
|
569
597
|
anyOf: [
|
|
570
598
|
{ required: ["verification_scope"] },
|
|
571
599
|
{ required: ["verification_perspective"] },
|
|
600
|
+
{ required: ["verification_receipts"] },
|
|
572
601
|
],
|
|
573
602
|
},
|
|
574
603
|
},
|
|
575
604
|
},
|
|
605
|
+
{
|
|
606
|
+
if: { required: ["verification_receipts"] },
|
|
607
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema conditional keyword.
|
|
608
|
+
then: { required: ["verification_scope"] },
|
|
609
|
+
},
|
|
576
610
|
{
|
|
577
611
|
if: {
|
|
578
612
|
properties: { type: { const: "req" } },
|
|
579
613
|
},
|
|
580
614
|
else: {
|
|
581
|
-
not: {
|
|
615
|
+
not: {
|
|
616
|
+
anyOf: [
|
|
617
|
+
{ required: ["semantic_inventory"] },
|
|
618
|
+
{ required: ["semantic_clauses"] },
|
|
619
|
+
{ required: ["semantic_text"] },
|
|
620
|
+
{ required: ["semantic_inventory_version"] },
|
|
621
|
+
{ required: ["semantic_source_field"] },
|
|
622
|
+
{ required: ["semantic_source_hash"] },
|
|
623
|
+
],
|
|
624
|
+
},
|
|
582
625
|
},
|
|
583
626
|
},
|
|
584
627
|
...factConditionals,
|
|
@@ -34,6 +34,7 @@ echo '{"sourceFiles":["src/auth/login.ts"],"includeImpactDiagnostics":true,"incl
|
|
|
34
34
|
- After meaningful source edits, run `kb_check({sourceFiles:[...], includeImpactDiagnostics:true, includeWorkingTreeDiff:true})` or the equivalent `check --input` JSON recipe before deciding whether traceability is current.
|
|
35
35
|
- Apply traceability updates sequentially through `kb_upsert` or `upsert --input` for requirements, scenarios, tests, facts, behavioral symbols, and source-linked relationships.
|
|
36
36
|
- Validate constraints and consistency through `kb_check` or `check --input` after updates.
|
|
37
|
+
- Run `kb_coverage` by requirement after validation. Treat `coverageStatus` as structural compatibility only; use the separate `proofStatus`, `proofStages`, `proofGaps`, and ranked `proofRepairs` to decide whether the complete intent-to-code chain is proven.
|
|
37
38
|
- Use `kb_delete` or `delete --input` only for explicit cleanup of obsolete records or relationships.
|
|
38
39
|
|
|
39
40
|
## Guidance
|
|
@@ -42,6 +43,11 @@ echo '{"sourceFiles":["src/auth/login.ts"],"includeImpactDiagnostics":true,"incl
|
|
|
42
43
|
- Preserve source-file traceability whenever adding or changing requirements, scenarios, tests, facts, behavioral symbols, or implementation links.
|
|
43
44
|
- Preserve the canonical chain `REQ-* -> SCEN-* -> TEST-*` when adding or changing requirements.
|
|
44
45
|
- Production symbols should implement requirements; test symbols should remain executable evidence for tests.
|
|
46
|
+
- A proof-bearing test must be reached through the requirement's scenario, declare `verification_scope: end_to_end`, and carry a fresh passed `kibi.verification-receipt.v1` bound to the live `verificationSnapshot`. Link its executable code with `executable_for`; link each production symbol with `implements` and `covered_by` to that qualifying test. Durable `status: passing` is structural metadata, not execution proof.
|
|
47
|
+
- Read `kb_status` immediately before a proof-bearing run, execute the exact recorded command, then append—not replace—the receipt history with test ID, scope, runner, command, snapshot, environment hash, timestamps, outcome, and artifact digest. Re-read coverage; wrong-snapshot, stale, failed, malformed, future-dated, or unavailable evidence must remain a gap.
|
|
48
|
+
- A green structural count is not proof. Do not report success while a proposition is absent or unresolved, grounding is incomplete or non-bijective, contradiction analysis is incomplete, the E2E path is direct-only, its execution receipt is not fresh for the live snapshot, or proof-bearing symbols lack current generated coordinates.
|
|
49
|
+
- Use `kb_coverage.repairPlan` to turn row-local `proofRepairs` into small dependency-ordered batches. Require `scope.complete: true` before treating it as a project-wide inventory, apply only `state: ready` work, and treat every `autoApplicable: false` batch as reviewed guidance rather than an executable mutation payload. Query current endpoints, follow its validation policy, keep upserts sequential, then rerun coverage after each batch; newly visible downstream gaps supersede the older plan. Never reinterpret `no_conflict_found` as universal consistency; it only describes the modeled ground claims Kibi could inspect.
|
|
50
|
+
- When `.kb/usage.log` exists, run `kibi usage-metrics --format json --require-acceptance` after the final complete coverage call. A successful graph check does not override failed or insufficient `kibi.telemetry-acceptance.v1` evidence; follow ranked telemetry diagnostics for advisor/preflight bypasses, lookup misses, stalled proof recovery, receipt freshness, or repeated mutation failures.
|
|
45
51
|
- Resolve impact at behavioral-symbol granularity when Kibi reports symbol-level diagnostics; avoid treating a whole file as impacted when the report identifies narrower linked behavior.
|
|
46
52
|
- Treat `symbol_semantic_review_needed` as a prompt to inspect linked requirements and tests; Kibi reports graph links but does not prove prose semantics.
|
|
47
53
|
- Do not read or edit files inside `.kb` directly; all modeling and cleanup goes through the selected Kibi interface.
|
|
@@ -51,4 +57,4 @@ Public training trajectories:
|
|
|
51
57
|
[{"taskId":"kibi-traceability-requirement-discovery-train-1","family":"requirement-discovery","reflection":"Discover the requirement linked to the supplied source symbol. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-requirement-discovery-train-2","family":"requirement-discovery","reflection":"Discover the requirement linked to the supplied source symbol. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-symbol-impact-granularity-train-1","family":"symbol-impact-granularity","reflection":"Resolve impact at behavioral symbol granularity rather than file granularity. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-symbol-impact-granularity-train-2","family":"symbol-impact-granularity","reflection":"Resolve impact at behavioral symbol granularity rather than file granularity. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-relationship-chain-train-1","family":"relationship-chain","reflection":"Trace the requirement, scenario, and test relationship chain. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-relationship-chain-train-2","family":"relationship-chain","reflection":"Trace the requirement, scenario, and test relationship chain. This is train case 2; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-executable-coverage-train-1","family":"executable-coverage","reflection":"Establish executable test identity and behavioral coverage links. This is train case 1; use only the public Kibi MCP surface."},{"taskId":"kibi-traceability-executable-coverage-train-2","family":"executable-coverage","reflection":"Establish executable test identity and behavioral coverage links. This is train case 2; use only the public Kibi MCP surface."}]
|
|
52
58
|
|
|
53
59
|
Previous development gate:
|
|
54
|
-
{"mean":0,"hardPasses":0,"worstFamilyMean":0}
|
|
60
|
+
{"mean":0,"hardPasses":0,"worstFamilyMean":0}
|
|
@@ -109,6 +109,12 @@ Use `kb_semantic_advisor` with up to three typed `interpretations` for ambiguous
|
|
|
109
109
|
|
|
110
110
|
The portable skill body must carry the core contract even when its detailed resources are unavailable: `kb_semantic_advisor` returns a `propositions[]` ledger and `semantic_inventory`; submit typed `interpretations` when wording has more than one plausible logical reading; validate modeled conditions through `kibi.logic.v1`; and preserve unresolved propositions as explicit gaps. Do not read or edit files inside `.kb` directly.
|
|
111
111
|
|
|
112
|
+
Requirement proof also requires fresh execution evidence. Read the available `verificationSnapshot` from `kb_status`, run the scenario-backed E2E command, and append a `kibi.verification-receipt.v1` carrying test ID, typed scope, runner, command, snapshot, environment hash, timestamps, outcome, and artifact digest. Never rewrite receipt history or treat durable `status: passing` as execution proof; re-run coverage and repair every receipt-specific gap.
|
|
113
|
+
|
|
114
|
+
Requirement-mode `kb_coverage` also returns `kibi.repair-plan.v1`. Use it only when `scope.complete` is true; a partial plan means pagination hid actionable requirements. Apply only the earliest `ready` batch for each requirement, query before mutation, create endpoints before relationships, validate every payload, and keep `kb_upsert` calls sequential. Batches are deliberately `autoApplicable: false`: semantic resolution, contradiction supersession, E2E execution, and source ownership always require review. Re-run coverage after every batch instead of continuing from a stale plan.
|
|
115
|
+
|
|
116
|
+
When `.kb/usage.log` exists, treat `kibi.telemetry-acceptance.v1` as the process-evidence lane. Run `kibi usage-metrics --format json --require-acceptance` before completion and inspect unfiltered `kb_check.qualityDiagnostics[]` for ranked `category: telemetry` repairs. The rolling report requires fresh evidence for advisor-before-requirement-write, exact validation-before-upsert, source-linked lookup results, proof-gap recovery, receipt freshness, and mutation retry discipline. `insufficient_evidence` is not a pass: capture current complete coverage and diagnostic events rather than waiving stale, partial, or pre-upgrade logs. A missing usage log means diagnostic logging is not active; do not invent telemetry evidence.
|
|
117
|
+
|
|
112
118
|
## Strict Fact Lane
|
|
113
119
|
|
|
114
120
|
Normative requirements that must participate in contradiction blocking use the strict fact lane. Create a `fact_kind: subject` fact and link it from the requirement via `constrains`. Create a `fact_kind: property_value` fact and link it via `requires_property`.
|
|
@@ -148,13 +154,13 @@ Readable prose is not evidence that a requirement is machine-checkable. Before t
|
|
|
148
154
|
|
|
149
155
|
1. Call `kb_semantic_advisor` with the complete requirement prose. When the automatic split is incomplete or a sentence contains multiple obligations, pass an explicit `clauses` array containing every atomic normative clause.
|
|
150
156
|
2. Use the stable `claim_key` returned for each clause. Every ground `property_value` or `predicate` fact must preserve that key in `claim_key` and preserve the clause in `claim_text`. Use the advisor-returned inventory exactly; do not add punctuation or wording variants of an existing clause.
|
|
151
|
-
3. Put the
|
|
157
|
+
3. Put exactly the current assertive proposition keys in the requirement's `logic_claims` manifest. Preserve unrelated metadata, but remove stale claim keys when the source meaning changes; never silently omit an earlier proposition that remains in the current prose.
|
|
152
158
|
4. Ground each key through exactly one suitable logical lane: `requires_property` to one strict `property_value` fact, `requires_predicate` to one ground `predicate` fact, or `requires_rule` to one safe `rule` fact. A subject fact supports a strict claim but does not ground a key by itself. Observation, meta, ambiguity, and ontology-gap facts explicitly remain unresolved and do not count as logical coverage.
|
|
153
159
|
5. Run `kb_check` with `logic-coverage`, `rule-safety`, `rule-verifiability`, `semantic-completeness`, `predicate-verifiability`, and `domain-contradictions`. `logic-coverage` enforces a one-claim/one-ground-fact mapping and rejects distinct claim keys that encode the same logical term; human or agent review still confirms that the atomic clauses exhaust the prose and that each ground term preserves its meaning.
|
|
154
160
|
|
|
155
161
|
Kibi emits a non-blocking logical-coverage debt diagnostic for every current requirement without a manifest, independent of title wording. The `logic-coverage` rule is enabled by default for requirements that do declare manifests, so an unfiltered final check catches missing or orphaned ground claims while legacy requirements remain explicit backfill work.
|
|
156
162
|
|
|
157
|
-
A complete `logic_claims` manifest alone is not a complete model.
|
|
163
|
+
A complete `logic_claims` manifest alone is not a complete model. Preserve the advisor's `inventory_contract` as `semantic_inventory_version`, `semantic_source_field`, and `semantic_source_hash`; every ledger span must select its exact claim text from that field. For new or migrated requirements, use requirement-only `semantic_text` for normalized authored prose and keep `text_ref` available for independent code or document evidence. Legacy direct payloads may still declare `text_ref` or `title`; an explicitly declared but empty semantic source fails closed instead of falling through. Mutation rejects duplicate or omitted propositions and requires every `modeled` entry to resolve through exactly one logical edge to a fact with the same claim key. Explicit unresolved entries remain ingestible but cannot prove the requirement.
|
|
158
164
|
|
|
159
165
|
Never invent, reuse across different clauses, or manually alter a claim key. Kibi derives it from `claim_text` and rejects mismatched mutation and Markdown inputs.
|
|
160
166
|
|
|
@@ -181,7 +187,7 @@ Preserve the readable requirement prose. Facts add a machine-queryable model; th
|
|
|
181
187
|
|
|
182
188
|
1. Call `kb_semantic_advisor` on the complete prose, verify its atomic clause inventory, and choose one lane per clause.
|
|
183
189
|
2. For each relational clause, call `kb_suggest_predicates` with that clause and the current `existingLogicClaims`. Read each candidate as a Prolog-shaped ground term `predicate_name(arg1,...,argN)`: the schema fixes the predicate name, arity, argument roles, and argument order.
|
|
184
|
-
3. Accept a candidate only when its meaning and every ordered argument fit the prose. Use the returned `applyPlan`, including its exact `predicate_name`, `predicate_args`, `canonical_key`, and `polarity`; never invent a predicate name, reorder arguments, add variables, or write a raw Prolog clause.
|
|
190
|
+
3. Accept a candidate only when its meaning and every ordered argument fit the prose. If lexical rank order prefers a false positive, retry with the reviewed candidate's exact `schema.id` as `schemaId`; do not mutate the candidate or treat a missing schema reference as an ontology gap. If it returns `binding_status: incomplete`, retry with exact `argumentBindings` for every `unbound_arguments` name; its empty `applyPlan` is a safety gate, and the literal `unknown` must never be persisted. Use `polarityHint` only when review of the complete claim proves that surface negation does not deny the selected predicate. Once complete, use the returned `applyPlan`, including its exact `predicate_name`, `predicate_args`, `canonical_key`, and `polarity`; never invent a predicate name, reorder arguments, add variables, or write a raw Prolog clause.
|
|
185
191
|
4. Create or confirm the requirement and `fact_kind: predicate` endpoints, preserve `claim_key` and `claim_text`, merge the returned `logicClaims` into the requirement, then link requirement -> predicate fact with `requires_predicate`. Treat the requirement's logical representation as the conjunction of every linked ground term. Encode a prohibition with `polarity: deny` on the fitting positive schema, not a made-up negative predicate. An `assert` and `deny` requirement over the same namespace, name, and ordered arguments are a blocking `domain-contradictions` conflict, so requirements must reuse the same canonical schema and argument vocabulary for equivalent domain claims.
|
|
186
192
|
5. Use an existing built-in or project-local `fact_kind: predicate_schema`. Create a new schema only when the task explicitly authorizes ontology extension and supplies a stable name, arity, `argument_names`, and `argument_types`; otherwise record `fact_kind: observation` with `review:ontology-gap`.
|
|
187
193
|
6. For each scalar, threshold, duration, boolean, enum-set, or cardinality clause, use `kb_model_requirement` with the current `existingLogicClaims` and the strict subject/property lane instead. For ambiguity or a lexical false positive, preserve the prose as a review observation, apply its returned `relates_to` review anchor when present, and report the requirement as logically incomplete. Use `review:ambiguity` for unresolved scope or interpretation and `review:keyword-false-positive` when a vocabulary match is not a domain assertion.
|
|
@@ -264,7 +270,7 @@ Call `kb_status` when branch KB context may be stale or after switching context.
|
|
|
264
270
|
| Tags as multi-ID lookup | Tags are metadata, not identifiers | Use `kb_query` with explicit `id` values |
|
|
265
271
|
| `relates_to` for strict modeling | Loses contradiction safety | Use `constrains` and `requires_property` instead |
|
|
266
272
|
| One fact for a compound requirement | Leaves untracked prose outside contradiction checks | Decompose all atomic clauses, preserve claim keys, and validate `logic_claims` with `logic-coverage` |
|
|
267
|
-
|
|
|
273
|
+
| Keeping stale `logic_claims` after prose changes | Makes the manifest disagree with the source ledger | Replace it atomically with exactly the current assertive keys while preserving unrelated metadata |
|
|
268
274
|
| Observation counted as coverage | Ambiguity or ontology gaps appear machine-checkable | Keep the claim unresolved until a strict or predicate ground fact exists |
|
|
269
275
|
| Relationship type used as predicate name | Confuses graph edges with ontology terms | Select a declared predicate schema and keep `requires_predicate` as the req -> fact edge |
|
|
270
276
|
| `status: implemented` on requirements | Not a valid lifecycle status | Use a valid status such as `closed`, add an `implemented` tag, and link evidence instead |
|
|
@@ -7,7 +7,7 @@ Requirement prose remains the human-readable source. Facts add queryable semanti
|
|
|
7
7
|
Logical coverage is clause-based, not entity-based. Give `kb_semantic_advisor` the complete requirement body and verify that its `clauses` list contains every atomic obligation. Supply the `clauses` input yourself when automatic splitting would combine or omit obligations. For every normative clause:
|
|
8
8
|
|
|
9
9
|
- preserve the returned stable key as `claim_key` and the exact clause as `claim_text` on its ground fact;
|
|
10
|
-
- add the key to the
|
|
10
|
+
- add the key to the exact current `logic_claims` set, removing only stale keys whose propositions no longer exist in the source;
|
|
11
11
|
- link it through exactly one `requires_property` for `property_value`, one `requires_predicate` for `predicate`, or one `requires_rule` for a safe `rule` fact;
|
|
12
12
|
- leave ambiguity and ontology gaps visibly unresolved—observations do not satisfy `logic-coverage`.
|
|
13
13
|
|
|
@@ -36,7 +36,7 @@ Example (inspection data, not executable input):
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Use `rule_schema` facts for stable predicate signatures and link a requirement to a `rule` fact with `requires_rule`. Keep `logic_claims`
|
|
39
|
+
Use `rule_schema` facts for stable predicate signatures and link a requirement to a `rule` fact with `requires_rule`. Keep `logic_claims` as the exact current assertive key set; `semantic_inventory` is the complete proposition ledger, anchored by `semantic_inventory_version`, `semantic_source_field`, and `semantic_source_hash`. Prefer requirement-only `semantic_text` as the semantic source for normalized authored prose so `text_ref` can remain independent code or document evidence; retain `text_ref` and `title` only as legacy semantic-source choices. A manifest is not proof until each modeled key is linked to exactly one same-key fact and the rule checks pass.
|
|
40
40
|
|
|
41
41
|
## Contradictions and uncertainty
|
|
42
42
|
|
|
@@ -13,9 +13,16 @@ The canonical workflow for any KB operation follows this pattern:
|
|
|
13
13
|
7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
|
|
14
14
|
8. **Link**: validated `kb_upsert` with `requires_rule`, `requires_predicate`, `constrains`, or `requires_property`, sequentially
|
|
15
15
|
9. **Validate coverage and consistency**: targeted `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then final full `kb_check`
|
|
16
|
+
10. **Prove execution**: read `kb_status.verificationSnapshot`, run each scenario-backed E2E command, append its `kibi.verification-receipt.v1`, and re-run `kb_coverage`; never promote durable test status into fresh evidence
|
|
17
|
+
11. **Repair incrementally**: require `kb_coverage.repairPlan.scope.complete`, apply only one `ready` dependency batch per requirement, validate before every sequential write, and rerun coverage before selecting the next batch
|
|
18
|
+
12. **Gate workflow evidence**: when `.kb/usage.log` exists, run `kibi usage-metrics --format json --require-acceptance`; repair ranked telemetry diagnostics and never treat stale or insufficient evidence as a pass
|
|
16
19
|
|
|
17
20
|
Every current requirement without `logic_claims` remains visible as non-blocking backfill debt. Once a manifest and `semantic_inventory` exist, the unfiltered check enforces correspondence to linked ground facts/rules and rejects silently missing assertive propositions.
|
|
18
21
|
|
|
22
|
+
`kibi.repair-plan.v1` is a deterministic read-only plan, not a mutation script. Its phase order keeps source and proposition analysis ahead of ground endpoints, endpoints ahead of manifests/links, logic ahead of contradictions, scenarios ahead of tests and receipts, and production ownership ahead of coverage and coordinate refresh. A `blocked` batch is waiting on every listed `dependsOn` batch. If pagination makes the plan partial, increase the requirement coverage limit rather than applying an incomplete project view.
|
|
23
|
+
|
|
24
|
+
`kibi.telemetry-acceptance.v1` evaluates the latest 200 usage events and keeps process health separate from graph correctness. It requires at least 95% complete diagnostic telemetry and, when applicable, exact recent validation before every upsert and a same-requirement/current-hash advisor pass before requirement writes. It also evaluates source lookup misses, comparable complete-scope proof-gap recovery, receipt-specific coverage gaps, and mutation targets retried three or more times. Failed metrics become ranked `category: telemetry` quality diagnostics; missing current coverage fields or evidence older than seven days stays `insufficient_evidence`.
|
|
25
|
+
|
|
19
26
|
## Creating a New Feature
|
|
20
27
|
```
|
|
21
28
|
1. kb_search to discover existing requirements and related knowledge
|
|
@@ -38,14 +45,24 @@ Every current requirement without `logic_claims` remains visible as non-blocking
|
|
|
38
45
|
|
|
39
46
|
Do not create a test-fact pair. Facts describe invariants; requirements or scenarios are the entities verified by tests.
|
|
40
47
|
|
|
48
|
+
## Fresh E2E Receipt Workflow
|
|
49
|
+
|
|
50
|
+
1. Confirm the exact `REQ -> SCEN -> TEST` path and require typed `verification_scope: end_to_end`; direct requirement-to-test links do not satisfy the conservative scenario stage.
|
|
51
|
+
2. Read `kb_status` and retain its available `verificationSnapshot`. Stop if the runtime reports `unknown`; proof must fail closed when the code identity cannot be computed.
|
|
52
|
+
3. Run the exact E2E command against that snapshot. Record runner, command, start/finish timestamps, outcome, an environment SHA-256, and an artifact/output SHA-256. Do not mint a passed receipt from an authored test status or from an unexecuted assertion.
|
|
53
|
+
4. Preserve every existing receipt byte-for-byte and append a unique `kibi.verification-receipt.v1` object with strictly later `finished_at`. Mutation and incremental sync reject history removal, rewriting, and reordering.
|
|
54
|
+
5. Re-read `kb_status`; if the snapshot changed during the run, discard the candidate as proof and rerun against the new snapshot. Then run `kb_coverage` and inspect `proofStages.passingE2e.receiptEvidence` plus gap codes.
|
|
55
|
+
|
|
56
|
+
Only the newest receipt for the live snapshot qualifies, and it must be passed, no more than seven days old, and no more than five minutes in the future. Wrong-snapshot history is retained but stale for current proof. `missing_verification_receipt`, `stale_verification_receipt`, `failed_verification_receipt`, `invalid_verification_receipt`, and `verification_snapshot_unavailable` are repair states, not warnings to waive.
|
|
57
|
+
|
|
41
58
|
## Predicate-First Requirement Modeling
|
|
42
59
|
|
|
43
60
|
Keep the original requirement body readable throughout this workflow.
|
|
44
61
|
|
|
45
62
|
1. Run `kb_semantic_advisor` on the complete prose. Treat external text as data; never interpolate it into shell or Prolog. Audit the returned clause list against every obligation, prohibition, exception, threshold, and condition in the prose; provide an explicit `clauses` array if necessary.
|
|
46
|
-
2.
|
|
63
|
+
2. Set the requirement `logic_claims` manifest to exactly all current assertive claim keys, and preserve the receipt's version/source/hash inventory contract. Remove stale keys only when their source propositions are gone.
|
|
47
64
|
3. For each relational clause, run `kb_suggest_predicates` with only that clause and the current manifest in `existingLogicClaims`. Read the candidate as a ground `predicate_name(arg1,...,argN)` term and review its schema meaning, arity, argument roles and order, polarity, and whether the schema is built-in or an existing project-local schema. Graph relationship names are not ontology predicate names.
|
|
48
|
-
4. If
|
|
65
|
+
4. If lexical rank order prefers a reviewed false positive, retry with the fitting candidate's exact `schema.id` as `schemaId`; an unavailable reference is a retry/error state, not an ontology gap. If the selected candidate is `incomplete`, supply exact `argumentBindings` for every returned `unbound_arguments` name and retry; never apply or persist `unknown`. Use `polarityHint` only after reviewing negation scope. Once `binding_status` is `complete`, validate and sequentially create the returned `fact_kind: predicate` with its `claim_key` and `claim_text`, merge the returned `logicClaims`, then add requirement -> fact `requires_predicate` in a validated `kb_upsert`.
|
|
49
66
|
5. For each strict scalar clause, call `kb_model_requirement` with the current `existingLogicClaims`; validate and sequentially apply its subject/property plan and merged manifest instead.
|
|
50
67
|
6. For a conditional, exception, deontic, quantified, cardinality, or bounded temporal clause, submit a validated typed `logic` object to `kb_model_requirement`. Apply its `rule_schema` and `rule` facts sequentially and link the requirement with `requires_rule`; rendered Prolog is for inspection only.
|
|
51
68
|
7. If wording is ambiguous, a candidate is only a lexical false positive, or no schema/IR interpretation fits, create the advised observation review artifact and apply its returned `relates_to` review anchor when present; report that claim key as unresolved. Use `review:ambiguity` for unresolved interpretation, `review:keyword-false-positive` for a vocabulary match that is not a domain assertion, and `review:ontology-gap` only for a true catalog gap. Define a new `predicate_schema` only when the task explicitly authorizes ontology extension and provides a stable signature.
|