kibi-runtime 1.0.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 (44) hide show
  1. package/dist/engine-daemon.js +2402 -0
  2. package/dist/engine.d.ts +65 -0
  3. package/dist/engine.js +1 -0
  4. package/dist/index.d.ts +49 -0
  5. package/dist/index.js +279965 -0
  6. package/dist/skill-operations.d.ts +69 -0
  7. package/dist/skill-operations.js +105 -0
  8. package/dist/skill-system/errors.d.ts +18 -0
  9. package/dist/skill-system/errors.js +36 -0
  10. package/dist/skill-system/loader.d.ts +8 -0
  11. package/dist/skill-system/loader.js +81 -0
  12. package/dist/skill-system/paths.d.ts +5 -0
  13. package/dist/skill-system/paths.js +25 -0
  14. package/dist/skill-system/types.d.ts +14 -0
  15. package/dist/skill-system/types.js +1 -0
  16. package/dist/skill-system/validation.d.ts +9 -0
  17. package/dist/skill-system/validation.js +119 -0
  18. package/dist/skills/kibi-bootstrap/SKILL.md +58 -0
  19. package/dist/skills/kibi-bootstrap/resources/bootstrap.md +11 -0
  20. package/dist/skills/kibi-bootstrap/resources/branch-lifecycle.md +7 -0
  21. package/dist/skills/kibi-bootstrap/resources/operation-access.md +5 -0
  22. package/dist/skills/kibi-bootstrap/resources/source-authoring.md +8 -0
  23. package/dist/skills/kibi-freshness/SKILL.md +74 -0
  24. package/dist/skills/kibi-freshness/resources/branch-lifecycle.md +7 -0
  25. package/dist/skills/kibi-freshness/resources/operation-access.md +6 -0
  26. package/dist/skills/kibi-freshness/resources/source-authoring.md +7 -0
  27. package/dist/skills/kibi-traceability/SKILL.md +60 -0
  28. package/dist/skills/kibi-traceability/resources/branch-lifecycle.md +7 -0
  29. package/dist/skills/kibi-traceability/resources/operation-access.md +5 -0
  30. package/dist/skills/kibi-traceability/resources/source-authoring.md +6 -0
  31. package/dist/skills/kibi-traceability/resources/traceability.md +8 -0
  32. package/dist/skills/kibi-usage/SKILL.md +152 -0
  33. package/dist/skills/kibi-usage/resources/branch-lifecycle.md +31 -0
  34. package/dist/skills/kibi-usage/resources/fact-lanes.md +235 -0
  35. package/dist/skills/kibi-usage/resources/kb-improvement.md +38 -0
  36. package/dist/skills/kibi-usage/resources/logic-ir.md +43 -0
  37. package/dist/skills/kibi-usage/resources/operation-access.md +42 -0
  38. package/dist/skills/kibi-usage/resources/relationship-directions.md +119 -0
  39. package/dist/skills/kibi-usage/resources/source-authoring.md +31 -0
  40. package/dist/skills/kibi-usage/resources/ui-requirements.md +96 -0
  41. package/dist/skills/kibi-usage/resources/workflows.md +150 -0
  42. package/dist/skills.d.ts +3 -0
  43. package/dist/skills.js +2 -0
  44. package/package.json +37 -0
@@ -0,0 +1,43 @@
1
+ # Typed Logic IR and Proposition Coverage
2
+
3
+ Kibi stores human prose as readable requirement text, but verifiable meaning belongs in typed facts and `kibi.logic.v1` rule facts. The host agent may propose an interpretation; Kibi validates, canonicalizes, hashes, persists, and reasons over it. Never submit a Prolog source string, goal, module, or function symbol. Rendered Prolog is an inspection preview only.
4
+
5
+ ## Two-pass extraction
6
+
7
+ 1. Run `kb_semantic_advisor` over the complete text. Supply explicit `clauses` when sentence splitting could hide a condition, exception, definition, descriptive assertion, threshold, quantity, or temporal qualifier.
8
+ 2. Audit the returned `propositions` against the original UTF-8 text. Every assertive span must be `modeled`, `ambiguous`, `ontology_gap`, or `missing`; rationale, examples, and subjective commentary are `nonlogical` and remain readable prose.
9
+ 3. For each assertive proposition, submit up to three typed `interpretations` when alternatives are plausible. Kibi compares canonical semantic keys; materially different valid interpretations remain unresolved regardless of confidence.
10
+ 4. Apply only a validated plan, then read back the requirement, rule schema, rule fact, and all relationship targets. Run `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, and `domain-contradictions` before the final unfiltered check.
11
+
12
+ When a project-local schema names several ordered arguments, those arguments are facets of one relation, not separate propositions. Preserve the advisor claim key for the complete relation and do not manufacture clauses for each argument. Supporting `predicate_schema` facts carry the declared signature only; the ground predicate fact carries the claim provenance. Apply the exact `kb_suggest_predicates`/`kb_model_requirement` plan, reducing a rejected schema payload through `kb_validate_upsert` rather than silently downgrading a fitting declared relation to an observation.
13
+
14
+ ## Logic IR shape
15
+
16
+ The supported v1 forms are:
17
+
18
+ - `kind: atom` with a ground `head`;
19
+ - `kind: rule` with a range-restricted `head` and `body`;
20
+ - `kind: constraint` with a body and no head.
21
+
22
+ Terms are typed `const`, `var`, `number`, `duration`, or ISO `timestamp`. Variables are explicitly declared as `forall` (the default) or body-local `exists`; an existential variable may not occur in a rule head. Bodies use `all`, `any`, closed-world `not`, comparisons, bounded `count`, and bounded temporal expressions. Modalities are `assert`, `deny`, `oblige`, `permit`, and `forbid`.
23
+
24
+ Every head and body variable must be bound by a positive atom. Negation is allowed only on an atom with `closedWorld: true`, and only when its variables are also positively bound. Function symbols, raw goals, cuts, meta-calls, dynamic predicates, I/O, unbounded aggregation, unsafe variables, and unstratified negation are rejected before persistence.
25
+
26
+ Example (inspection data, not executable input):
27
+
28
+ ```json
29
+ {
30
+ "version": "kibi.logic.v1",
31
+ "kind": "rule",
32
+ "modality": "oblige",
33
+ "variables": [{"name": "U", "type": "user", "quantifier": "forall"}],
34
+ "head": {"kind": "atom", "name": "audit", "args": [{"kind": "var", "name": "U", "type": "user"}]},
35
+ "body": {"kind": "atom", "name": "admin_action", "args": [{"kind": "var", "name": "U", "type": "user"}]}
36
+ }
37
+ ```
38
+
39
+ Use `rule_schema` facts for stable predicate signatures and link a requirement to a `rule` fact with `requires_rule`. Keep `logic_claims` as the exact current assertive key set; `semantic_inventory` is the complete proposition ledger, anchored by `semantic_inventory_version`, `semantic_source_field`, and `semantic_source_hash`. Prefer requirement-only `semantic_text` as the semantic source for normalized authored prose so `text_ref` can remain independent code or document evidence; retain `text_ref` and `title` only as legacy semantic-source choices. A manifest is not proof until each modeled key is linked to exactly one same-key fact and the rule checks pass.
40
+
41
+ ## Contradictions and uncertainty
42
+
43
+ Kibi compares opposing modalities over matching heads and overlapping authority, scope, and validity intervals. `assert`/`deny`, `oblige`/`forbid`, and overlapping `permit`/`forbid` pairs can be contradictory. Different conditions, unresolved interpretations, unsupported ontology terms, analysis limits, and incomplete closure produce `unresolved`, never a false consistency proof. Preserve superseding requirements rather than deleting historical claims.
@@ -0,0 +1,42 @@
1
+ # Kibi Operation Access Catalog
2
+
3
+ Generated from the public `OperationSpec` catalog. CLI JSON and MCP structured
4
+ content use the same `KibiResult` envelope (protocol 1); result data is versioned
5
+ per operation. Effects are authoritative for mutability and adapter annotations.
6
+
7
+ | MCP tool name | CLI route | Input mode | Mutability | Requires Prolog | Effects | Interface | Result version | Destructive | Retry safety | Open-world | Output schema |
8
+ |---|---|---|---|---|---|---|---|---|---|---|---|
9
+ | `kb_skills_list` | `skills-list` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills_list.v1 | no | safe | no | yes |
10
+ | `kb_skills_load` | `skills-load` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills_load.v1 | no | safe | no | yes |
11
+ | `kb_skills_read` | `skills-read` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_skills_read.v1 | no | safe | no | yes |
12
+ | `kb_query` | `query` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_query.v1 | no | safe | no | yes |
13
+ | `kb_search` | `search` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_search.v1 | no | safe | no | yes |
14
+ | `kb_status` | `status` | --input JSON or flags | read | no | kb-read, workspace-read | peer; capability-selected | kibi.kb_status.v1 | no | safe | no | yes |
15
+ | `kb_find_gaps` | `find-gaps` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_find_gaps.v1 | no | safe | no | yes |
16
+ | `kb_coverage` | `coverage` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_coverage.v1 | no | safe | no | yes |
17
+ | `kb_graph` | `graph` | --input JSON or flags | read | yes | kb-read | peer; capability-selected | kibi.kb_graph.v1 | no | safe | no | yes |
18
+ | `kb_semantic_advisor` | `semantic-advisor` | --input JSON | read | no | local-read | peer; capability-selected | kibi.kb_semantic_advisor.v1 | no | safe | no | yes |
19
+ | `kb_model_requirement` | `model-requirement` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_model_requirement.v1 | no | safe | no | yes |
20
+ | `kb_suggest_predicates` | `suggest-predicates` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_suggest_predicates.v1 | no | safe | no | yes |
21
+ | `kb_plan_bootstrap` | `plan-bootstrap` | --input JSON | read | no | workspace-read | peer; capability-selected | kibi.kb_plan_bootstrap.v1 | no | safe | no | yes |
22
+ | `kb_validate_upsert` | `validate-upsert` | --input JSON | read | yes | kb-read | peer; capability-selected | kibi.kb_validate_upsert.v1 | no | safe | no | yes |
23
+ | `kb_upsert` | `upsert` | --input JSON | write | yes | kb-write, workspace-write | peer; capability-selected | kibi.kb_upsert.v1 | yes | unsafe | no | yes |
24
+ | `kb_delete` | `delete` | --input JSON | write | yes | kb-write, workspace-write | peer; capability-selected | kibi.kb_delete.v1 | yes | unsafe | no | yes |
25
+ | `kb_check` | `check` | --input JSON or flags | read | yes | kb-read, workspace-read | peer; capability-selected | kibi.kb_check.v1 | no | safe | no | yes |
26
+ | `kb_sparql_remote` | `sparql-remote` | --input JSON | read | no | network-read | peer; capability-selected | kibi.kb_sparql_remote.v1 | no | safe | yes | yes |
27
+ | `kb_compile_intent` | `compile-intent` | --input JSON | read | yes | kb-read, workspace-read | peer; capability-selected | kibi.kb_compile_intent.v1 | no | safe | no | yes |
28
+ | `kb_apply_plan` | `apply-plan` | --input JSON | write | yes | kb-read, kb-write, workspace-read, workspace-write | peer; capability-selected | kibi.kb_apply_plan.v1 | yes | unsafe | no | yes |
29
+ | `kb_ingest_verification` | `ingest-verification` | --input JSON | write | yes | kb-read, kb-write, workspace-read | peer; capability-selected | kibi.kb_ingest_verification.v1 | yes | unsafe | no | yes |
30
+
31
+ ## JSON execution recipe
32
+
33
+ Use a trusted project-local, non-installing runner. Stdin contains one UTF-8 JSON
34
+ object and stdout contains the versioned result envelope:
35
+
36
+ ```bash
37
+ printf '%s\n' '{"query":"authentication","limit":10}' | npx --no-install kibi search --input -
38
+ ```
39
+
40
+ `_diagnostic_telemetry` is adapter metadata, not business input. Never copy it
41
+ into entity properties. On `committed_with_repairs`, follow typed required
42
+ `nextActions` and do not retry the original mutation.
@@ -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` | new-req -> old-req | New requirement formally replaces an old 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-v2
80
+ to: REQ-001
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,31 @@
1
+ # Source-first authoring
2
+
3
+ Tracked Markdown, YAML, symbol manifests, and relationship shards are the
4
+ authoritative project memory. Prolog/RDF state is a rebuildable compiled
5
+ artifact. Kibi may transactionally write tracked files, but it never stages or
6
+ commits them; ordinary Git workflows remain responsible for review and merge.
7
+
8
+ `kb_upsert` accepts `document.path` and `document.body`. Existing entities use
9
+ their authored source by default and preserve body bytes when `body` is omitted.
10
+ New requirements use `semantic_text` as their body. If a new entity has zero or
11
+ multiple configured writable targets, provide an explicit workspace-relative
12
+ `document.path`; absolute, traversal, and symlink escapes are rejected.
13
+
14
+ New files are compiled only while their exact bytes are covered by a pending-
15
+ source receipt. Sync compiles Git-tracked files plus those hash-bound pending
16
+ files; arbitrary untracked files are ignored. Stage the file in Git to absorb
17
+ and remove its receipt. A changed or missing pending file is a blocking hash
18
+ drift diagnostic. Unresolved Git index conflicts are likewise blocking; Kibi
19
+ never chooses a merge winner.
20
+
21
+ Relationship upserts and relationship deletes patch only the canonical shard,
22
+ preserving unrelated records. Authored entity deletion returns a hash-bound
23
+ plan; approve that plan through `kb_apply_plan`. Evolve requirements with a new
24
+ requirement and `supersedes`, rather than deleting the old semantic claim.
25
+
26
+ On `committed_with_repairs`, inspect `effects` and execute the typed required
27
+ `nextActions`. Never retry the original mutation after its authoritative commit.
28
+ Cancellation follows the same rule: wait for the terminal journal state. A
29
+ pre-commit rollback is retryable, a committed source with a failed derivative
30
+ is repairable, and an indeterminate outcome is non-retryable until its recovery
31
+ action resolves the journal.
@@ -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,150 @@
1
+ # Workflows
2
+
3
+ ## Closeout contract
4
+
5
+ End every task with these five independent fields (not a single inferred
6
+ success flag):
7
+
8
+ ```text
9
+ taskOutcome: complete | interim | blocked
10
+ kbState: clean_fresh | stale | dirty | legacy_compat | not_evaluated
11
+ verificationState: fresh | dirty | unavailable | not_evaluated
12
+ proofState: proven | mixed | unresolved | not_evaluated
13
+ limitationDisposition: none | accepted | unaccepted | not_applicable
14
+ ```
15
+
16
+ `taskOutcome` describes whether the requested objective was completed. The
17
+ other fields describe observed system state. A clean check can coexist with a
18
+ stale or dirty KB; unresolved proof can coexist with a complete maintenance
19
+ task. An accepted limitation is an auditable operator decision, never logical
20
+ grounding, receipt editing, or proof. For every quality diagnostic, record its
21
+ ID, one of `fixed`, `accepted`, or `deferred`, and a rationale. Keep accepted
22
+ ontology gaps and historical telemetry limitations explicit.
23
+
24
+ Receipt reuse is safe only when the live verification snapshot, contract hash,
25
+ freshness window, and every required case result still match. Otherwise rerun
26
+ the contracted command. If the contract changed, retain every older receipt
27
+ unchanged, append evidence for the current contract, and keep proof unresolved
28
+ with `verification_contract_mismatch` until that current receipt exists.
29
+ Obsolete symbols require current extraction or Git evidence before
30
+ remap/deletion; transfer coverage only when existing test evidence supports it,
31
+ then sync and read back status. Same-version packages with different export
32
+ surfaces are a release defect: require a new package version and label any
33
+ project override temporary. This skill never selects a package manager or
34
+ edits dependency configuration.
35
+
36
+ ## Discovery to Validation Sequence
37
+
38
+ The canonical workflow for any KB operation follows this pattern:
39
+
40
+ 1. **Discover**: `kb_search` with focused probes
41
+ 2. **Confirm**: `kb_query` for exact IDs and state
42
+ 3. **Inspect**: `kb_status` when freshness matters
43
+ 4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
44
+ 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
45
+ 6. **Preflight**: `kb_validate_upsert` for every intended entity or relationship payload
46
+ 7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
47
+ 8. **Link**: validated `kb_upsert` with `requires_rule`, `requires_predicate`, `constrains`, or `requires_property`, sequentially
48
+ 9. **Validate coverage and consistency**: targeted `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then final full `kb_check`
49
+ 10. **Prove execution**: read `kb_status.verificationSnapshot`, run each scenario-backed E2E command exactly as declared by its `verification_contract.v1` through `kibi verify`, append the derived `kibi.verification-receipt.v2`, and re-run `kb_coverage`; never promote durable test status into fresh evidence
50
+ 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
51
+ 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
52
+
53
+ 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.
54
+
55
+ `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.
56
+
57
+ `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`.
58
+
59
+ ## Agent-guided migration
60
+
61
+ `kb_status`, unfiltered `kb_check`, and complete-scope `kb_coverage` may return
62
+ the shared `kibi.migration-plan.v2`. Treat it as a typed action graph: inspect
63
+ the canonical `planHash`, scope completeness, dependencies, safety class,
64
+ preconditions, postconditions, and evidence. Apply only ready automatic actions
65
+ with `autoApplicable: true` through an explicitly approved `kb_apply_plan` or
66
+ `kibi migrate --apply-safe` request containing the exact hash and action IDs.
67
+ Never infer an operation from a prose suggestion, and never apply a partial
68
+ plan's destructive symbol or relationship action.
69
+
70
+ The migration engine may normalize schema/config metadata, cut over validated
71
+ legacy storage with backups, migrate the exact historical branch attachment,
72
+ refresh coordinates, and perform provenance-proven stale cleanup. It does not
73
+ choose package managers, ground semantic claims, resolve contradictions, rerun
74
+ E2E tests, rewrite receipt history, remap authored symbols, or accept
75
+ limitations. Those actions remain explicit review/operator/execution steps.
76
+
77
+ For `e2e_receipt_freshness_low`, query each listed requirement/test gap and run its exact current contract through `kibi verify`; this appends v2 evidence and preserves older history. If `coverage_depth_review` conflicts with a coverage row whose `proofStages.passingE2e.status` is `passed`, report the diagnostic as a stale heuristic and keep any independent proof gaps unresolved.
78
+
79
+ ## Creating a New Feature
80
+ ```
81
+ 1. kb_search to discover existing requirements and related knowledge
82
+ 2. kb_query to confirm exact IDs and source-linked context
83
+ 3. kb_upsert for new or updated requirements (include relationship rows)
84
+ 4. kb_check with targeted rules
85
+ ```
86
+
87
+ ## Small Behavior Fix With No Existing Requirement
88
+ ```
89
+ 1. kb_search and kb_query by the changed source file and test file.
90
+ 2. If no requirement exists, create a REQ for the corrected behavior.
91
+ 3. Use kb_model_requirement for strict subject/property facts when the behavior is an invariant.
92
+ 4. Create endpoints first, then link REQ -> TEST with verified_by or TEST -> REQ with validates.
93
+ 5. Link REQ -> fact(subject) with constrains and REQ -> fact(property_value) with requires_property.
94
+ 6. Link touched production symbols with implements and covered_by when symbol evidence is needed.
95
+ 7. Author and stage tracked markdown/symbol evidence; MCP writes do not stage those files automatically.
96
+ 8. Run kb_check with targeted rules, then a final full check.
97
+ ```
98
+
99
+ Do not create a test-fact pair. Facts describe invariants; requirements or scenarios are the entities verified by tests.
100
+
101
+ ## Fresh E2E Receipt Workflow
102
+
103
+ 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.
104
+ 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.
105
+ 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.
106
+ 4. Preserve every existing receipt byte-for-byte and append the derived `kibi.verification-receipt.v2` object with strictly later `finished_at`. Earlier receipts may bind older contracts; they remain audit history but cannot prove the current contract. Mutation and incremental sync reject history removal, rewriting, and reordering.
107
+ 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.
108
+
109
+ Only the newest receipt matching both the live snapshot and current contract qualifies, and it must be passed, no more than seven days old, and no more than five minutes in the future. Wrong-snapshot and older-contract history is retained but cannot prove the current test. `missing_verification_receipt`, `stale_verification_receipt`, `failed_verification_receipt`, `invalid_verification_receipt`, `verification_contract_mismatch`, and `verification_snapshot_unavailable` are repair states, not warnings to waive.
110
+
111
+ ## Predicate-First Requirement Modeling
112
+
113
+ Keep the original requirement body readable throughout this workflow.
114
+
115
+ 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.
116
+ 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.
117
+ 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.
118
+ 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`.
119
+ 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.
120
+ 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.
121
+ 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.
122
+ 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`.
123
+
124
+ 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.
125
+
126
+ 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`.
127
+
128
+ On resume after interruption, repeat `kb_query` for exact endpoints and apply only missing validated writes. Keep `kb_upsert` concurrency at one.
129
+
130
+ ## UI / Visual Requirement Modeling
131
+
132
+ Optional per-project workflow for recording what the screen should look like. Non-UI projects skip this lane entirely.
133
+
134
+ 1. Create a prose `req` holding the full visual description; it is the searchable anchor agents discover before touching a UI file.
135
+ 2. Run `kb_semantic_advisor` on the description; audit or supply `clauses`.
136
+ 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`.
137
+ 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.
138
+ 5. Preserve `claim_key` / `claim_text` on every ground fact and merge every key into the requirement `logic_claims` manifest.
139
+ 6. Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement.
140
+ 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`.
141
+
142
+ 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`.
143
+
144
+ ## Fixing a Traceability Gap
145
+ ```
146
+ 1. kb_query --sourceFile <code-file> to find linked entities
147
+ 2. kb_find_gaps --type req --missing-rel specified_by to find orphan requirements
148
+ 3. kb_upsert to add missing relationship rows (sequential)
149
+ 4. kb_check with rules: ["no-dangling-refs", "symbol-traceability"]
150
+ ```
@@ -0,0 +1,3 @@
1
+ export { listBundledSkills, loadBundledSkill, loadBundledSkillFrom, readBundledSkillResource, readBundledSkillResourceFrom, resetBundledSkillsDir, setBundledSkillsDir, } from "./skill-system/loader.js";
2
+ export { validateSkillBundle } from "./skill-system/validation.js";
3
+ export type { SkillBundle, SkillManifest } from "./skill-system/types.js";
package/dist/skills.js ADDED
@@ -0,0 +1,2 @@
1
+ export { listBundledSkills, loadBundledSkill, loadBundledSkillFrom, readBundledSkillResource, readBundledSkillResourceFrom, resetBundledSkillsDir, setBundledSkillsDir, } from "./skill-system/loader.js";
2
+ export { validateSkillBundle } from "./skill-system/validation.js";
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "kibi-runtime",
3
+ "version": "1.0.1",
4
+ "description": "Narrow first-party runtime contracts and adapters for Kibi operations.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json && bun build src/index.ts --outfile dist/index.js --target node --format esm --packages bundle --external kibi-core && bun build ../cli/src/engine-daemon.ts --outfile dist/engine-daemon.js --target node --format esm --packages bundle --external kibi-core && rm -rf dist/skills && mkdir -p dist/skills && cp -r src/skills/. dist/skills/",
19
+ "typecheck": "tsc -p tsconfig.json --noEmit"
20
+ },
21
+ "dependencies": {
22
+ "gray-matter": "^4.0.3",
23
+ "kibi-core": "^0.11.0"
24
+ },
25
+ "devDependencies": {
26
+ "kibi-cli": "workspace:*"
27
+ },
28
+ "engines": {
29
+ "node": ">=22"
30
+ },
31
+ "license": "AGPL-3.0-or-later",
32
+ "author": "Piotr Franczyk",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/Looted/kibi.git"
36
+ }
37
+ }