kibi-cursor 0.5.0 → 0.5.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.
Files changed (33) hide show
  1. package/.cursor-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +49 -0
  3. package/README.md +16 -1
  4. package/agent-plugin/mcp.json +10 -0
  5. package/agent-plugin/plugin.json +11 -0
  6. package/agent-plugin/skills/init-kibi/SKILL.md +62 -0
  7. package/agent-plugin/skills/kibi-freshness/SKILL.md +44 -0
  8. package/agent-plugin/skills/kibi-traceability/SKILL.md +54 -0
  9. package/agent-plugin/skills/kibi-usage/SKILL.md +270 -0
  10. package/agent-plugin/skills/kibi-usage/resources/fact-lanes.md +235 -0
  11. package/agent-plugin/skills/kibi-usage/resources/logic-ir.md +43 -0
  12. package/agent-plugin/skills/kibi-usage/resources/operation-access.md +44 -0
  13. package/agent-plugin/skills/kibi-usage/resources/relationship-directions.md +119 -0
  14. package/agent-plugin/skills/kibi-usage/resources/ui-requirements.md +96 -0
  15. package/agent-plugin/skills/kibi-usage/resources/workflows.md +80 -0
  16. package/dist/.cursor-plugin/plugin.json +1 -1
  17. package/dist/messages.d.ts +2 -2
  18. package/dist/messages.js +2 -2
  19. package/dist/skills/.canon-hash.json +6 -4
  20. package/dist/skills/kibi-usage/SKILL.md +35 -9
  21. package/dist/skills/kibi-usage/resources/fact-lanes.md +11 -1
  22. package/dist/skills/kibi-usage/resources/logic-ir.md +43 -0
  23. package/dist/skills/kibi-usage/resources/operation-access.md +19 -19
  24. package/dist/skills/kibi-usage/resources/ui-requirements.md +96 -0
  25. package/dist/skills/kibi-usage/resources/workflows.md +21 -6
  26. package/package.json +3 -2
  27. package/skills/.canon-hash.json +6 -4
  28. package/skills/kibi-usage/SKILL.md +35 -9
  29. package/skills/kibi-usage/resources/fact-lanes.md +11 -1
  30. package/skills/kibi-usage/resources/logic-ir.md +43 -0
  31. package/skills/kibi-usage/resources/operation-access.md +19 -19
  32. package/skills/kibi-usage/resources/ui-requirements.md +96 -0
  33. package/skills/kibi-usage/resources/workflows.md +21 -6
@@ -0,0 +1,235 @@
1
+ # Fact Lanes
2
+
3
+ Requirement prose remains the human-readable source. Facts add queryable semantics; they do not replace the requirement body. Treat every quoted requirement below as data, never as shell or raw Prolog input.
4
+
5
+ ## Atomic Claim Coverage
6
+
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
+
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 requirement `logic_claims` manifest without removing existing keys;
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
+ - leave ambiguity and ontology gaps visibly unresolved—observations do not satisfy `logic-coverage`.
13
+
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.
15
+
16
+ Example compound prose: “Checkout requires payment authorization before order submission, and customer data must be retained for 7 years.” This is two claims, not one. The first becomes `dependency_rule(checkout,payment_authorization,order_submission)`; the second becomes a strict retention property. Both fact records carry different advisor-issued claim keys, and both keys appear in the requirement manifest. A single `requires_predicate` edge is incomplete.
17
+
18
+ ## Predicate Lane (Relational Claims)
19
+
20
+ Call `kb_semantic_advisor`, then `kb_suggest_predicates`. Apply a candidate only when its schema meaning and ordered arguments fit the claim. Use the returned `applyPlan` rather than hand-writing unsupported predicate names, and link the requirement to the predicate fact with `requires_predicate`.
21
+
22
+ Treat the result as a Prolog-shaped ground term, not executable source: `predicate_name(arg1,...,argN)`. The selected `predicate_schema` fixes the name, arity, argument roles, and order. Store that model through `predicate_name`, `predicate_args`, `canonical_key`, and `polarity`; never interpolate prose into raw Prolog, introduce variables, or use a graph relationship such as `verified_by` as the predicate name.
23
+
24
+ ### Built-in predicate
25
+
26
+ Claim: “Checkout requires payment authorization before order submission.” The built-in `dependency_rule(subject, prerequisite, dependent)` schema produces:
27
+
28
+ ```yaml
29
+ id: FACT-CHECKOUT-PAYMENT-DEPENDENCY
30
+ status: active
31
+ fact_kind: predicate
32
+ predicate_name: dependency_rule
33
+ predicate_args: [checkout, payment_authorization, order_submission]
34
+ polarity: assert
35
+ canonical_key: dependency_rule(checkout,payment_authorization,order_submission)
36
+ claim_key: <advisor-issued key for this exact clause>
37
+ claim_text: Checkout requires payment authorization before order submission.
38
+ relationship: { type: requires_predicate, from: REQ-CHECKOUT-SUBMISSION, to: FACT-CHECKOUT-PAYMENT-DEPENDENCY }
39
+ ```
40
+
41
+ ### Project-local predicate
42
+
43
+ If the project has an approved `commit_action(subject, trigger, object)` predicate schema, “Editor annotation drafts autosave on navigation” may use:
44
+
45
+ ```yaml
46
+ id: FACT-EDITOR-DRAFT-AUTOSAVE
47
+ status: active
48
+ fact_kind: predicate
49
+ predicate_name: commit_action
50
+ predicate_args: [editor.annotation, navigation, draft]
51
+ polarity: assert
52
+ canonical_key: commit_action(editor.annotation,navigation,draft)
53
+ relationship: { type: requires_predicate, from: REQ-EDITOR-DRAFT-AUTOSAVE, to: FACT-EDITOR-DRAFT-AUTOSAVE }
54
+ ```
55
+
56
+ The project-local schema endpoint must exist before this fact is linked. When ontology extension is explicitly authorized, define it first with `fact_kind: predicate_schema`, `predicate_name`, `predicate_arity`, and equally sized `argument_names` and `argument_types`. Without an authorized stable signature, record `review:ontology-gap` instead of inventing a schema.
57
+
58
+ ### Deny predicate
59
+
60
+ Claim: “Suspended users must not publish articles.” When `permission_rule` fits, preserve its positive schema name and encode prohibition as polarity:
61
+
62
+ ```yaml
63
+ id: FACT-SUSPENDED-PUBLISH-DENIED
64
+ status: active
65
+ fact_kind: predicate
66
+ predicate_name: permission_rule
67
+ predicate_args: [suspended_user, publish, article]
68
+ polarity: deny
69
+ canonical_key: permission_rule(suspended_user,publish,article)
70
+ claim_key: <advisor-issued key for this exact clause>
71
+ claim_text: Suspended users must not publish articles.
72
+ relationship: { type: requires_predicate, from: REQ-SUSPENDED-PUBLISH-DENIED, to: FACT-SUSPENDED-PUBLISH-DENIED }
73
+ ```
74
+
75
+ If another current requirement links an `assert` fact with the same predicate namespace, name, and ordered arguments, `domain-contradictions` reports the pair. More complex semantic conflicts require a shared canonical schema and arguments; do not assume Kibi can prove arbitrary equivalence between differently shaped predicates.
76
+
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
+
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
+
89
+ ### Strict scalar
90
+
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`.
92
+
93
+ ### Ambiguous claim
94
+
95
+ Claim: “Premium accounts get better support.” “Better” does not identify a stable relation or scalar. Keep readable prose and create a `fact_kind: observation` tagged `review:ambiguity`; request clarification before adding strict or predicate facts.
96
+
97
+ ### False-positive trap
98
+
99
+ Claim: “Suspended users must not publish articles.” A lexical match such as `publishes_event` is semantically wrong because an article is not a domain event. Reject that candidate and use the suitable permission schema if one is returned; otherwise use a review observation. Candidate rank alone is never proof of suitability.
100
+
101
+ ### Ontology gap
102
+
103
+ Claim: “Annotations remain anchored to selected text after edits.” If no returned built-in or approved project-local schema expresses anchoring preservation, do not invent one:
104
+
105
+ ```yaml
106
+ id: FACT-ONTOLOGY-GAP-ANNOTATION-ANCHOR
107
+ status: active
108
+ fact_kind: observation
109
+ tags: [review:ontology-gap]
110
+ text_ref: docs/requirements/annotation-anchor.md
111
+ ```
112
+
113
+ An ontology-gap observation records review work; it does not make the requirement machine-checkable.
114
+
115
+ ## Strict Lane (Contradiction-Safe)
116
+
117
+ ### fact_kind: subject
118
+ ```yaml
119
+ id: FACT-USER-ROLE
120
+ title: User Role Assignment
121
+ status: active
122
+ fact_kind: subject
123
+ subject_key: user.role_assignment
124
+ ```
125
+
126
+ ### fact_kind: property_value
127
+ ```yaml
128
+ id: FACT-LIMIT-3
129
+ title: Maximum of Three Roles
130
+ status: active
131
+ fact_kind: property_value
132
+ subject_key: user.role_assignment
133
+ property_key: max_roles
134
+ operator: lte
135
+ value_type: int
136
+ value_int: 3
137
+ ```
138
+
139
+ ## Granular Facts for Coherence Checks
140
+
141
+ Granular strict facts work best when each `property_value` represents one semantic claim about one `subject_key` and one `property_key`. This lets `domain-contradictions` compare current requirements that constrain the same subject and require incompatible values.
142
+
143
+ ### Role set conflict
144
+
145
+ `REQ-ROLE-SET-2` and `REQ-ROLE-SET-3` are incoherent if both are current: they each define the exact allowed role set, but one allows two roles and the other allows three. Encode compact set values as canonical strings because the strict property schema supports string, int, number, and bool values.
146
+
147
+ ```yaml
148
+ subject:
149
+ id: FACT-USER-ROLES
150
+ title: User roles
151
+ status: active
152
+ fact_kind: subject
153
+ subject_key: user.roles
154
+
155
+ property_values:
156
+ - id: FACT-USER-ROLES-ALLOWED-2
157
+ title: User and admin roles only
158
+ status: active
159
+ fact_kind: property_value
160
+ subject_key: user.roles
161
+ property_key: user.roles.allowed_set
162
+ operator: eq
163
+ value_type: string
164
+ value_string: user,admin
165
+ - id: FACT-USER-ROLES-ALLOWED-3
166
+ title: User, admin, and superadmin roles
167
+ status: active
168
+ fact_kind: property_value
169
+ subject_key: user.roles
170
+ property_key: user.roles.allowed_set
171
+ operator: eq
172
+ value_type: string
173
+ value_string: user,admin,superadmin
174
+
175
+ relationships:
176
+ - { type: constrains, from: REQ-ROLE-SET-2, to: FACT-USER-ROLES }
177
+ - { type: requires_property, from: REQ-ROLE-SET-2, to: FACT-USER-ROLES-ALLOWED-2 }
178
+ - { type: constrains, from: REQ-ROLE-SET-3, to: FACT-USER-ROLES }
179
+ - { type: requires_property, from: REQ-ROLE-SET-3, to: FACT-USER-ROLES-ALLOWED-3 }
180
+ ```
181
+
182
+ ### Permission actor conflict
183
+
184
+ `REQ-ADMIN-CAN-MANAGE-BILLING` and `REQ-ONLY-SUPERADMIN-MANAGES-BILLING` conflict when both define the exact allowed actor for the same permission.
185
+
186
+ ```yaml
187
+ subject:
188
+ id: FACT-BILLING-MANAGE
189
+ title: Billing management permission
190
+ status: active
191
+ fact_kind: subject
192
+ subject_key: billing.manage
193
+
194
+ property_values:
195
+ - id: FACT-BILLING-MANAGE-ACTOR-ADMIN
196
+ title: Admin can manage billing
197
+ status: active
198
+ fact_kind: property_value
199
+ subject_key: billing.manage
200
+ property_key: billing.manage.allowed_actor
201
+ operator: eq
202
+ value_type: string
203
+ value_string: admin
204
+ - id: FACT-BILLING-MANAGE-ACTOR-SUPERADMIN
205
+ title: Only superadmin can manage billing
206
+ status: active
207
+ fact_kind: property_value
208
+ subject_key: billing.manage
209
+ property_key: billing.manage.allowed_actor
210
+ operator: eq
211
+ value_type: string
212
+ value_string: superadmin
213
+ ```
214
+
215
+ When a contradiction is intentional evolution rather than a real conflict, link the replaced requirement to the replacement requirement with `supersedes`.
216
+
217
+ ## Context Lane (Non-Blocking)
218
+
219
+ ### fact_kind: observation
220
+ For bug records, incident notes, and observed behavior.
221
+ ```yaml
222
+ id: FACT-BUG-123
223
+ title: Login fails on Safari 17
224
+ status: active
225
+ fact_kind: observation
226
+ ```
227
+
228
+ ### fact_kind: meta
229
+ For governance notes, process commentary, and workaround documentation.
230
+ ```yaml
231
+ id: FACT-WORKAROUND-456
232
+ title: Temporary cache bypass for v2 migration
233
+ status: active
234
+ fact_kind: meta
235
+ ```
@@ -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` for backward-compatible ground claim manifests; `semantic_inventory` is the complete proposition ledger. A manifest is not proof until each key is linked to exactly one intended 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.
@@ -0,0 +1,44 @@
1
+ # Kibi Operation Access Catalog
2
+
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
+
5
+ | MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects | Interface |
6
+ |---|---|---|---|---|---|---|
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
+
26
+ ## JSON execution recipes
27
+
28
+ Use the project-local, non-installing runner from a trusted workspace. Stdin must contain exactly one UTF-8 JSON object.
29
+
30
+ ```bash
31
+ echo '{"query":"authentication","type":"req","limit":10}' | npx --no-install kibi search --input -
32
+ ```
33
+
34
+ ```bash
35
+ echo '{"type":"req","id":"REQ-001","properties":{"title":"Test","status":"open"}}' | npx --no-install kibi upsert --input -
36
+ ```
37
+
38
+ ```bash
39
+ echo '{"rules":["required-fields","no-dangling-refs"]}' | bunx --no-install kibi check --input -
40
+ ```
41
+
42
+ ## Telemetry handling
43
+
44
+ `_diagnostic_telemetry` is adapter metadata, not business input. In CLI JSON mode the adapter may validate and extract it for CLI usage logging before shared execution. In MCP diagnostic mode the adapter enforces its configured telemetry requirement and strips the field before shared execution. Never copy telemetry into entity properties or operation business input.
@@ -0,0 +1,119 @@
1
+ # Relationship Directions
2
+
3
+ ## Direction Table
4
+
5
+ | Relationship | Source -> Target | Semantic Meaning |
6
+ |-------------|------------------|------------------|
7
+ | `implements` | symbol -> req | Production code symbol owns or implements requirement behavior |
8
+ | `specified_by` | req -> scenario | Requirement is specified by a BDD scenario |
9
+ | `verified_by` | req/scenario -> test | Requirement or scenario is verified by a test case |
10
+ | `validates` | test -> req/scenario | Test validates a requirement or scenario (inverse of verified_by) |
11
+ | `executable_for` | symbol -> test | Test symbol (code) is executable code for a test entity |
12
+ | `constrains` | req -> fact(subject) | Requirement constrains a strict-lane domain fact |
13
+ | `requires_property` | req -> fact(property_value) | Requirement requires a specific property value fact |
14
+ | `supersedes` | old-req -> new-req | Old requirement is formally replaced by a new requirement |
15
+ | `covered_by` | symbol -> test | Production symbol has test coverage evidence |
16
+
17
+ ## Valid Payload Examples
18
+
19
+ ### implements
20
+ ```yaml
21
+ relationships:
22
+ - type: implements
23
+ from: SYM-001
24
+ to: REQ-001
25
+ ```
26
+
27
+ ### specified_by
28
+ ```yaml
29
+ relationships:
30
+ - type: specified_by
31
+ from: REQ-001
32
+ to: SCEN-001
33
+ ```
34
+
35
+ ### verified_by
36
+ ```yaml
37
+ relationships:
38
+ - type: verified_by
39
+ from: REQ-001
40
+ to: TEST-001
41
+ ```
42
+
43
+ ### validates
44
+ ```yaml
45
+ relationships:
46
+ - type: validates
47
+ from: TEST-001
48
+ to: SCEN-001
49
+ ```
50
+
51
+ ### executable_for
52
+ ```yaml
53
+ relationships:
54
+ - type: executable_for
55
+ from: SYM-test-login
56
+ to: TEST-001
57
+ ```
58
+
59
+ ### constrains
60
+ ```yaml
61
+ relationships:
62
+ - type: constrains
63
+ from: REQ-019
64
+ to: FACT-USER-ROLE
65
+ ```
66
+
67
+ ### requires_property
68
+ ```yaml
69
+ relationships:
70
+ - type: requires_property
71
+ from: REQ-019
72
+ to: FACT-LIMIT-3
73
+ ```
74
+
75
+ ### supersedes
76
+ ```yaml
77
+ relationships:
78
+ - type: supersedes
79
+ from: REQ-001
80
+ to: REQ-001-v2
81
+ ```
82
+
83
+ ### covered_by
84
+ ```yaml
85
+ relationships:
86
+ - type: covered_by
87
+ from: SYM-handler
88
+ to: TEST-005
89
+ ```
90
+
91
+ ## Invalid Test-Fact Shortcuts
92
+
93
+ Do not model small behavior fixes as direct test-fact pairs. Facts describe invariants; requirements or scenarios are verified by tests.
94
+
95
+ ```yaml
96
+ # WRONG: fact -> test is not a valid verified_by shape
97
+ relationships:
98
+ - type: verified_by
99
+ from: FACT-HEADER-AVATAR-INITIAL-UPPERCASE
100
+ to: TEST-AVATAR-HEADER-FALLBACK
101
+
102
+ # WRONG: test -> fact is not a valid validates shape
103
+ relationships:
104
+ - type: validates
105
+ from: TEST-AVATAR-HEADER-FALLBACK
106
+ to: FACT-HEADER-AVATAR-INITIAL-UPPERCASE
107
+ ```
108
+
109
+ Use a requirement as the verification target/source, then link that requirement to strict facts:
110
+
111
+ ```yaml
112
+ relationships:
113
+ - type: verified_by
114
+ from: REQ-HEADER-AVATAR-INITIAL-UPPERCASE
115
+ to: TEST-AVATAR-HEADER-FALLBACK
116
+ - type: requires_property
117
+ from: REQ-HEADER-AVATAR-INITIAL-UPPERCASE
118
+ to: FACT-HEADER-AVATAR-INITIAL-UPPERCASE
119
+ ```
@@ -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.
@@ -0,0 +1,80 @@
1
+ # Workflows
2
+
3
+ ## Discovery to Validation Sequence
4
+
5
+ The canonical workflow for any KB operation follows this pattern:
6
+
7
+ 1. **Discover**: `kb_search` with focused probes
8
+ 2. **Confirm**: `kb_query` for exact IDs and state
9
+ 3. **Inspect**: `kb_status` when freshness matters
10
+ 4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
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
+ 6. **Preflight**: `kb_validate_upsert` for every intended entity or relationship payload
13
+ 7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
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
+
17
+ 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
+
19
+ ## Creating a New Feature
20
+ ```
21
+ 1. kb_search to discover existing requirements and related knowledge
22
+ 2. kb_query to confirm exact IDs and source-linked context
23
+ 3. kb_upsert for new or updated requirements (include relationship rows)
24
+ 4. kb_check with targeted rules
25
+ ```
26
+
27
+ ## Small Behavior Fix With No Existing Requirement
28
+ ```
29
+ 1. kb_search and kb_query by the changed source file and test file.
30
+ 2. If no requirement exists, create a REQ for the corrected behavior.
31
+ 3. Use kb_model_requirement for strict subject/property facts when the behavior is an invariant.
32
+ 4. Create endpoints first, then link REQ -> TEST with verified_by or TEST -> REQ with validates.
33
+ 5. Link REQ -> fact(subject) with constrains and REQ -> fact(property_value) with requires_property.
34
+ 6. Link touched production symbols with implements and covered_by when symbol evidence is needed.
35
+ 7. Author and stage tracked markdown/symbol evidence; MCP writes do not stage those files automatically.
36
+ 8. Run kb_check with targeted rules, then a final full check.
37
+ ```
38
+
39
+ Do not create a test-fact pair. Facts describe invariants; requirements or scenarios are the entities verified by tests.
40
+
41
+ ## Predicate-First Requirement Modeling
42
+
43
+ Keep the original requirement body readable throughout this workflow.
44
+
45
+ 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. Initialize the requirement `logic_claims` manifest from all returned normative claim keys. Preserve existing keys on updates.
47
+ 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 suitable, 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
+ 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. 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
+ 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.
52
+ 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`.
53
+
54
+ 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.
55
+
56
+ Examples: built-in permission and deny claims use the suggested `permission_rule`; a project-local `commit_action` is valid only after its schema exists; session timeout is strict scalar; “better support” is ambiguous; `publishes_event` for publishing an article is a false positive; annotation anchoring without a fitting schema is an ontology gap. The authoritative payloads are in `resources/fact-lanes.md`.
57
+
58
+ On resume after interruption, repeat `kb_query` for exact endpoints and apply only missing validated writes. Keep `kb_upsert` concurrency at one.
59
+
60
+ ## UI / Visual Requirement Modeling
61
+
62
+ Optional per-project workflow for recording what the screen should look like. Non-UI projects skip this lane entirely.
63
+
64
+ 1. Create a prose `req` holding the full visual description; it is the searchable anchor agents discover before touching a UI file.
65
+ 2. Run `kb_semantic_advisor` on the description; audit or supply `clauses`.
66
+ 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`.
67
+ 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.
68
+ 5. Preserve `claim_key` / `claim_text` on every ground fact and merge every key into the requirement `logic_claims` manifest.
69
+ 6. Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement.
70
+ 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`.
71
+
72
+ 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`.
73
+
74
+ ## Fixing a Traceability Gap
75
+ ```
76
+ 1. kb_query --sourceFile <code-file> to find linked entities
77
+ 2. kb_find_gaps --type req --missing-rel specified_by to find orphan requirements
78
+ 3. kb_upsert to add missing relationship rows (sequential)
79
+ 4. kb_check with rules: ["no-dangling-refs", "symbol-traceability"]
80
+ ```
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kibi-cursor",
3
3
  "displayName": "Kibi",
4
- "version": "0.5.0",
4
+ "version": "0.5.1",
5
5
  "description": "Optional Cursor adapter for Kibi. Requires SWI-Prolog 9+ and project-local kibi-cli, kibi-mcp, and kibi-core before the bundled MCP server can start.",
6
6
  "license": "AGPL-3.0-or-later",
7
7
  "author": {
@@ -1,7 +1,7 @@
1
1
  import type { HookState } from "./hook-state.js";
2
2
  import { type McpState } from "./kb-mcp-tools.js";
3
- export declare const BOOTSTRAP_REMINDER = "Kibi config was not found at the Cursor workspace root. Use visible Kibi MCP tools, or a trusted project-local CLI JSON route with --input when MCP is unavailable, to bootstrap project memory; if neither interface is available, tell the operator. Do not read or edit `.kb/` files directly. Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
4
- export declare const DIRECT_KB_EDIT_WARNING = "Do not read or edit `.kb/` files directly. Use visible Kibi MCP tools, or trusted project-local CLI JSON routes with --input when MCP is unavailable. Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
3
+ export declare const BOOTSTRAP_REMINDER = "Kibi config was not found at the Cursor workspace root. Use visible Kibi MCP tools or a trusted project-local CLI JSON route with --input (peer surfaces) to bootstrap project memory; if neither interface is available, tell the operator. Do not read or edit `.kb/` files directly. Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
4
+ export declare const DIRECT_KB_EDIT_WARNING = "Do not read or edit `.kb/` files directly. Use visible Kibi MCP tools or trusted project-local CLI JSON routes with --input (peer surfaces). Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
5
5
  export declare function interfaceAdvisory(mcpState: McpState, workspaceTrusted: boolean): string | undefined;
6
6
  export declare function stopFollowupMessage(state: HookState): string | undefined;
7
7
  /** @deprecated Use stopFollowupMessage */
package/dist/messages.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { resolveKibiInterface } from "./kb-mcp-tools.js";
2
2
  import { isKbFreshnessRelevantPath, isSourceImpactRelevantPath, } from "./path-policy.js";
3
- export const BOOTSTRAP_REMINDER = "Kibi config was not found at the Cursor workspace root. Use visible Kibi MCP tools, or a trusted project-local CLI JSON route with --input when MCP is unavailable, to bootstrap project memory; if neither interface is available, tell the operator. Do not read or edit `.kb/` files directly. Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
4
- export const DIRECT_KB_EDIT_WARNING = "Do not read or edit `.kb/` files directly. Use visible Kibi MCP tools, or trusted project-local CLI JSON routes with --input when MCP is unavailable. Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
3
+ export const BOOTSTRAP_REMINDER = "Kibi config was not found at the Cursor workspace root. Use visible Kibi MCP tools or a trusted project-local CLI JSON route with --input (peer surfaces) to bootstrap project memory; if neither interface is available, tell the operator. Do not read or edit `.kb/` files directly. Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
4
+ export const DIRECT_KB_EDIT_WARNING = "Do not read or edit `.kb/` files directly. Use visible Kibi MCP tools or trusted project-local CLI JSON routes with --input (peer surfaces). Query before mutate, run kb_upsert sequentially, and run kb_check before completion.";
5
5
  export function interfaceAdvisory(mcpState, workspaceTrusted) {
6
6
  const selectedInterface = resolveKibiInterface(mcpState, workspaceTrusted);
7
7
  switch (selectedInterface) {