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.
Files changed (35) hide show
  1. package/.cursor-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +85 -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 +60 -0
  9. package/agent-plugin/skills/kibi-usage/SKILL.md +276 -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 +97 -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 +7 -5
  20. package/dist/skills/kibi-traceability/SKILL.md +7 -1
  21. package/dist/skills/kibi-usage/SKILL.md +44 -12
  22. package/dist/skills/kibi-usage/resources/fact-lanes.md +12 -2
  23. package/dist/skills/kibi-usage/resources/logic-ir.md +43 -0
  24. package/dist/skills/kibi-usage/resources/operation-access.md +19 -19
  25. package/dist/skills/kibi-usage/resources/ui-requirements.md +96 -0
  26. package/dist/skills/kibi-usage/resources/workflows.md +40 -8
  27. package/package.json +3 -2
  28. package/skills/.canon-hash.json +7 -5
  29. package/skills/kibi-traceability/SKILL.md +7 -1
  30. package/skills/kibi-usage/SKILL.md +44 -12
  31. package/skills/kibi-usage/resources/fact-lanes.md +12 -2
  32. package/skills/kibi-usage/resources/logic-ir.md +43 -0
  33. package/skills/kibi-usage/resources/operation-access.md +19 -19
  34. package/skills/kibi-usage/resources/ui-requirements.md +96 -0
  35. package/skills/kibi-usage/resources/workflows.md +40 -8
@@ -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,97 @@
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
+ 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
19
+
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`.
25
+
26
+ ## Creating a New Feature
27
+ ```
28
+ 1. kb_search to discover existing requirements and related knowledge
29
+ 2. kb_query to confirm exact IDs and source-linked context
30
+ 3. kb_upsert for new or updated requirements (include relationship rows)
31
+ 4. kb_check with targeted rules
32
+ ```
33
+
34
+ ## Small Behavior Fix With No Existing Requirement
35
+ ```
36
+ 1. kb_search and kb_query by the changed source file and test file.
37
+ 2. If no requirement exists, create a REQ for the corrected behavior.
38
+ 3. Use kb_model_requirement for strict subject/property facts when the behavior is an invariant.
39
+ 4. Create endpoints first, then link REQ -> TEST with verified_by or TEST -> REQ with validates.
40
+ 5. Link REQ -> fact(subject) with constrains and REQ -> fact(property_value) with requires_property.
41
+ 6. Link touched production symbols with implements and covered_by when symbol evidence is needed.
42
+ 7. Author and stage tracked markdown/symbol evidence; MCP writes do not stage those files automatically.
43
+ 8. Run kb_check with targeted rules, then a final full check.
44
+ ```
45
+
46
+ Do not create a test-fact pair. Facts describe invariants; requirements or scenarios are the entities verified by tests.
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
+
58
+ ## Predicate-First Requirement Modeling
59
+
60
+ Keep the original requirement body readable throughout this workflow.
61
+
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.
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.
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.
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`.
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.
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`.
70
+
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.
72
+
73
+ 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`.
74
+
75
+ On resume after interruption, repeat `kb_query` for exact endpoints and apply only missing validated writes. Keep `kb_upsert` concurrency at one.
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
+
91
+ ## Fixing a Traceability Gap
92
+ ```
93
+ 1. kb_query --sourceFile <code-file> to find linked entities
94
+ 2. kb_find_gaps --type req --missing-rel specified_by to find orphan requirements
95
+ 3. kb_upsert to add missing relationship rows (sequential)
96
+ 4. kb_check with rules: ["no-dangling-refs", "symbol-traceability"]
97
+ ```
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kibi-cursor",
3
3
  "displayName": "Kibi",
4
- "version": "0.5.0",
4
+ "version": "0.6.0",
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) {
@@ -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": "a621553397c1f8813f05fd9552fc30a5e8ed118442e019add35804de7d43a0b1",
5
- "kibi-usage/SKILL.md": "f4a713d8c95d9c9a254e2f23b27013293f0caacb4009409409e56c7deeccc8a5",
6
- "kibi-usage/resources/fact-lanes.md": "8b2f835775e57427db980c5412d6e58840a53e71e8e508ae39f14ebfa693e4b8",
7
- "kibi-usage/resources/operation-access.md": "d8653b544305d4c00734c737b1156110208a9a82fbec6b04726d25b973f2b840",
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/workflows.md": "36e50fe83fc7ac6bc68fcf51d2c2175e09c68815b6bbebed8cfa1d5611617913"
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.2.0
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
- Use this order for every Kibi operation:
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 complete set of keys in the requirement's `logic_claims` manifest. Merge returned keys with existing values; never overwrite earlier claims while modeling a later clause.
136
- 4. Ground each key through exactly one suitable logical lane: `requires_property` to one strict `property_value` fact, or `requires_predicate` to one ground `predicate` 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.
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. Semantic-advisor readiness remains partial until the payload has at least one distinct `requires_property` or `requires_predicate` grounding slot per normative claim. This count prevents one token edge from suppressing the remaining plans; only `logic-coverage` readback proves that each slot reaches the fact with the matching claim key.
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
- | Replacing `logic_claims` on each call | Discards previously grounded clauses | Pass existing keys and merge the returned manifest |
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 requirement `logic_claims` manifest without removing existing keys;
11
- - link it through exactly one `requires_property` for `property_value` or one `requires_predicate` for `predicate`;
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`.