kibi-cursor 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor-plugin/plugin.json +1 -1
- package/CHANGELOG.md +85 -0
- package/README.md +16 -1
- package/agent-plugin/mcp.json +10 -0
- package/agent-plugin/plugin.json +11 -0
- package/agent-plugin/skills/init-kibi/SKILL.md +62 -0
- package/agent-plugin/skills/kibi-freshness/SKILL.md +44 -0
- package/agent-plugin/skills/kibi-traceability/SKILL.md +60 -0
- package/agent-plugin/skills/kibi-usage/SKILL.md +276 -0
- package/agent-plugin/skills/kibi-usage/resources/fact-lanes.md +235 -0
- package/agent-plugin/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/agent-plugin/skills/kibi-usage/resources/operation-access.md +44 -0
- package/agent-plugin/skills/kibi-usage/resources/relationship-directions.md +119 -0
- package/agent-plugin/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/agent-plugin/skills/kibi-usage/resources/workflows.md +97 -0
- package/dist/.cursor-plugin/plugin.json +1 -1
- package/dist/messages.d.ts +2 -2
- package/dist/messages.js +2 -2
- package/dist/skills/.canon-hash.json +7 -5
- package/dist/skills/kibi-traceability/SKILL.md +7 -1
- package/dist/skills/kibi-usage/SKILL.md +44 -12
- package/dist/skills/kibi-usage/resources/fact-lanes.md +12 -2
- package/dist/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/dist/skills/kibi-usage/resources/operation-access.md +19 -19
- package/dist/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/dist/skills/kibi-usage/resources/workflows.md +40 -8
- package/package.json +3 -2
- package/skills/.canon-hash.json +7 -5
- package/skills/kibi-traceability/SKILL.md +7 -1
- package/skills/kibi-usage/SKILL.md +44 -12
- package/skills/kibi-usage/resources/fact-lanes.md +12 -2
- package/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/skills/kibi-usage/resources/operation-access.md +19 -19
- package/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/skills/kibi-usage/resources/workflows.md +40 -8
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Typed Logic IR and Proposition Coverage
|
|
2
|
+
|
|
3
|
+
Kibi stores human prose as readable requirement text, but verifiable meaning belongs in typed facts and `kibi.logic.v1` rule facts. The host agent may propose an interpretation; Kibi validates, canonicalizes, hashes, persists, and reasons over it. Never submit a Prolog source string, goal, module, or function symbol. Rendered Prolog is an inspection preview only.
|
|
4
|
+
|
|
5
|
+
## Two-pass extraction
|
|
6
|
+
|
|
7
|
+
1. Run `kb_semantic_advisor` over the complete text. Supply explicit `clauses` when sentence splitting could hide a condition, exception, definition, descriptive assertion, threshold, quantity, or temporal qualifier.
|
|
8
|
+
2. Audit the returned `propositions` against the original UTF-8 text. Every assertive span must be `modeled`, `ambiguous`, `ontology_gap`, or `missing`; rationale, examples, and subjective commentary are `nonlogical` and remain readable prose.
|
|
9
|
+
3. For each assertive proposition, submit up to three typed `interpretations` when alternatives are plausible. Kibi compares canonical semantic keys; materially different valid interpretations remain unresolved regardless of confidence.
|
|
10
|
+
4. Apply only a validated plan, then read back the requirement, rule schema, rule fact, and all relationship targets. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions` before the final unfiltered check.
|
|
11
|
+
|
|
12
|
+
When a project-local schema names several ordered arguments, those arguments are facets of one relation, not separate propositions. Preserve the advisor claim key for the complete relation and do not manufacture clauses for each argument. Supporting `predicate_schema` facts carry the declared signature only; the ground predicate fact carries the claim provenance. Apply the exact `kb_suggest_predicates`/`kb_model_requirement` plan, reducing a rejected schema payload through `kb_validate_upsert` rather than silently downgrading a fitting declared relation to an observation.
|
|
13
|
+
|
|
14
|
+
## Logic IR shape
|
|
15
|
+
|
|
16
|
+
The supported v1 forms are:
|
|
17
|
+
|
|
18
|
+
- `kind: atom` with a ground `head`;
|
|
19
|
+
- `kind: rule` with a range-restricted `head` and `body`;
|
|
20
|
+
- `kind: constraint` with a body and no head.
|
|
21
|
+
|
|
22
|
+
Terms are typed `const`, `var`, `number`, `duration`, or ISO `timestamp`. Variables are explicitly declared as `forall` (the default) or body-local `exists`; an existential variable may not occur in a rule head. Bodies use `all`, `any`, closed-world `not`, comparisons, bounded `count`, and bounded temporal expressions. Modalities are `assert`, `deny`, `oblige`, `permit`, and `forbid`.
|
|
23
|
+
|
|
24
|
+
Every head and body variable must be bound by a positive atom. Negation is allowed only on an atom with `closedWorld: true`, and only when its variables are also positively bound. Function symbols, raw goals, cuts, meta-calls, dynamic predicates, I/O, unbounded aggregation, unsafe variables, and unstratified negation are rejected before persistence.
|
|
25
|
+
|
|
26
|
+
Example (inspection data, not executable input):
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"version": "kibi.logic.v1",
|
|
31
|
+
"kind": "rule",
|
|
32
|
+
"modality": "oblige",
|
|
33
|
+
"variables": [{"name": "U", "type": "user", "quantifier": "forall"}],
|
|
34
|
+
"head": {"kind": "atom", "name": "audit", "args": [{"kind": "var", "name": "U", "type": "user"}]},
|
|
35
|
+
"body": {"kind": "atom", "name": "admin_action", "args": [{"kind": "var", "name": "U", "type": "user"}]}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
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
|
+
|
|
41
|
+
## Contradictions and uncertainty
|
|
42
|
+
|
|
43
|
+
Kibi compares opposing modalities over matching heads and overlapping authority, scope, and validity intervals. `assert`/`deny`, `oblige`/`forbid`, and overlapping `permit`/`forbid` pairs can be contradictory. Different conditions, unresolved interpretations, unsupported ontology terms, analysis limits, and incomplete closure produce `unresolved`, never a false consistency proof. Preserve superseding requirements rather than deleting historical claims.
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
This table is the machine-readable interface map for Kibi's shared operation catalog. Every CLI route shown is dedicated; there is no generic operation runner. `--input JSON or flags` means the route supports exact MCP-shaped JSON from a file or stdin as well as its established human flags. `--input JSON` means the dedicated parity route is JSON-only.
|
|
4
4
|
|
|
5
|
-
| MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects |
|
|
5
|
+
| MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects | Interface |
|
|
6
6
|
|---|---|---|---|---|---|---|
|
|
7
|
-
| `kb_skills_list` | `skills-list` | `--input JSON` | read | no | `local-read` |
|
|
8
|
-
| `kb_skills_load` | `skills-load` | `--input JSON` | read | no | `local-read` |
|
|
9
|
-
| `kb_skills_read` | `skills-read` | `--input JSON` | read | no | `local-read` |
|
|
10
|
-
| `kb_query` | `query` | `--input JSON or flags` | read | yes | `kb-read` |
|
|
11
|
-
| `kb_search` | `search` | `--input JSON or flags` | read | yes | `kb-read` |
|
|
12
|
-
| `kb_status` | `status` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` |
|
|
13
|
-
| `kb_find_gaps` | `find-gaps` | `--input JSON or flags` | read | yes | `kb-read` |
|
|
14
|
-
| `kb_coverage` | `coverage` | `--input JSON or flags` | read | yes | `kb-read` |
|
|
15
|
-
| `kb_graph` | `graph` | `--input JSON or flags` | read | yes | `kb-read` |
|
|
16
|
-
| `kb_semantic_advisor` | `semantic-advisor` | `--input JSON` | read | no | `local-read` |
|
|
17
|
-
| `kb_model_requirement` | `model-requirement` | `--input JSON` | read | yes | `kb-read` |
|
|
18
|
-
| `kb_suggest_predicates` | `suggest-predicates` | `--input JSON` | read | yes | `kb-read` |
|
|
19
|
-
| `kb_autopilot_generate` | `autopilot-generate` | `--input JSON` | read | no | `workspace-read` |
|
|
20
|
-
| `kb_validate_upsert` | `validate-upsert` | `--input JSON` | read | yes | `kb-read` |
|
|
21
|
-
| `kb_upsert` | `upsert` | `--input JSON` | write | yes | `kb-write, workspace-write` |
|
|
22
|
-
| `kb_delete` | `delete` | `--input JSON` | write | yes | `kb-write, workspace-write` |
|
|
23
|
-
| `kb_check` | `check` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` |
|
|
24
|
-
| `kb_sparql_remote` | `sparql-remote` | `--input JSON` | read | no | `network-read` |
|
|
7
|
+
| `kb_skills_list` | `skills-list` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
|
|
8
|
+
| `kb_skills_load` | `skills-load` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
|
|
9
|
+
| `kb_skills_read` | `skills-read` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
|
|
10
|
+
| `kb_query` | `query` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
|
|
11
|
+
| `kb_search` | `search` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
|
|
12
|
+
| `kb_status` | `status` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` | peer; capability-selected |
|
|
13
|
+
| `kb_find_gaps` | `find-gaps` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
|
|
14
|
+
| `kb_coverage` | `coverage` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
|
|
15
|
+
| `kb_graph` | `graph` | `--input JSON or flags` | read | yes | `kb-read` | peer; capability-selected |
|
|
16
|
+
| `kb_semantic_advisor` | `semantic-advisor` | `--input JSON` | read | no | `local-read` | peer; capability-selected |
|
|
17
|
+
| `kb_model_requirement` | `model-requirement` | `--input JSON` | read | yes | `kb-read` | peer; capability-selected |
|
|
18
|
+
| `kb_suggest_predicates` | `suggest-predicates` | `--input JSON` | read | yes | `kb-read` | peer; capability-selected |
|
|
19
|
+
| `kb_autopilot_generate` | `autopilot-generate` | `--input JSON` | read | no | `workspace-read` | peer; capability-selected |
|
|
20
|
+
| `kb_validate_upsert` | `validate-upsert` | `--input JSON` | read | yes | `kb-read` | peer; capability-selected |
|
|
21
|
+
| `kb_upsert` | `upsert` | `--input JSON` | write | yes | `kb-write, workspace-write` | peer; capability-selected |
|
|
22
|
+
| `kb_delete` | `delete` | `--input JSON` | write | yes | `kb-write, workspace-write` | peer; capability-selected |
|
|
23
|
+
| `kb_check` | `check` | `--input JSON or flags` | read | yes | `kb-read, workspace-read` | peer; capability-selected |
|
|
24
|
+
| `kb_sparql_remote` | `sparql-remote` | `--input JSON` | read | no | `network-read` | peer; capability-selected |
|
|
25
25
|
|
|
26
26
|
## JSON execution recipes
|
|
27
27
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# UI / Visual Requirement Modeling
|
|
2
|
+
|
|
3
|
+
Optional, per-project lane for recording what the screen should look like so UI edits cannot
|
|
4
|
+
silently drift from the spec. Non-UI projects skip it entirely; no check rule requires it.
|
|
5
|
+
|
|
6
|
+
## Three layers
|
|
7
|
+
|
|
8
|
+
1. **Prose `req`** — the full on-screen description lives in the requirement body as the
|
|
9
|
+
searchable anchor agents discover with `kb_search` / `kb_query`.
|
|
10
|
+
2. **Strict facts** — checkable visual invariants as `fact_kind: subject` (`subject_key`,
|
|
11
|
+
linked `constrains`) plus `fact_kind: property_value` (`property_key`, `operator`, typed
|
|
12
|
+
`value_*`, linked `requires_property`). Incompatible values on the same subject/property
|
|
13
|
+
from two current requirements are rejected on write unless `supersedes`.
|
|
14
|
+
3. **Relational predicates** — ground `fact_kind: predicate` linked with `requires_predicate`.
|
|
15
|
+
The built-in `visual_layout_rule(subject, relation, target)` covers "X must remain visually
|
|
16
|
+
aligned with Y" (relation `aligned_with`). Other relational layout claims need a
|
|
17
|
+
project-local `predicate_schema` when the task authorizes ontology extension.
|
|
18
|
+
|
|
19
|
+
Kibi enforces stated facts and links, not pixels. Freeform spatial prose is stored and
|
|
20
|
+
searchable but is not machine-checked.
|
|
21
|
+
|
|
22
|
+
## Button position
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
id: FACT-UI-SUBMIT-REGION
|
|
26
|
+
fact_kind: subject
|
|
27
|
+
subject_key: settings.screen.submit_button
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
id: FACT-UI-SUBMIT-POSITION
|
|
32
|
+
fact_kind: property_value
|
|
33
|
+
subject_key: settings.screen.submit_button
|
|
34
|
+
property_key: position
|
|
35
|
+
operator: eq
|
|
36
|
+
value_type: string
|
|
37
|
+
value_string: bottom_right
|
|
38
|
+
canonical_key: settings.screen.submit_button.position.eq.bottom_right
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Link both facts from the requirement:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
id: REQ-UI-SETTINGS
|
|
45
|
+
relationships:
|
|
46
|
+
- type: constrains
|
|
47
|
+
from: REQ-UI-SETTINGS
|
|
48
|
+
to: FACT-UI-SUBMIT-REGION
|
|
49
|
+
- type: requires_property
|
|
50
|
+
from: REQ-UI-SETTINGS
|
|
51
|
+
to: FACT-UI-SUBMIT-POSITION
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A later requirement writing `position: top_left` on the same subject is rejected on write.
|
|
55
|
+
|
|
56
|
+
## Header item order
|
|
57
|
+
|
|
58
|
+
Use one indexed `property_key` per slot against the same subject region:
|
|
59
|
+
`nav_order_1: home`, `nav_order_2: search`, `nav_order_3: profile`, each as a separate
|
|
60
|
+
`property_value` fact linked with `requires_property`. This makes each slot independently
|
|
61
|
+
contradiction-checkable.
|
|
62
|
+
|
|
63
|
+
## Relational alignment
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
id: FACT-UI-NAV-ALIGN
|
|
67
|
+
fact_kind: predicate
|
|
68
|
+
predicate_name: visual_layout_rule
|
|
69
|
+
predicate_args: [navigation_rail, aligned_with, header]
|
|
70
|
+
polarity: assert
|
|
71
|
+
canonical_key: visual_layout_rule(navigation_rail,aligned_with,header)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Link with `requires_predicate`. An `assert`/`deny` pair over the same predicate namespace,
|
|
75
|
+
name, and ordered arguments is a blocking `domain-contradictions` conflict.
|
|
76
|
+
|
|
77
|
+
## UI component traceability
|
|
78
|
+
|
|
79
|
+
Model the component as a `symbol` with `sourceFile` and `symbol_role: behavioral`, linked
|
|
80
|
+
`implements` to the requirement, so component edits surface the visual spec in impact
|
|
81
|
+
diagnostics (`symbol_semantic_review_needed`).
|
|
82
|
+
|
|
83
|
+
## Workflow
|
|
84
|
+
|
|
85
|
+
1. `kb_semantic_advisor` on the full description; audit or supply `clauses`.
|
|
86
|
+
2. Relational clauses: `kb_suggest_predicates`, apply the predicate plan and
|
|
87
|
+
`requires_predicate`.
|
|
88
|
+
3. Scalar placement/alignment/order clauses: `kb_model_requirement`, apply the strict
|
|
89
|
+
subject/property plan and `constrains` / `requires_property`.
|
|
90
|
+
4. Preserve `claim_key` / `claim_text`; merge every key into the requirement
|
|
91
|
+
`logic_claims` manifest.
|
|
92
|
+
5. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`.
|
|
93
|
+
6. `kb_check` with `logic-coverage`, `predicate-verifiability`, `domain-contradictions`,
|
|
94
|
+
then a final unfiltered `kb_check`.
|
|
95
|
+
|
|
96
|
+
Non-UI projects: declare `has_ui: false` during bootstrap and no UI entities are proposed.
|
|
@@ -8,13 +8,20 @@ The canonical workflow for any KB operation follows this pattern:
|
|
|
8
8
|
2. **Confirm**: `kb_query` for exact IDs and state
|
|
9
9
|
3. **Inspect**: `kb_status` when freshness matters
|
|
10
10
|
4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
|
|
11
|
-
5. **Choose per-clause lanes**: `kb_suggest_predicates` for
|
|
11
|
+
5. **Choose per-clause lanes**: strict facts for scalar claims; `kb_suggest_predicates` for approved ground ontology relations; `kb_model_requirement` with `kibi.logic.v1` for conditions, exceptions, modalities, quantifiers, cardinality, and bounded temporal rules; observation review for ambiguity, nonlogical prose, and ontology gaps
|
|
12
12
|
6. **Preflight**: `kb_validate_upsert` for every intended entity or relationship payload
|
|
13
13
|
7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
|
|
14
|
-
8. **Link**: validated `kb_upsert` with `requires_predicate`, `constrains`, or `requires_property`, sequentially
|
|
15
|
-
9. **Validate coverage and consistency**: targeted `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then final full `kb_check`
|
|
14
|
+
8. **Link**: validated `kb_upsert` with `requires_rule`, `requires_predicate`, `constrains`, or `requires_property`, sequentially
|
|
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
|
-
Every current requirement without `logic_claims` remains visible as non-blocking backfill debt. Once a manifest
|
|
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.
|
|
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`.
|
|
18
25
|
|
|
19
26
|
## Creating a New Feature
|
|
20
27
|
```
|
|
@@ -38,17 +45,28 @@ 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
|
-
6.
|
|
51
|
-
7.
|
|
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.
|
|
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.
|
|
69
|
+
8. Read back the requirement, proposition ledger, and all facts. Confirm every manifest key occurs on exactly one intended ground fact/rule, no punctuation variant minted a second claim, and no two claim keys encode the same logical term. Exact query output may represent repeated relationship types as arrays, so inspect every target. Then run `kb_check` with `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`. Finish with an unfiltered `kb_check`.
|
|
52
70
|
|
|
53
71
|
Do not treat the manifest itself as proof of grounding. The advisor keeps readiness partial while there are fewer logical edge slots than normative claims; final readback and `logic-coverage` bind those slots to exact claim keys and ground terms.
|
|
54
72
|
|
|
@@ -56,6 +74,20 @@ Examples: built-in permission and deny claims use the suggested `permission_rule
|
|
|
56
74
|
|
|
57
75
|
On resume after interruption, repeat `kb_query` for exact endpoints and apply only missing validated writes. Keep `kb_upsert` concurrency at one.
|
|
58
76
|
|
|
77
|
+
## UI / Visual Requirement Modeling
|
|
78
|
+
|
|
79
|
+
Optional per-project workflow for recording what the screen should look like. Non-UI projects skip this lane entirely.
|
|
80
|
+
|
|
81
|
+
1. Create a prose `req` holding the full visual description; it is the searchable anchor agents discover before touching a UI file.
|
|
82
|
+
2. Run `kb_semantic_advisor` on the description; audit or supply `clauses`.
|
|
83
|
+
3. For relational layout clauses ("X must remain visually aligned with Y"), call `kb_suggest_predicates`, apply the returned `fact_kind: predicate` plan with `predicate_name: visual_layout_rule` and `requires_predicate`.
|
|
84
|
+
4. For scalar placement, alignment, and ordering clauses, call `kb_model_requirement` and apply strict `fact_kind: subject` / `fact_kind: property_value` facts linked with `constrains` / `requires_property`. Model header order as indexed property keys (`nav_order_1`, `nav_order_2`, ...) against one subject region.
|
|
85
|
+
5. Preserve `claim_key` / `claim_text` on every ground fact and merge every key into the requirement `logic_claims` manifest.
|
|
86
|
+
6. Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement.
|
|
87
|
+
7. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`. Run `kb_check` with `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then a final unfiltered `kb_check`.
|
|
88
|
+
|
|
89
|
+
Incompatible values on the same subject/property from two current requirements are rejected on write; change an intentional value via a replacement requirement linked with `supersedes`. Full payloads are in `resources/ui-requirements.md`.
|
|
90
|
+
|
|
59
91
|
## Fixing a Traceability Gap
|
|
60
92
|
```
|
|
61
93
|
1. kb_query --sourceFile <code-file> to find linked entities
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-cursor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Kibi Cursor plugin - thin adapter for Cursor MCP integration and editor hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"skills",
|
|
20
20
|
"rules",
|
|
21
21
|
"commands",
|
|
22
|
+
"agent-plugin",
|
|
22
23
|
"dist",
|
|
23
24
|
"CHANGELOG.md"
|
|
24
25
|
],
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"access": "public"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
|
-
"build": "tsc -p tsconfig.json && bun run scripts/copy-plugin-assets.ts && bun run ../../scripts/sync-agent-skills.ts --write --target cursor",
|
|
38
|
+
"build": "tsc -p tsconfig.json && bun run scripts/copy-plugin-assets.ts && bun run scripts/build-agent-plugin.ts && bun run ../../scripts/sync-agent-skills.ts --write --target cursor",
|
|
38
39
|
"dev": "tsc -p tsconfig.json --watch",
|
|
39
40
|
"clean": "rm -rf dist",
|
|
40
41
|
"prepack": "npm run build"
|
package/skills/.canon-hash.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"init-kibi/SKILL.md": "4e936774cd31cf366e9e17452e9030fdaeabab345bce5ee163656e0fe5dc73d7",
|
|
3
3
|
"kibi-freshness/SKILL.md": "68345a514233503f8f78d53e7d602d8a5fc566e1ec118388c7393716c9f7490d",
|
|
4
|
-
"kibi-traceability/SKILL.md": "
|
|
5
|
-
"kibi-usage/SKILL.md": "
|
|
6
|
-
"kibi-usage/resources/fact-lanes.md": "
|
|
7
|
-
"kibi-usage/resources/
|
|
4
|
+
"kibi-traceability/SKILL.md": "3aee5cb0d3d8e41d29cb6804ac9303083e8477fc9cb90f76248a7dc8e907a4b3",
|
|
5
|
+
"kibi-usage/SKILL.md": "e31077634b0d53700eb4ff15c82e04239340b08cd327e6d99c831f89c3e10904",
|
|
6
|
+
"kibi-usage/resources/fact-lanes.md": "41b28023a57593009867ea0ebc8e9f3f05c3bd837144772d12844423f922e763",
|
|
7
|
+
"kibi-usage/resources/logic-ir.md": "151675d0ffa813cb9e271084102a3af42de369b8f9a0c64866af0cdc4d924063",
|
|
8
|
+
"kibi-usage/resources/operation-access.md": "a5ec895aa9b2f30140b2b72baf444843d32dd99e92d6e10be4279d84f5ea799b",
|
|
8
9
|
"kibi-usage/resources/relationship-directions.md": "aecbde048bb84e210318e4aca98e07f8370168c640c3a9d65696d2195c8598ec",
|
|
9
|
-
"kibi-usage/resources/
|
|
10
|
+
"kibi-usage/resources/ui-requirements.md": "b7c31ab1affa3ab25ae5242d8fd8c4d546532d1cafc65d84088375317c1682cc",
|
|
11
|
+
"kibi-usage/resources/workflows.md": "06cf3da42b0cc96a3f38c0c37b28ee435fa93f45a93dc665fc5d756094ee1eab"
|
|
10
12
|
}
|
|
@@ -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}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: kibi-usage
|
|
3
3
|
name: Kibi Usage
|
|
4
4
|
description: Guides agents to use Kibi MCP, facts, relationships, and validation correctly
|
|
5
|
-
version: 1.
|
|
5
|
+
version: 1.3.0
|
|
6
6
|
kibiCompatibility: ">=0.11.0"
|
|
7
7
|
tags:
|
|
8
8
|
- kibi
|
|
@@ -15,6 +15,8 @@ resources:
|
|
|
15
15
|
- resources/fact-lanes.md
|
|
16
16
|
- resources/workflows.md
|
|
17
17
|
- resources/operation-access.md
|
|
18
|
+
- resources/ui-requirements.md
|
|
19
|
+
- resources/logic-ir.md
|
|
18
20
|
---
|
|
19
21
|
# Kibi Usage
|
|
20
22
|
|
|
@@ -22,10 +24,10 @@ Consult this skill before any Kibi knowledge base operation, on first interactio
|
|
|
22
24
|
|
|
23
25
|
## Interface Selection
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
Kibi exposes two peer surfaces over the same 18 operations: visible MCP tools and the trusted project-local CLI. Both accept the same business input and effects (see `resources/operation-access.md`). Choose by what is visible and approved in the current environment — MCP and the CLI are equal choices, not a preference order:
|
|
26
28
|
|
|
27
29
|
1. If Kibi MCP tools are visible and approved in the current environment, use MCP.
|
|
28
|
-
2. Otherwise, in a trusted workspace, use the project-local CLI through a non-installing runner: `npx --no-install kibi ...` or `bunx --no-install kibi ...`.
|
|
30
|
+
2. Otherwise, in a trusted workspace, use the project-local CLI through a non-installing runner: `npx --no-install kibi ...` or `bunx --no-install kibi ...`. The CLI is a peer interface, not a fallback.
|
|
29
31
|
3. If the project-local CLI is unavailable or too old for the needed route, stop and tell the operator to enable or install Kibi.
|
|
30
32
|
4. Never use a global fallback or an installing runner. Never probe or install packages as a side effect of interface selection.
|
|
31
33
|
|
|
@@ -99,6 +101,20 @@ relationships:
|
|
|
99
101
|
to: REQ-ADMIN-BILLING-POLICY
|
|
100
102
|
```
|
|
101
103
|
|
|
104
|
+
## Typed Logic IR Lane
|
|
105
|
+
|
|
106
|
+
Readable prose is retained for people, while every assertive proposition is inventoried and either grounded in a strict fact, a predicate fact, or a safe typed rule. Use the required extraction pass followed by an adversarial coverage audit; do not let a high-confidence single suggestion stand in for the rest of a compound requirement. Load `resources/logic-ir.md` for the IR grammar, proposition ledger, safety boundary, and proof semantics.
|
|
107
|
+
|
|
108
|
+
Use `kb_semantic_advisor` with up to three typed `interpretations` for ambiguous clauses. Kibi canonicalizes alternatives and keeps materially different meanings unresolved. Create `fact_kind: rule_schema` and `fact_kind: rule` endpoints from `kb_model_requirement`'s validated plan, then link `req -> rule` with `requires_rule`. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions`; unresolved, incomplete, or timed-out reasoning is not evidence of consistency.
|
|
109
|
+
|
|
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
|
+
|
|
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
|
+
|
|
102
118
|
## Strict Fact Lane
|
|
103
119
|
|
|
104
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`.
|
|
@@ -126,19 +142,25 @@ Use `kb_model_requirement` for automated strict-fact modeling when available. It
|
|
|
126
142
|
|
|
127
143
|
Granular fact examples for coherence checks include `REQ-ROLE-SET-2` versus `REQ-ROLE-SET-3` on `user.roles.allowed_set` (`user,admin` versus `user,admin,superadmin`) and `REQ-ADMIN-CAN-MANAGE-BILLING` versus `REQ-ONLY-SUPERADMIN-MANAGES-BILLING` on `billing.manage.allowed_actor`. See `resources/fact-lanes.md`; `domain-contradictions` uses these canonical keys.
|
|
128
144
|
|
|
145
|
+
## UI / Visual Requirement Modeling
|
|
146
|
+
|
|
147
|
+
Optional, per-project lane for recording what the screen should look like so UI edits cannot silently drift from the spec. Non-UI projects skip it; no check rule requires it.
|
|
148
|
+
|
|
149
|
+
Use three layers: a prose `req` as the searchable anchor, strict `property_value` facts for checkable positions/alignment/order (linked `constrains` / `requires_property`, so incompatible values on the same subject/property are rejected on write unless `supersedes`), and relational predicates linked with `requires_predicate` (built-in `visual_layout_rule(subject, relation, target)` for "X must remain visually aligned with Y"). Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement, so component edits surface the visual spec in impact diagnostics. Full payloads and workflow: `resources/ui-requirements.md`.
|
|
150
|
+
|
|
129
151
|
## Complete Logical Coverage
|
|
130
152
|
|
|
131
153
|
Readable prose is not evidence that a requirement is machine-checkable. Before treating a normative requirement as modeled, decompose its entire body into atomic normative clauses and ground every clause. One correct fact or relationship never proves that the other prose is covered.
|
|
132
154
|
|
|
133
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.
|
|
134
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.
|
|
135
|
-
3. Put the
|
|
136
|
-
4. Ground each key through exactly one suitable logical lane: `requires_property` to one strict `property_value` fact,
|
|
137
|
-
5. Run `kb_check` with `logic-coverage`, `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.
|
|
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.
|
|
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.
|
|
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.
|
|
138
160
|
|
|
139
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.
|
|
140
162
|
|
|
141
|
-
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.
|
|
142
164
|
|
|
143
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.
|
|
144
166
|
|
|
@@ -165,11 +187,21 @@ Preserve the readable requirement prose. Facts add a machine-queryable model; th
|
|
|
165
187
|
|
|
166
188
|
1. Call `kb_semantic_advisor` on the complete prose, verify its atomic clause inventory, and choose one lane per clause.
|
|
167
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.
|
|
168
|
-
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.
|
|
169
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.
|
|
170
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`.
|
|
171
|
-
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 and report the requirement as logically incomplete.
|
|
172
|
-
7. Validate every payload, create endpoints first, apply `kb_upsert` calls sequentially, read back all affected IDs, and run targeted `logic-coverage`, `predicate-verifiability`, and `domain-contradictions` checks before the final unfiltered `kb_check`. Exact query output can return an array when one relationship type has multiple targets; verify every target rather than reading only one edge.
|
|
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.
|
|
194
|
+
7. Validate every payload, create endpoints first, apply `kb_upsert` calls sequentially, read back all affected IDs, and run targeted `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions` checks before the final unfiltered `kb_check`. Exact query output can return an array when one relationship type has multiple targets; verify every target rather than reading only one edge.
|
|
195
|
+
|
|
196
|
+
### Schema-aware proposition boundary
|
|
197
|
+
|
|
198
|
+
A declared project-local predicate schema can encode one complete relation whose ordered arguments name several facets of the same claim. Do not split those arguments into separate propositions, invent one predicate per noun, or pass an explicit `clauses` array merely to enumerate the schema arguments. First ask `kb_semantic_advisor` about the complete sentence; add clauses only for independently asserted propositions that are not represented by the selected relation. For a schema-backed relation, preserve the one claim key for the complete relation, create the supporting `predicate_schema` with its minimal declared signature (supporting schemas do not carry `claim_key` or `logic_claims`), call `kb_suggest_predicates` on the complete claim, and apply its exact plan to create one ground predicate fact with the ordered schema arguments and that claim key. If `kb_model_requirement` returns an apply plan, execute that plan sequentially; do not fall back to observation facts when an explicitly declared schema fits. If a schema write is rejected, use `kb_validate_upsert` to reduce it to the supported signature, then retry once before considering an ontology gap.
|
|
199
|
+
|
|
200
|
+
### Hard lane gates for unresolved prose and supplied schemas
|
|
201
|
+
|
|
202
|
+
The advisor's proposition `status` is a safety gate, not a confidence hint. A `nonlogical` proposition (including `subjective`, rationale, example, heading, or commentary) never receives a `logic_claims` entry and never goes through `kb_suggest_predicates` or `kb_model_requirement`; preserve the complete prose as one `fact_kind: observation` only when an auditable record is useful. Do not manufacture atomic clauses from a subjective sentence merely because it contains `when`, a domain noun, or the word `predicate`. An `ambiguous` proposition remains an ambiguity observation until the operator supplies a typed interpretation. An `ontology_gap` remains unresolved unless an approved schema or validated IR is actually available.
|
|
203
|
+
|
|
204
|
+
When authorized task input contains `projectLocalSchemas`, those declarations are the schema authority even if the first advisor or predicate lookup calls them an ontology gap. Do not treat an empty candidate list as final: create the minimal declared `predicate_schema` endpoint first, then call `kb_suggest_predicates` again on the one complete claim (with the current `existingLogicClaims`) and apply the resulting ground predicate plan. Preserve the single claim key for that relation; do not add keys for schema arguments. If the lookup still cannot return a plan after the declared schema exists, validate the exact schema-backed predicate payload once and report the remaining blocker rather than inventing a different predicate. For prohibition cues (`must not`, `never`, `cannot`, `forbidden`), use the positive schema with `polarity: deny`; never silently change it to `assert` or encode the negation in a new predicate name.
|
|
173
205
|
|
|
174
206
|
Example: “Checkout requires payment authorization before order submission” fits `dependency_rule(subject, prerequisite, dependent)`. The ground model is `dependency_rule(checkout,payment_authorization,order_submission)`, stored as:
|
|
175
207
|
|
|
@@ -217,7 +249,7 @@ Never fire `kb_upsert` calls in parallel. Execute them sequentially to avoid loc
|
|
|
217
249
|
|
|
218
250
|
## Checks
|
|
219
251
|
|
|
220
|
-
Run `kb_check` with specific rules during iteration for fast feedback. For normative requirement modeling, include `rules: ["logic-coverage", "predicate-verifiability", "domain-contradictions"]`; add `required-fields` and `no-dangling-refs` after writes. Run a full `kb_check` without rule filters before declaring Kibi work complete.
|
|
252
|
+
Run `kb_check` with specific rules during iteration for fast feedback. For normative requirement modeling, include `rules: ["rule-safety", "rule-verifiability", "semantic-completeness", "logic-coverage", "predicate-verifiability", "domain-contradictions"]`; add `required-fields` and `no-dangling-refs` after writes. Run a full `kb_check` without rule filters before declaring Kibi work complete.
|
|
221
253
|
|
|
222
254
|
The `domain-contradictions` rule detects conflicts between strict-lane facts linked to requirements. When a contradiction is found, the supported escape hatch is `supersedes`: create a new requirement that supersedes the old one, then link the new requirement to updated facts.
|
|
223
255
|
|
|
@@ -238,7 +270,7 @@ Call `kb_status` when branch KB context may be stale or after switching context.
|
|
|
238
270
|
| Tags as multi-ID lookup | Tags are metadata, not identifiers | Use `kb_query` with explicit `id` values |
|
|
239
271
|
| `relates_to` for strict modeling | Loses contradiction safety | Use `constrains` and `requires_property` instead |
|
|
240
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` |
|
|
241
|
-
|
|
|
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 |
|
|
242
274
|
| Observation counted as coverage | Ambiguity or ontology gaps appear machine-checkable | Keep the claim unresolved until a strict or predicate ground fact exists |
|
|
243
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 |
|
|
244
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,8 +7,8 @@ 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
|
|
11
|
-
- link it through exactly one `requires_property` for `property_value` or one `
|
|
10
|
+
- add the key to the exact current `logic_claims` set, removing only stale keys whose propositions no longer exist in the source;
|
|
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
|
|
|
14
14
|
Use the advisor-returned atomic inventory as the identity boundary. Trailing punctuation and copied conjunction commas are formatting, not new claims. `logic-coverage` rejects one claim grounded by multiple facts and distinct claim keys that resolve to the same ground logical term.
|
|
@@ -76,6 +76,16 @@ If another current requirement links an `assert` fact with the same predicate na
|
|
|
76
76
|
|
|
77
77
|
The full logical representation of a requirement is the conjunction of all of its linked ground property and predicate terms. Conditions, exceptions, permissions, and ordering constraints remain explicit arguments of their declared schemas. Contradiction detection therefore depends on equivalent prose reusing the same predicate name, argument roles, ordered canonical values, and opposing polarity rather than inventing synonymous terms.
|
|
78
78
|
|
|
79
|
+
### Lane gates before a predicate lookup
|
|
80
|
+
|
|
81
|
+
Treat the advisor's proposition status as a hard routing decision. `nonlogical`/`subjective` prose is not a logical claim: keep it as one observation when needed and do not add its key to `logic_claims`. `ambiguous` prose stays an ambiguity observation. `ontology_gap` prose stays unresolved unless an approved schema or validated Logic IR is available. Never split a subjective or commentary sentence into synthetic clauses just because it contains conditional words or domain vocabulary.
|
|
82
|
+
|
|
83
|
+
If authorized input supplies `projectLocalSchemas`, use those signatures as the authority. Create the minimal `predicate_schema` endpoint before lookup, then rerun `kb_suggest_predicates` on the complete relation if the first lookup had no candidate. Apply exactly one ground predicate and one claim key for that relation. For `must not`, `never`, `cannot`, or `forbidden` wording, preserve the positive schema and set `polarity: deny`; do not turn the result into an asserted predicate or invent a negative name. An empty lookup before the declared schema exists is a retry condition, not proof of an ontology gap.
|
|
84
|
+
|
|
85
|
+
## Typed rule lane
|
|
86
|
+
|
|
87
|
+
Use a validated `kibi.logic.v1` object for a proposition whose meaning includes a condition, exception, obligation, prohibition, permission, quantifier, cardinality bound, or bounded temporal relation. `kb_model_requirement` returns the `rule_schema` and `rule` facts plus a `requires_rule` edge. The rule stores canonical JSON and a deterministic hash; any rendered Prolog is an audit view and is never executed. Reject raw goals, function symbols, cuts, meta-calls, dynamic predicates, I/O, unsafe variables, unstratified negation, and unbounded aggregation. Keep the exact proposition in `claim_text`, its advisor key in `claim_key`, and its byte span in the semantic ledger. Run `rule-safety` and `rule-verifiability` before treating the rule as modeled.
|
|
88
|
+
|
|
79
89
|
### Strict scalar
|
|
80
90
|
|
|
81
91
|
Claim: “Sessions expire after at most 30 minutes.” This is a scalar limit, not a predicate. Route it through `kb_model_requirement` to a subject plus `property_value` with `operator: lte`, `value_type: int`, and `value_int: 30`, linked by `constrains` and `requires_property`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Typed Logic IR and Proposition Coverage
|
|
2
|
+
|
|
3
|
+
Kibi stores human prose as readable requirement text, but verifiable meaning belongs in typed facts and `kibi.logic.v1` rule facts. The host agent may propose an interpretation; Kibi validates, canonicalizes, hashes, persists, and reasons over it. Never submit a Prolog source string, goal, module, or function symbol. Rendered Prolog is an inspection preview only.
|
|
4
|
+
|
|
5
|
+
## Two-pass extraction
|
|
6
|
+
|
|
7
|
+
1. Run `kb_semantic_advisor` over the complete text. Supply explicit `clauses` when sentence splitting could hide a condition, exception, definition, descriptive assertion, threshold, quantity, or temporal qualifier.
|
|
8
|
+
2. Audit the returned `propositions` against the original UTF-8 text. Every assertive span must be `modeled`, `ambiguous`, `ontology_gap`, or `missing`; rationale, examples, and subjective commentary are `nonlogical` and remain readable prose.
|
|
9
|
+
3. For each assertive proposition, submit up to three typed `interpretations` when alternatives are plausible. Kibi compares canonical semantic keys; materially different valid interpretations remain unresolved regardless of confidence.
|
|
10
|
+
4. Apply only a validated plan, then read back the requirement, rule schema, rule fact, and all relationship targets. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions` before the final unfiltered check.
|
|
11
|
+
|
|
12
|
+
When a project-local schema names several ordered arguments, those arguments are facets of one relation, not separate propositions. Preserve the advisor claim key for the complete relation and do not manufacture clauses for each argument. Supporting `predicate_schema` facts carry the declared signature only; the ground predicate fact carries the claim provenance. Apply the exact `kb_suggest_predicates`/`kb_model_requirement` plan, reducing a rejected schema payload through `kb_validate_upsert` rather than silently downgrading a fitting declared relation to an observation.
|
|
13
|
+
|
|
14
|
+
## Logic IR shape
|
|
15
|
+
|
|
16
|
+
The supported v1 forms are:
|
|
17
|
+
|
|
18
|
+
- `kind: atom` with a ground `head`;
|
|
19
|
+
- `kind: rule` with a range-restricted `head` and `body`;
|
|
20
|
+
- `kind: constraint` with a body and no head.
|
|
21
|
+
|
|
22
|
+
Terms are typed `const`, `var`, `number`, `duration`, or ISO `timestamp`. Variables are explicitly declared as `forall` (the default) or body-local `exists`; an existential variable may not occur in a rule head. Bodies use `all`, `any`, closed-world `not`, comparisons, bounded `count`, and bounded temporal expressions. Modalities are `assert`, `deny`, `oblige`, `permit`, and `forbid`.
|
|
23
|
+
|
|
24
|
+
Every head and body variable must be bound by a positive atom. Negation is allowed only on an atom with `closedWorld: true`, and only when its variables are also positively bound. Function symbols, raw goals, cuts, meta-calls, dynamic predicates, I/O, unbounded aggregation, unsafe variables, and unstratified negation are rejected before persistence.
|
|
25
|
+
|
|
26
|
+
Example (inspection data, not executable input):
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"version": "kibi.logic.v1",
|
|
31
|
+
"kind": "rule",
|
|
32
|
+
"modality": "oblige",
|
|
33
|
+
"variables": [{"name": "U", "type": "user", "quantifier": "forall"}],
|
|
34
|
+
"head": {"kind": "atom", "name": "audit", "args": [{"kind": "var", "name": "U", "type": "user"}]},
|
|
35
|
+
"body": {"kind": "atom", "name": "admin_action", "args": [{"kind": "var", "name": "U", "type": "user"}]}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
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
|
+
|
|
41
|
+
## Contradictions and uncertainty
|
|
42
|
+
|
|
43
|
+
Kibi compares opposing modalities over matching heads and overlapping authority, scope, and validity intervals. `assert`/`deny`, `oblige`/`forbid`, and overlapping `permit`/`forbid` pairs can be contradictory. Different conditions, unresolved interpretations, unsupported ontology terms, analysis limits, and incomplete closure produce `unresolved`, never a false consistency proof. Preserve superseding requirements rather than deleting historical claims.
|