kibi-cli 2.32.0 → 2.35.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 (164) hide show
  1. package/dist/cli.d.ts.map +1 -1
  2. package/dist/cli.js +5 -1
  3. package/dist/commands/check-generated.d.ts +5 -1
  4. package/dist/commands/check-generated.d.ts.map +1 -1
  5. package/dist/commands/check-generated.js +24 -35
  6. package/dist/commands/init-helpers.d.ts.map +1 -1
  7. package/dist/commands/init-helpers.js +8 -5
  8. package/dist/commands/migrate.d.ts.map +1 -1
  9. package/dist/commands/migrate.js +23 -5
  10. package/dist/commands/sync/manifest.d.ts +10 -1
  11. package/dist/commands/sync/manifest.d.ts.map +1 -1
  12. package/dist/commands/sync/manifest.js +87 -14
  13. package/dist/commands/sync.d.ts.map +1 -1
  14. package/dist/commands/sync.js +19 -0
  15. package/dist/extractors/markdown.d.ts +1 -1
  16. package/dist/extractors/markdown.d.ts.map +1 -1
  17. package/dist/extractors/symbol-coordinates.js +2 -2
  18. package/dist/extractors/symbols-coordinator.d.ts +2 -4
  19. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  20. package/dist/extractors/symbols-coordinator.js +1 -2
  21. package/dist/operations/migration/proof-contract-claims.d.ts +23 -10
  22. package/dist/operations/migration/proof-contract-claims.d.ts.map +1 -1
  23. package/dist/operations/migration/proof-contract-claims.js +35 -2
  24. package/dist/operations/migration/schema6.d.ts.map +1 -1
  25. package/dist/operations/migration/schema6.js +2 -4
  26. package/dist/operations/migration/symbol-coordinates-refresh.d.ts +3 -2
  27. package/dist/operations/migration/symbol-coordinates-refresh.d.ts.map +1 -1
  28. package/dist/operations/migration/symbol-coordinates-refresh.js +4 -3
  29. package/dist/operations/migration/untrack-symbol-coordinates.d.ts +23 -0
  30. package/dist/operations/migration/untrack-symbol-coordinates.d.ts.map +1 -0
  31. package/dist/operations/migration/untrack-symbol-coordinates.js +67 -0
  32. package/dist/operations/modeling/requirement-modeler.d.ts.map +1 -1
  33. package/dist/operations/modeling/requirement-modeler.js +48 -1
  34. package/dist/operations/modeling/requirement-types.d.ts +2 -1
  35. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  36. package/dist/operations/modeling/requirement-utils.d.ts +1 -1
  37. package/dist/operations/modeling/requirement-utils.d.ts.map +1 -1
  38. package/dist/operations/modeling/requirement-utils.js +8 -1
  39. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  40. package/dist/operations/mutation/source-authoring.js +39 -20
  41. package/dist/operations/proof/claim-bindings.d.ts +18 -0
  42. package/dist/operations/proof/claim-bindings.d.ts.map +1 -1
  43. package/dist/operations/proof/claim-bindings.js +157 -4
  44. package/dist/operations/proof/code-certificates.d.ts +34 -14
  45. package/dist/operations/proof/code-certificates.d.ts.map +1 -1
  46. package/dist/operations/proof/code-certificates.js +266 -157
  47. package/dist/operations/proof/code-models.d.ts +96 -0
  48. package/dist/operations/proof/code-models.d.ts.map +1 -0
  49. package/dist/operations/proof/code-models.js +601 -0
  50. package/dist/operations/proof/code-runner.d.ts +40 -0
  51. package/dist/operations/proof/code-runner.d.ts.map +1 -0
  52. package/dist/operations/proof/code-runner.js +164 -0
  53. package/dist/operations/proof/code-scope.d.ts +3 -0
  54. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  55. package/dist/operations/proof/code-scope.js +26 -2
  56. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  57. package/dist/operations/proof/ingest-proof.js +2 -1
  58. package/dist/operations/proof/regular-language.d.ts +89 -0
  59. package/dist/operations/proof/regular-language.d.ts.map +1 -0
  60. package/dist/operations/proof/regular-language.js +943 -0
  61. package/dist/operations/proof/source-code-readers.d.ts +12 -0
  62. package/dist/operations/proof/source-code-readers.d.ts.map +1 -0
  63. package/dist/operations/proof/source-code-readers.js +699 -0
  64. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  65. package/dist/operations/semantic-advisor/analyze-prose.js +2 -1
  66. package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -1
  67. package/dist/operations/semantic-advisor/strict-count-rules.js +8 -2
  68. package/dist/operations/semantic-advisor/strict-rules.d.ts +8 -0
  69. package/dist/operations/semantic-advisor/strict-rules.d.ts.map +1 -1
  70. package/dist/operations/semantic-advisor/strict-rules.js +231 -1
  71. package/dist/operations/semantic-advisor/types.d.ts +1 -1
  72. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  73. package/dist/prolog.d.ts.map +1 -1
  74. package/dist/prolog.js +13 -3
  75. package/dist/public/operations/catalog.d.ts +156 -13
  76. package/dist/public/operations/catalog.d.ts.map +1 -1
  77. package/dist/public/operations/evidence-floor.js +1 -1
  78. package/dist/public/operations/proof-contract-claims.js +1 -1
  79. package/dist/public/operations/specs/composite.d.ts +16 -3
  80. package/dist/public/operations/specs/composite.d.ts.map +1 -1
  81. package/dist/public/operations/specs/modeling.d.ts +16 -3
  82. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  83. package/dist/public/operations/specs/modeling.js +22 -3
  84. package/dist/public/operations/specs/mutation-schemas.d.ts +140 -10
  85. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  86. package/dist/public/operations/specs/mutation-schemas.js +14 -3
  87. package/dist/public/operations/specs/upsert.d.ts +140 -10
  88. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  89. package/dist/public/proof-certificates.d.ts +75 -1
  90. package/dist/public/proof-certificates.d.ts.map +1 -1
  91. package/dist/public/proof-certificates.js +212 -0
  92. package/dist/public/proof-protocol.d.ts +143 -10
  93. package/dist/public/proof-protocol.d.ts.map +1 -1
  94. package/dist/public/proof-protocol.js +301 -16
  95. package/dist/public/proof-receipt.d.ts +4 -3
  96. package/dist/public/proof-receipt.d.ts.map +1 -1
  97. package/dist/public/proof-receipt.js +6 -1
  98. package/dist/public/proof-sources.d.ts +102 -0
  99. package/dist/public/proof-sources.d.ts.map +1 -0
  100. package/dist/public/proof-sources.js +1292 -0
  101. package/dist/public/schemas/entity.d.ts.map +1 -1
  102. package/dist/public/schemas/entity.js +21 -1
  103. package/dist/public/skills/kibi-commit-review/SKILL.md +8 -8
  104. package/dist/public/skills/kibi-commit-review/resources/staged-gate.md +6 -6
  105. package/dist/public/skills/kibi-decisions/SKILL.md +5 -2
  106. package/dist/public/skills/kibi-decisions/resources/decision-records.md +4 -1
  107. package/dist/public/skills/kibi-freshness/SKILL.md +2 -2
  108. package/dist/public/skills/kibi-traceability/SKILL.md +3 -2
  109. package/dist/public/skills/kibi-usage/SKILL.md +5 -3
  110. package/dist/public/skills/kibi-usage/resources/proof.md +105 -9
  111. package/dist/report/html-report.css +45 -10
  112. package/dist/report/html-report.d.ts.map +1 -1
  113. package/dist/report/html-report.js +74 -17
  114. package/dist/report/report-view.d.ts +1 -1
  115. package/dist/report/report-view.d.ts.map +1 -1
  116. package/dist/report/report-view.js +1 -0
  117. package/dist/schemas/entity.schema.json +199 -8
  118. package/dist/traceability/evidence-model.d.ts +13 -12
  119. package/dist/traceability/evidence-model.d.ts.map +1 -1
  120. package/dist/traceability/evidence-model.js +1 -1
  121. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  122. package/dist/traceability/staged-diagnostics.js +24 -20
  123. package/dist/traceability/staged-impact-contract.d.ts +4 -4
  124. package/dist/traceability/staged-impact-contract.js +9 -9
  125. package/dist/traceability/staged-symbols-manifest.d.ts +11 -3
  126. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  127. package/dist/traceability/staged-symbols-manifest.js +47 -140
  128. package/dist/types/entities.d.ts +1 -1
  129. package/dist/types/entities.d.ts.map +1 -1
  130. package/dist/utils/rule-registry.generated.d.ts +1 -1
  131. package/dist/utils/rule-registry.generated.js +1 -1
  132. package/dist/utils/schema-version.d.ts +1 -1
  133. package/dist/utils/schema-version.d.ts.map +1 -1
  134. package/dist/utils/schema-version.js +3 -1
  135. package/dist/utils/strict-modeling.d.ts +3 -2
  136. package/dist/utils/strict-modeling.d.ts.map +1 -1
  137. package/dist/utils/strict-modeling.js +37 -4
  138. package/dist/workspace-cwd.d.ts +15 -0
  139. package/dist/workspace-cwd.d.ts.map +1 -0
  140. package/dist/workspace-cwd.js +86 -0
  141. package/package.json +2 -2
  142. package/schema/validation.pl +3 -1
  143. package/src/public/operations/evidence-floor.ts +1 -1
  144. package/src/public/operations/proof-contract-claims.ts +1 -1
  145. package/src/public/operations/specs/modeling.ts +24 -5
  146. package/src/public/operations/specs/mutation-schemas.ts +14 -3
  147. package/src/public/proof-certificates.ts +296 -1
  148. package/src/public/proof-protocol-types.d.ts +54 -2
  149. package/src/public/proof-protocol.ts +396 -20
  150. package/src/public/proof-receipt.ts +8 -2
  151. package/src/public/proof-sources.ts +1656 -0
  152. package/src/public/schemas/entity.ts +32 -2
  153. package/src/public/skills/kibi-commit-review/SKILL.md +8 -8
  154. package/src/public/skills/kibi-commit-review/resources/staged-gate.md +6 -6
  155. package/src/public/skills/kibi-decisions/SKILL.md +5 -2
  156. package/src/public/skills/kibi-decisions/resources/decision-records.md +4 -1
  157. package/src/public/skills/kibi-freshness/SKILL.md +2 -2
  158. package/src/public/skills/kibi-traceability/SKILL.md +3 -2
  159. package/src/public/skills/kibi-usage/SKILL.md +5 -3
  160. package/src/public/skills/kibi-usage/resources/proof.md +105 -9
  161. package/src/schemas/entity.schema.json +199 -8
  162. package/dist/traceability/reviewed-coordinate-refresh.d.ts +0 -10
  163. package/dist/traceability/reviewed-coordinate-refresh.d.ts.map +0 -1
  164. package/dist/traceability/reviewed-coordinate-refresh.js +0 -49
@@ -35,7 +35,17 @@ type FactKind =
35
35
  | "predicate"
36
36
  | "rule_schema"
37
37
  | "rule";
38
- type Operator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
38
+ type Operator =
39
+ | "eq"
40
+ | "neq"
41
+ | "lt"
42
+ | "lte"
43
+ | "gt"
44
+ | "gte"
45
+ | "matches"
46
+ | "includes"
47
+ | "subset_of"
48
+ | "excludes";
39
49
  type ValueType = "string" | "int" | "number" | "bool";
40
50
  type Polarity = "require" | "forbid" | "assert" | "deny";
41
51
  type VerificationScope = "unit" | "integration" | "end_to_end";
@@ -549,7 +559,27 @@ const entitySchema: Record<string, unknown> = {
549
559
  },
550
560
  subject_key: { type: "string" },
551
561
  property_key: { type: "string" },
552
- operator: { type: "string", enum: ["eq", "neq", "lt", "lte", "gt", "gte"] },
562
+ // matches: value_string is a JavaScript regular expression (u flag) the
563
+ // property's values match as a whole; only string facts use it.
564
+ // includes: every member of value_set has the property (the members
565
+ // that have it include the set); subset_of: every member that has the
566
+ // property is in value_set; excludes: no member of value_set has it.
567
+ // Only set facts use these three.
568
+ operator: {
569
+ type: "string",
570
+ enum: [
571
+ "eq",
572
+ "neq",
573
+ "lt",
574
+ "lte",
575
+ "gt",
576
+ "gte",
577
+ "matches",
578
+ "includes",
579
+ "subset_of",
580
+ "excludes",
581
+ ],
582
+ },
553
583
  value_type: {
554
584
  type: "string",
555
585
  enum: ["string", "int", "number", "bool", "set"],
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  id: kibi-commit-review
3
3
  name: kibi-commit-review
4
- description: "Use when kibi check --staged or the Kibi pre-commit hook blocks a commit (kibi_impact_evidence_missing, symbols_manifest_stale, symbol_granularity_violation, symbol-coverage, kibi check-generated drift, Staged impact review failed), or when preparing a commit or pull-request impact review. Covers reading the per-file Detail lines, authoring .kb/symbols.yaml symbol entries through kb_upsert, kibi sync --refresh-symbol-coordinates, staging the tracked Kibi evidence with git add, kb_prepare_impact_review for a staged or diff scope, the kibi signoff requirements summary to show before a commit, and how merge commits and migration renames are judged."
5
- version: 1.2.2
4
+ description: "Use when kibi check --staged or the Kibi pre-commit hook blocks a commit (kibi_impact_evidence_missing, symbols_manifest_stale, symbol_granularity_violation, symbol-coverage, kibi check-generated drift, Staged impact review failed), or when preparing a commit or pull-request impact review. Covers reading the per-file Detail lines, authoring .kb/symbols.yaml symbol entries through kb_upsert, staging the tracked Kibi evidence with git add (symbol coordinates are derived and never staged), kb_prepare_impact_review for a staged or diff scope, the kibi signoff requirements summary to show before a commit, and how merge commits and migration renames are judged."
5
+ version: 1.3.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -55,17 +55,17 @@ Never read or open any file under `.kb`, not even read-only with a file tool to
55
55
  - New or uncovered symbols: author a `symbol` entity per listed symbol
56
56
  through `kb_upsert` (`title` = the member the extractor names,
57
57
  `sourceFile`, `status: active`, `symbol_role: behavioral`, `implements`
58
- to the requirement, `covered_by` to the test). Then run
59
- `kibi sync --refresh-symbol-coordinates`.
60
- - Only coordinates moved: `kibi sync --refresh-symbol-coordinates`.
58
+ to the requirement, `covered_by` to the test).
59
+ - Only lines moved: nothing to do. Symbol coordinates are derived locally
60
+ by every sync and never committed.
61
61
  - No behavior change (a genuine false positive): see the audited
62
62
  no-impact note in `resources/staged-gate.md`; it never covers a real
63
63
  behavior change.
64
64
  4. **Stage the evidence.** Kibi authors tracked files but never Git-stages or
65
65
  commits them. `git status --short .kb` lists what it wrote; `git add` the
66
- entity Markdown, `.kb/relationships/` shards, `.kb/symbols.yaml` and
67
- `.kb/symbol-coordinates.yaml` that belong to this change (use `git add -p`
68
- when the files hold unrelated edits).
66
+ entity Markdown, `.kb/relationships/` shards and `.kb/symbols.yaml` that
67
+ belong to this change (use `git add -p` when the files hold unrelated
68
+ edits). `.kb/symbol-coordinates.yaml` is gitignored; never stage it.
69
69
  5. **Re-run** `kibi check --staged` (and `kibi check-generated --staged` when it
70
70
  failed) until it passes. Never bypass the hook (`--no-verify`) unless the
71
71
  person says so.
@@ -8,10 +8,10 @@ not the working tree, so a fix counts only once it is staged.
8
8
  ## Reading a finding
9
9
 
10
10
  ```text
11
- symbols_manifest_stale: .kb/symbol-coordinates.yaml is stale or missing for staged source files: src/billing/refund.ts
11
+ symbols_manifest_stale: .kb/symbols.yaml does not cover the declarations of staged source files: src/billing/refund.ts
12
12
  Detail: src/billing/refund.ts — extraction finds 4 symbol(s), evidence covers 3.
13
13
  Not in .kb/symbols.yaml: approveRefund (line 42)
14
- Suggestion: Author .kb/symbols.yaml entries for the uncovered symbols (kibi upsert, with implements/covered_by links), then run kibi sync --refresh-symbol-coordinates && git add .kb/symbol-coordinates.yaml .kb/symbols.yaml, then re-run kibi check --staged.
14
+ Suggestion: Author .kb/symbols.yaml entries for the uncovered symbols (kibi upsert, with implements/covered_by links). Stage .kb/symbols.yaml with the behavior edit, then re-run kibi check --staged.
15
15
  ```
16
16
 
17
17
  - Detail lines name every symbol, never a shortened list. `Evidence without a
@@ -24,15 +24,15 @@ symbols_manifest_stale: .kb/symbol-coordinates.yaml is stale or missing for stag
24
24
 
25
25
  | Id or message | Cause | Fix |
26
26
  | --- | --- | --- |
27
- | `kibi_impact_evidence_missing` | A staged behavior edit (changed lines in exported or behavior-bearing code, not comments or formatting) has no staged Kibi evidence. Test-only edits do not need it unless they add executable test symbols. | Query the owning knowledge; update it when behavior changed; stage entity Markdown under `.kb/`, authored `.kb/symbols.yaml` entries for the listed symbols, or refreshed `.kb/symbol-coordinates.yaml`. |
28
- | `symbols_manifest_stale` | Extraction output changed and the staged coordinates (or manifest) do not match it. | Author entries for the listed symbols first, then `kibi sync --refresh-symbol-coordinates`, then stage both manifests. |
27
+ | `kibi_impact_evidence_missing` | A staged behavior edit (changed lines in exported or behavior-bearing code, not comments or formatting) has no staged Kibi evidence. Test-only edits do not need it unless they add executable test symbols. | Query the owning knowledge; update it when behavior changed; stage entity Markdown under `.kb/` or authored `.kb/symbols.yaml` entries for the listed symbols. A file whose every declaration already has a `.kb/symbols.yaml` entry needs nothing more. |
28
+ | `symbols_manifest_stale` | A staged behavior file declares symbols `.kb/symbols.yaml` has no entry for, or an entry names a declaration that is gone. | Author entries for the listed symbols, re-point or retire entries whose declaration is gone, and stage `.kb/symbols.yaml`. Coordinates are derived locally and never staged. |
29
29
  | `symbol_granularity_violation` | A changed behavioral member is owned only by a coarse class or module symbol while a narrower declaration exists. | Add a symbol for the member itself (`title` = `Class.method` or the exported function) with its own links; use `granularity_reason` (`config-artifact`, `module-level-behavior`, `extractor-miss`, `legacy-link`, `test-suite`) only when it is true. |
30
30
  | `symbol-coverage` | A changed symbol, or a symbol whose staged manifest entry changed, fails the full-check rule on the staged knowledge. | The symbol `implements` the requirement and is `covered_by` a test that verifies it: through the requirement's scenario (`verified_by` scenario -> test) when it has one, else `verified_by` requirement -> test. A direct requirement -> test link does not count while a scenario exists. The finding's suggestion names the missing link (see `kibi-traceability`). |
31
31
  | `kibi_impact_override_missing_rationale` | A `Kibi-Impact: none` declaration has no `Rationale:` line. | Add the rationale, or drop the declaration and stage real evidence. |
32
32
  | `entity-context-missing` (staged entity) | A staged requirement, scenario, test, ADR or observation fact has fewer than 12 words of context. | Upsert a sectioned `document.body` (see `kibi-usage`, Entity body contract). |
33
33
  | `domain-contradictions`, `kb-consistency`, `scenario-feasibility`, `exception-claim-keys` (staged `.kb/` change) | The staged knowledge introduces a violation the last commit did not have. `kb-consistency` also catches facts that contradict only together and names their requirements. | Fix the knowledge; a contradiction with a recorded rule goes to the person (`kibi-decisions`). |
34
34
  | Proposition-complete ingestion | A staged requirement's semantic inventory is missing or no longer matches its prose. | Re-derive it (`kb_model` analyze with the complete prose) or run `kibi migrate` for drift. |
35
- | `kibi check-generated --staged` drift | The staged `.kb/symbols.yaml` or `.kb/symbol-coordinates.yaml` differs from a refresh computed from the index. | `kibi sync --refresh-symbol-coordinates`, review the diff, stage only the intended hunks (`git add -p`). |
35
+ | `kibi check-generated --staged` drift | The staged `.kb/symbols.yaml` is not in the layout sync writes, or `.kb/symbol-coordinates.yaml` is tracked. | `kibi sync --refresh-symbol-coordinates`, review the diff, stage only the intended hunks (`git add -p`); untrack a tracked coordinates file with `kibi migrate` (or `git rm --cached`). |
36
36
  | `Staged impact review failed: impact_review_invalid: ...` | The base commit has `.kibi/impact-policy.json` and the staged `.kibi/impact-review.json` is missing, stale or incomplete. The message names the cause (missing review path, stale fingerprint, ...). | Prepare a fresh record (below). Any later staged change makes the fingerprints stale again, so prepare it last. |
37
37
 
38
38
  The staged gate does not judge evidence levels: the `evidence-floor` rule
@@ -98,6 +98,6 @@ does not prove it. Put the person's id there only when they reviewed it.
98
98
  npx --no-install kibi check --staged # the gate
99
99
  npx --no-install kibi check --staged --format json # with full evidence
100
100
  npx --no-install kibi check-generated --staged # manifest drift
101
- npx --no-install kibi sync --refresh-symbol-coordinates # refresh coordinates
101
+ npx --no-install kibi sync --refresh-symbol-coordinates # rebuild local coordinates
102
102
  git status --short .kb # what Kibi wrote
103
103
  ```
@@ -2,7 +2,7 @@
2
2
  id: kibi-decisions
3
3
  name: kibi-decisions
4
4
  description: "Use when the person states a rule or decision (must, never, always, from now on, we decided), when a Kibi hook asks to confirm or warns about an edit to code that implements a firm requirement, when the Stop hook says source files changed but nothing was recorded, when kb_check quotes requirement_statement_unverified, or when a request conflicts with a recorded requirement or ADR. Covers reading firmness and origin, recording a person's rule as firm with origin.ref, superseding with a Why this changed section, the kb_compile_intent unresolved/reviewCandidates/conflictReviews loop, asking before overriding a firm rule, and putting decisions to the person as one numbered kibi signoff --questions view."
5
- version: 1.3.0
5
+ version: 1.4.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -80,7 +80,10 @@ name the missing capability. Never read or edit `.kb/` files directly.
80
80
  run `kibi prove`. Otherwise set `required_evidence: asserted`, say in the
81
81
  body that no end-to-end test proves the rule yet, and report it as
82
82
  asserted, not tested. Kibi's bootstrap and migration give an untested firm
83
- rule the same floor.
83
+ rule the same floor. When the rule is a claim a certificate kind checks
84
+ (allowed values, transitions, a pattern, a rule over roles, a config,
85
+ route or schema read), a certificate test proves it instead: see
86
+ Certificate proof kinds in kibi-usage `resources/proof.md`.
84
87
  - **The person changes a rule:** supersede it (new requirement linked
85
88
  `supersedes` new -> old, `firmness: firm` when the old one was firm, a
86
89
  `## Why this changed` section of at least 12 words naming their instruction
@@ -62,7 +62,10 @@ validation, not the write.
62
62
  the `evidence-floor` check while it is recorded. Drop it (the floor goes
63
63
  back to `tested`) once an end-to-end test with a proof contract and a
64
64
  passing `kibi prove` receipt covers the rule's scenario; never set it below
65
- `asserted` on a firm rule.
65
+ `asserted` on a firm rule. A rule that a certificate kind checks (allowed
66
+ values, transitions, a pattern, a rule over roles, a config, route or
67
+ schema read) can instead be proved by a certificate test; see Certificate
68
+ proof kinds in kibi-usage `resources/proof.md`.
66
69
  - Your own choice is `default`; a guess is `exploratory`. Write the value
67
70
  explicitly whenever you record a decision.
68
71
  - For strict modeling (claim keys, predicate facts) follow `kibi-usage`,
@@ -2,7 +2,7 @@
2
2
  id: kibi-freshness
3
3
  name: kibi-freshness
4
4
  description: Check exact Git attachment, branch migration/quarantine, compiled-store freshness, source linkage, and repair state before decisions or writes.
5
- version: 2.2.0
5
+ version: 2.3.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -68,7 +68,7 @@ For every freshness, branch, or completion question, call `kb_status` first, the
68
68
  - If entities look stale, refresh context through an approved Kibi capability and then re-query.
69
69
  - When asked whether a requirement is proven, quote its `evidenceLevel` and
70
70
  `evidenceFloor` from `kb_coverage`. `pending_reproof` (receipts older than
71
- the code) is stale evidence, not proof; `kibi prove` refreshes it, and
71
+ the code, or than a file a `source` proof read) is stale evidence, not proof; `kibi prove` refreshes it, and
72
72
  `kibi check --fresh-evidence` is the check that fails on it.
73
73
  - Preserve source-file traceability by carrying `sourceFile`, text references, and validation evidence through discovery, mutation, and completion.
74
74
  - Do not read or edit files inside `.kb` directly; use the selected Kibi interface instead.
@@ -2,7 +2,7 @@
2
2
  id: kibi-traceability
3
3
  name: kibi-traceability
4
4
  description: Maintain source-first requirement, scenario, test, symbol, and proof traceability through Kibi's peer interfaces.
5
- version: 2.2.0
5
+ version: 2.3.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -67,7 +67,8 @@ coverage and a green check are not proof by themselves.
67
67
 
68
68
  Report each requirement's `evidenceLevel` from `kb_coverage` as it is:
69
69
  `proved` only when certificate proofs (exhaustive, typecheck, arithmetic,
70
- smt) derive every applicable claim, named in each contract's `proves`
70
+ smt, rule, state_machine, regex, source) bound at code or harness scope
71
+ derive every applicable claim (intent-scope bindings stay `tested`), named in each contract's `proves`
71
72
  (`claimSummary` and `unprovedClaims` say which are missing), `tested` for fresh passing E2E receipts,
72
73
  `asserted` when only a person stands behind it, `unverified` otherwise. Its
73
74
  `evidenceFloor` says what `kb_check`'s `evidence-floor` rule requires:
@@ -2,7 +2,7 @@
2
2
  id: kibi-usage
3
3
  name: Kibi Usage
4
4
  description: Use Kibi's source-first, exact-Git, migration-aware, proof-aware operations safely across MCP or the trusted local CLI, including partial completion repair.
5
- version: 2.27.0
5
+ version: 2.32.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -436,8 +436,10 @@ For an existing product KB that needs semantic backfill, read
436
436
  `resources/kb-improvement.md`, and `resources/proof.md` for the proof workflow.
437
437
  Each current requirement has an evidence floor (`required_evidence`, else
438
438
  `tested` when firm); certificate proof kinds (exhaustive, typecheck,
439
- arithmetic, smt) reach `proved` for the claims their contract names in
440
- `proves`, and a requirement is proved only when every claim is. When the `evidence-floor` rule fails, follow Debugging
439
+ arithmetic, smt, rule, state_machine, regex, source) reach `proved` for the claims their contract names in
440
+ `proves`, and a requirement is proved only when every claim is. A rule
441
+ predicate bound with `harness_for` (scope `harness`) also counts toward
442
+ `proved`; an intent-scope binding stays `tested`. When the `evidence-floor` rule fails, follow Debugging
441
443
  proof regressions in `resources/proof.md` and use `kibi proof explain`.
442
444
 
443
445
  ## Predicate Ontology Decision Tree
@@ -178,8 +178,14 @@ left:
178
178
  goes unhandled (a switch ending in a `never` assignment, or a
179
179
  `satisfies Record<Domain, ...>` map). Set `witness.path` and
180
180
  `domain_source`; the witness must import the domain. Kibi compiles the
181
- witness itself (strict, with the workspace's TypeScript), so `typescript`
182
- must be installed in the workspace.
181
+ witness itself (strict, with the workspace's TypeScript and the import
182
+ resolution and declaration files of the nearest `tsconfig.json`), so
183
+ `typescript` must be
184
+ installed in the workspace (TypeScript 7 has no compiler API: add
185
+ `typescript@6` as a dev dependency). With `proves`, Kibi decides each
186
+ claim with its own witness and reports the fields or members that break
187
+ it. When the test's compile failed, the rejection adds the first error
188
+ Kibi's own compile of the witness reports.
183
189
  - `arithmetic`: a claim on one `int` or `real` variable decided exactly from
184
190
  typed facts. Set `constraint_source: { fact_ids: [FACT-...] }` to the
185
191
  numeric `property_value` facts (one subject and property); the
@@ -187,10 +193,93 @@ left:
187
193
  exactly their constraints. To read the value from the code instead, set
188
194
  `value_source: [{ symbol_id: SYM-<constant>, export: <name> }]`; Kibi
189
195
  evaluates the number export itself and adds `variable eq value` as an
190
- assumption.
196
+ assumption. For a count claim over a collection ("exactly 32 tools") add
197
+ `measure: count` and name the list, set, map or object export; Kibi uses
198
+ its size, so do not add a number export just for the proof. A count
199
+ claim needs only `value_source`. Naming the claim's own fact in
200
+ `constraint_source` assumes the claim: without `value_source` Kibi counts
201
+ that derivation as intent only (tested), and with it a code value that
202
+ breaks the claim shows up as contradictory assumptions, which the
203
+ rejection names.
204
+ A claim that every member of a closed set has a property ("Every currency
205
+ in GBP, ILS and ZAR must fail closed") is a set fact whose `property_key`
206
+ names the property, whose `value_set` is the members and whose operator
207
+ is `includes` (other members may have the property too, so two such
208
+ claims over different sets do not contradict). Prove it with `rule`: Kibi
209
+ checks the property on each listed member. The kinds that compare the
210
+ whole set (`exhaustive`, `state_machine`) reject an `includes` fact.
191
211
  - `smt`: an SMT-LIB query that declares the facts' property as a constant,
192
212
  asserts each `constraint_source` fact constraint and then the claim's
193
213
  negation. Kibi re-runs z3 or cvc5 on it and accepts only `unsat`.
214
+ - `rule`: decisions over finite domains. Set `predicate_source: {<predicate>:
215
+ { symbol_id }}` to the function behind each predicate the claim uses (it
216
+ takes the arguments in order and returns a boolean) and `domains: {<type>:
217
+ { symbol_id }}` to the export listing each argument type's values. Kibi
218
+ calls every function on every combination and model checks the claim's
219
+ fact: a `kibi.logic.v1` rule fact (from `kb_model_requirement` with
220
+ `logic`) must hold for every assignment, a predicate fact must be decided
221
+ as it says, and a set fact whose `property_key` names a predicate needs it
222
+ true for every member. A type name is also a one-argument predicate
223
+ (`role(R)`) to range a variable. A failure names the assignment. A domain
224
+ can come from the project instead of an export (`domains: {<type>:
225
+ {source: {...}}}`, see `source` below). When the predicate is a test
226
+ harness that drives real code (it calls the handler with each role), add
227
+ `harness_for: [SYM-...]` naming that code; the claim binds with scope
228
+ `harness`, which proves, and those symbols must be `covered_by` the test.
229
+ Add `export: <name>` to a `predicate_source` entry when the function's
230
+ export is not the symbol's title.
231
+ - `state_machine`: set `domain_source` to the transition table (object or
232
+ Map from state to next states, or `[from, to]` pairs) or to a
233
+ `next(state, event)` function with `domains: {state, event}`;
234
+ `initial_source` names the initial state. Model "transitions must be one of
235
+ a -> b, ..." as a `transitions` set fact (members `a->b`), and terminal,
236
+ initial or reachable states as `terminal_states`, `initial_states` or
237
+ `reachable_states` set facts; Kibi checks that projection exactly.
238
+ Temporal claims use two more projections: "a cancelled invoice can never
239
+ become paid" is a `reachable_pairs` fact with `operator: excludes` and
240
+ member `cancelled->paid`, and "every path from draft to paid must pass
241
+ through approved" is a `required_waypoints` fact with member
242
+ `draft->paid via approved` (paid must be reachable from draft, and not
243
+ once approved is removed). Any projection also takes `includes`,
244
+ `subset_of` and `excludes`. Rules over a machine use `transition`,
245
+ `reachable`, `initial`, `terminal`, `state`.
246
+ - `regex`: set `pattern_source` to a `RegExp`, a Python `re.compile(...)` or
247
+ a string constant. Model "X must match `re`" as a string fact with
248
+ `operator: matches` (a JavaScript pattern with the `u` flag, matched
249
+ whole); Kibi decides exact language equality and reports the shortest
250
+ string only one side accepts. Backreferences, lookaround, `\b`, the `g`,
251
+ `y`, `m` and `v` flags, Python `\d`/`\w` without `re.ASCII` and
252
+ non-ASCII letters under `i` are refused with the reason. An exact string
253
+ fact (`eq`/`neq`) checks a constant.
254
+ - `source`: Kibi reads a project source itself and checks a set fact
255
+ against what it read, so the test only runs the proof (it may write
256
+ nothing, or `sourceCertificate({ testId })`). Set `source: {reader, ...}`:
257
+ `json`/`yaml` (`file`, `path`, `select`), `glob` (`pattern`, `capture`),
258
+ `openapi` (`file`, `select: operations|unsecured_operations|...`),
259
+ `references` (`files`, `extract: env|imports|calls|string_args|thrown|
260
+ property`), `schema` (`format: drizzle|prisma|sql`, `select:
261
+ tables|columns|required_columns|nullable_columns|foreign_keys`), `routes`
262
+ (Hono or Express app export, `path_prefix`, `names_from`, `select:
263
+ routes|middleware`) or `validator` (zod, valibot or pydantic, `select:
264
+ fields|required_fields|optional_fields`). A member Kibi cannot read
265
+ statically (a computed env name, a dynamic import, an env object handed
266
+ to a variable) fails the read with its location, and so does an empty
267
+ read (a glob matching no file, migrations with no `CREATE TABLE`), so a
268
+ read is never silently partial. Model the claim as a set fact: `eq`
269
+ (exactly), `includes` (at least), `subset_of` ("must be one of"),
270
+ `excludes` ("must never use"); `property_key: required_fields` or
271
+ `nullable_fields` (only `eq`/`includes`) with bare members `name` for
272
+ "every table" (it also covers tables added later) or `table.name` for
273
+ one; `middleware` with `includes` for "every route under /p must use M"
274
+ (Kibi checks each route). Name middleware with `names_from`: a
275
+ zero-argument factory export such as `requireAuth()` names the
276
+ middleware it returns `requireAuth`. Write the fact with `kb_model`
277
+ (requirement mode, `operator` plus a list `value`) or `kb_upsert`. The
278
+ receipt stales when a file the read touched changes, and the claim binds
279
+ with scope `source`. `value_source` accepts `{source, measure: count}`.
280
+ The builders need kibi-cli 2.33.0 or newer in the project. The env
281
+ extractor reads `process.env`, `import.meta.env`, `Bun.env`,
282
+ `Deno.env.get`, `os.environ` and `os.getenv`, through casts.
194
283
 
195
284
  `arithmetic` and `smt` from `constraint_source` alone prove that the
196
285
  knowledge base's facts entail the claim, not that code follows the facts:
@@ -202,8 +291,11 @@ Every certificate contract names the claims it proves in `proves:
202
291
  [CLAIM-...]` (blocking `proof-contract-claims` from schema 12). Kibi derives
203
292
  each claim's obligation from its grounding fact: a set fact (`value_type:
204
293
  set`, `value_set: [...]`) needs the `exhaustive` domain or the `typecheck`
205
- domain type to be exactly the set; a numeric fact needs the `arithmetic`
206
- claim or the negated `smt` assertion to be its constraint. The receipt
294
+ domain type to be exactly the set (with `property_key: required_fields`,
295
+ `typecheck` instead needs every member to be a required, non-nullable field
296
+ of the domain type); a numeric fact needs the `arithmetic` claim or the
297
+ negated `smt` assertion to be its constraint; rule, predicate, machine and
298
+ string facts need the `rule`, `state_machine` or `regex` checks above. The receipt
207
299
  records one binding per claim: `derived` (checked, the only kind that
208
300
  proves), `attested` (the fact has no derivation; counts as tested) or
209
301
  `rejected` with the reason. Model an enumerated claim as a set fact and a
@@ -212,13 +304,16 @@ REQ-...` shows each claim with its bindings.
212
304
 
213
305
  Build the certificate with `kibi-cli/proof-certificates`
214
306
  (`exhaustiveCertificate`, `typecheckCertificate`, `arithmeticCertificate`,
215
- `smtCertificate`), fail the test when it records a failure
216
- (`failedMembers`), and call `writeCodeCertificate`; it writes to the
307
+ `smtCertificate`, `ruleCertificate`, `stateMachineCertificate`,
308
+ `regexCertificate`, `sourceCertificate`; `readProjectSource` returns Kibi's
309
+ read for a test that wants to assert on it), fail the test when it records a failure
310
+ (`failedMembers`, `failedCalls`), and call `writeCodeCertificate`; it writes to the
217
311
  directory `kibi prove` sets in `KIBI_PROOF_CERTIFICATES` and does nothing
218
312
  elsewhere. A Python test writes the same `kibi.code-certificate.v1` JSON
219
313
  to that directory itself. Wire the KB: the proof file symbol is
220
314
  `executable_for` the test and named in `required_proofs`; the domain symbol
221
- `implements` the requirement and is `covered_by` the test; the test
315
+ (and every symbol a rule, machine or pattern contract names) `implements`
316
+ the requirement and is `covered_by` the test; the test
222
317
  `validates` one of the requirement's scenarios. `proved` is per claim: a
223
318
  multi-claim requirement is proved only when certificates derive every
224
319
  applicable claim, and reads `tested` with `n/m claims proved` otherwise. A
@@ -296,7 +391,8 @@ re-run `kibi prove --stale` (or the affected selection), then confirm
296
391
  unit test count only while that unit test has a current passing receipt, so
297
392
  prove unit tests that cover type-shape symbols too.
298
393
 
299
- Full reference: `docs/proving-requirements.md`.
394
+ Full reference: [Proving requirements](https://looted.github.io/kibi/reference/proving.html)
395
+ (`docs/proving-requirements.md` in the Kibi repository).
300
396
 
301
397
  ## Debugging proof regressions
302
398