kibi-runtime 1.0.1 → 2.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.
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { listBundledSkills, loadBundledSkill, readBundledSkillResource, } from "./skills.js";
3
3
  function assertNonEmptyString(value, field) {
4
- if (typeof value !== "string" || value.trim() === "") {
4
+ if (value.trim() === "") {
5
5
  throw new Error(`${field} must be a non-empty string`);
6
6
  }
7
7
  }
@@ -7,21 +7,33 @@ import { RESOURCE_MAX_BYTES, assertMaxBytes, parseSkillBundle, } from "./validat
7
7
  const moduleDir = dirname(fileURLToPath(import.meta.url));
8
8
  // Source tests load this module from src/skill-system, while the published
9
9
  // bundle inlines it into dist/index.js and copies assets to dist/skills.
10
- const defaultBundledSkillsDir = existsSync(resolve(moduleDir, "skills"))
11
- ? resolve(moduleDir, "skills")
12
- : resolve(moduleDir, "../skills");
13
- let bundledSkillsDir = defaultBundledSkillsDir;
10
+ // Resolved lazily so tests can exercise the default resolution via
11
+ // resetBundledSkillsDir() instead of at import time.
12
+ let overrideSkillsDir;
13
+ function defaultBundledSkillsDir() {
14
+ // rationale: resolved lazily at first use; per-test coverage attribution
15
+ // for this literal is not observable, and the canonical-usage test pins the
16
+ // resolved directory behaviorally.
17
+ // Stryker disable StringLiteral
18
+ return existsSync(resolve(moduleDir, "skills"))
19
+ ? resolve(moduleDir, "skills")
20
+ : resolve(moduleDir, "../skills");
21
+ // Stryker restore
22
+ }
14
23
  export function setBundledSkillsDir(dir) {
15
- bundledSkillsDir = dir;
24
+ overrideSkillsDir = dir;
16
25
  }
17
26
  export function resetBundledSkillsDir() {
18
- bundledSkillsDir = defaultBundledSkillsDir;
27
+ overrideSkillsDir = undefined;
28
+ }
29
+ function currentBundledSkillsDir() {
30
+ return overrideSkillsDir ?? defaultBundledSkillsDir();
19
31
  }
20
32
  export function listBundledSkills() {
21
- return listFrom(bundledSkillsDir);
33
+ return listFrom(currentBundledSkillsDir());
22
34
  }
23
35
  export function loadBundledSkill(id) {
24
- return loadBundledSkillFrom(bundledSkillsDir, id);
36
+ return loadBundledSkillFrom(currentBundledSkillsDir(), id);
25
37
  }
26
38
  // implements REQ-reusable-skill-subsystem
27
39
  // covered_by TEST-skill-cli-load-validate
@@ -55,6 +67,9 @@ function findRoot(dir, id) {
55
67
  function listRoots(dir) {
56
68
  if (!existsSync(dir))
57
69
  return [];
70
+ // rationale: dropping the directory filter only admits symlinked entries,
71
+ // which find() resolves to the same bundle regardless of readdir order.
72
+ // Stryker disable next-line MethodExpression
58
73
  return readdirSync(dir, { withFileTypes: true })
59
74
  .filter((entry) => entry.isDirectory())
60
75
  .map((entry) => join(dir, entry.name))
@@ -64,7 +79,11 @@ function readBundle(bundle, id, resourcePath) {
64
79
  const resource = normalizeResourcePath(resourcePath);
65
80
  if (!resource || isPathOutOfBounds(resourcePath))
66
81
  throw new SkillResourceOutOfBoundsError(id, resourcePath);
67
- if (!(bundle.manifest.resources ?? []).some((declared) => normalizeResourcePath(declared) === resource))
82
+ if (
83
+ // rationale: an empty declared list and a placeholder entry both fail the
84
+ // declaration check for any real resource, yielding the same error.
85
+ // Stryker disable next-line ArrayDeclaration
86
+ !(bundle.manifest.resources ?? []).some((declared) => normalizeResourcePath(declared) === resource))
68
87
  throw new SkillResourceNotFoundError(id, resourcePath);
69
88
  const candidate = resolve(bundle.rootDir, resource);
70
89
  try {
@@ -11,9 +11,11 @@ export function isPathOutOfBounds(pathLike) {
11
11
  normalized.startsWith("../") ||
12
12
  normalized.includes("/../"));
13
13
  }
14
+ // implements REQ-reusable-skill-subsystem
14
15
  export function isWithinRoot(rootDir, candidatePath) {
15
16
  const rel = relative(rootDir, candidatePath);
16
- return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
17
+ // An empty rel (candidate === root) already satisfies both checks below.
18
+ return !rel.startsWith("..") && !isAbsolute(rel);
17
19
  }
18
20
  export function resolveSkillFilePath(pathLike) {
19
21
  const resolved = resolve(pathLike);
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
1
+ import * as fs from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import matter from "gray-matter";
4
4
  import { SkillOversizeError, SkillValidationError } from "./errors.js";
@@ -6,14 +6,18 @@ import { SKILL_FILE_NAME, isPathOutOfBounds, isWithinRoot, normalizeResourcePath
6
6
  const SKILL_MARKDOWN_MAX_BYTES = 256 * 1024;
7
7
  export const RESOURCE_MAX_BYTES = 128 * 1024;
8
8
  export function assertMaxBytes(pathLike, maxBytes) {
9
- const size = statSync(pathLike).size;
9
+ const size = fs.statSync(pathLike).size;
10
10
  if (size > maxBytes)
11
11
  throw new SkillOversizeError(pathLike, maxBytes, size);
12
12
  }
13
+ // implements REQ-reusable-skill-subsystem
13
14
  export function parseSkillBundle(rootDir) {
14
15
  const path = resolve(rootDir, SKILL_FILE_NAME);
15
16
  assertMaxBytes(path, SKILL_MARKDOWN_MAX_BYTES);
16
- const parsed = matter(readFileSync(path, "utf8"));
17
+ // rationale: Bun treats the empty encoding as utf8 (verified), so
18
+ // gray-matter parses identical content either way.
19
+ // Stryker disable next-line StringLiteral
20
+ const parsed = matter(fs.readFileSync(path, "utf8"));
17
21
  const [error] = validateManifestData(parsed.data);
18
22
  if (error)
19
23
  throw error;
@@ -23,17 +27,21 @@ export function parseSkillBundle(rootDir) {
23
27
  rootDir: resolve(rootDir),
24
28
  };
25
29
  }
30
+ // implements REQ-reusable-skill-subsystem
26
31
  export function validateSkillBundle(pathLike) {
27
32
  const path = resolveSkillFilePath(pathLike);
28
33
  const errors = [];
29
- if (!existsSync(path))
34
+ if (!fs.existsSync(path))
30
35
  return {
31
36
  valid: false,
32
37
  errors: [
33
38
  new SkillValidationError("SKILL.md", `Missing ${SKILL_FILE_NAME}`),
34
39
  ],
35
40
  };
36
- const parsed = matter(readFileSync(path, "utf8"));
41
+ // rationale: Bun treats the empty encoding as utf8 (verified), so
42
+ // gray-matter parses identical content either way.
43
+ // Stryker disable next-line StringLiteral
44
+ const parsed = matter(fs.readFileSync(path, "utf8"));
37
45
  errors.push(...validateManifestData(parsed.data));
38
46
  if (errors.length === 0)
39
47
  validateBundleContents(path, coerceManifest(parsed.data), errors);
@@ -48,7 +56,7 @@ function validateBundleContents(path, manifest, errors) {
48
56
  }
49
57
  let root;
50
58
  try {
51
- root = realpathSync(dirname(path));
59
+ root = fs.realpathSync(dirname(path));
52
60
  }
53
61
  catch (error) {
54
62
  errors.push(new SkillValidationError("SKILL.md", error instanceof Error ? error.message : String(error)));
@@ -57,11 +65,11 @@ function validateBundleContents(path, manifest, errors) {
57
65
  for (const resource of manifest.resources ?? []) {
58
66
  const resourcePath = resolve(dirname(path), resource);
59
67
  try {
60
- if (!existsSync(resourcePath)) {
68
+ if (!fs.existsSync(resourcePath)) {
61
69
  errors.push(new SkillValidationError("resources", `Missing skill resource: ${resource}`));
62
70
  continue;
63
71
  }
64
- const real = realpathSync(resourcePath);
72
+ const real = fs.realpathSync(resourcePath);
65
73
  if (!isWithinRoot(root, real)) {
66
74
  errors.push(new SkillValidationError("resources", `Skill resource escapes bundle root: ${resource}`));
67
75
  continue;
@@ -39,7 +39,7 @@ echo '{}' | npx --no-install kibi status --input -
39
39
  matching `branch.json`; a `legacy_compat` attachment is read-only until an
40
40
  explicit old/new migration is approved.
41
41
  - Inspect bounded `staleReasons` (indexed source missing/newer or documentation
42
- source newer) and `verificationSnapshotChanges`. Kibi deliberately reports
42
+ source newer) and `proofSnapshotChanges`. Kibi deliberately reports
43
43
  editor/config paths such as editor dot-directories; do not silently ignore them.
44
44
  - Use `kb_query`, or `query --input`, with `sourceFile` and text references for source-linked discovery.
45
45
  - Re-run `kb_search`, or `search --input`, after sync gaps or stale context are detected.
@@ -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.1.0
5
+ version: 2.1.3
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -19,6 +19,7 @@ resources:
19
19
  - resources/relationship-directions.md
20
20
  - resources/fact-lanes.md
21
21
  - resources/workflows.md
22
+ - resources/proof.md
22
23
  - resources/ui-requirements.md
23
24
  - resources/logic-ir.md
24
25
  - resources/kb-improvement.md
@@ -67,13 +68,30 @@ mutability, and Prolog requirements of each operation.
67
68
  Kibi never Git-stages or commits those files. Do not read or edit `.kb`
68
69
  directly.
69
70
  5. Finish with targeted and final `kb_check`, then read status/coverage and
70
- state freshness, verification, proof, and limitations separately.
71
+ report the five independent closeout fields (not one inferred success flag).
71
72
 
72
73
  Run `kb_check` with specific rules during iteration and the unfiltered final
73
74
  check. Never fire `kb_upsert` calls in parallel; create or confirm endpoint
74
75
  entities before linking them. The canonical MCP names are `kb_search`,
75
76
  `kb_query`, `kb_upsert`, and `kb_check`.
76
77
 
78
+ For a task that explicitly supplies a malformed concrete mutation payload, locate and read that public request artifact before choosing an entity, preserving its exact entity ID, type, requested changes, and every intended relationship and endpoint. Do not substitute a seeded or convenient entity for the requested target. Start with kb_search, then exact-filter those targets with kb_query, and run kb_validate_upsert on that same payload; validation is not completion. Correct only diagnosed pre-commit errors and revalidate the corrected payload. Once authorized, apply the identical corrected and authorized payload with kb_upsert. If it returns committed_with_repairs, treat the mutation as committed, follow only the required repair actions, and neither retry it nor trigger unrelated semantic backfill for a schema-only repair. Exact-read every changed entity and relationship endpoint with kb_query, then finish with an unfiltered kb_check followed by a final kb_status.
79
+
80
+ ## Closeout fields
81
+
82
+ End every task with these five independent fields:
83
+
84
+ ```text
85
+ taskOutcome: complete | interim | blocked
86
+ kbState: clean_fresh | stale | dirty | legacy_compat | not_evaluated
87
+ verificationState: fresh | dirty | unavailable | not_evaluated
88
+ proofState: proven | mixed | unresolved | not_evaluated
89
+ limitationDisposition: none | accepted | unaccepted | not_applicable
90
+ ```
91
+
92
+ `taskOutcome` is whether the requested work finished. The other fields are
93
+ observed system state. A clean check can coexist with unresolved proof.
94
+
77
95
  ## Exact Git attachment
78
96
 
79
97
  The active ref is the exact KB identity. `KIBI_BRANCH` is used verbatim; Git's
@@ -114,22 +132,36 @@ safe normative claims; use `observation` or `meta` for bug/workaround notes and
114
132
  `flag` only for actual runtime/config gates. Requirements require scenarios,
115
133
  tests, symbol ownership, and fresh proof-bearing receipts before claiming proof.
116
134
  For an existing product KB that needs semantic backfill, read
117
- `resources/kb-improvement.md`.
135
+ `resources/kb-improvement.md`, and `resources/proof.md` for the proof workflow.
136
+ When a proof ratchet fails, follow Debugging proof regressions in
137
+ `resources/proof.md`: use `kibi proof explain` and compare current proof state
138
+ to committed `proof/baseline.json` with `kibi proof impact`.
118
139
 
119
140
  ## Predicate Ontology Decision Tree
120
141
 
121
- Call `kb_semantic_advisor`, `kb_model_requirement`, or `kb_suggest_predicates`
122
- before encoding a normative clause. Use `fact_kind: predicate` with
123
- `requires_predicate` when a suitable schema exists; use `fact_kind: observation`
124
- for an ontology gap. Keep the `REQ -> TEST` chain and use `verified_by` for
125
- proof-bearing links. Relationship direction is fixed, and every `from` in a
126
- relationship batch must equal the upserted entity ID.
142
+ Call `kb_semantic_advisor` on the complete prose before encoding a clause.
143
+ Set requirement `logic_claims` to exactly the assertive `claim_key` values.
144
+ For each relational clause, call `kb_suggest_predicates` with that clause and
145
+ `existingLogicClaims`. If lexical rank is a false positive, retry with the
146
+ reviewed `schemaId`. If `binding_status` is `incomplete`, supply
147
+ `argumentBindings` and retry. Persist `fact_kind: predicate` with the same
148
+ `claim_key` / `claim_text`, then link `REQ -> fact` with `requires_predicate`.
149
+ Use `kb_model_requirement` for strict scalar clauses. Use
150
+ `fact_kind: observation` only for a true ontology gap. The manifest is not
151
+ grounding: run `logic-coverage` so each key binds to one ground fact.
152
+ Relationship direction is fixed, and every `from` in a relationship batch
153
+ must equal the upserted entity ID.
154
+
155
+ For conditional relational claims, after the initial `kb_suggest_predicates` and before any `kb_upsert`—including one needed for a missing schema—call read-only `kb_model_requirement` to preview suitable scalar or typed-rule modeling. Treat the preview as advisory: do not apply an irrelevant result or create unrequested facts, and retain an approved ground-predicate plan when it captures the whole claim. Preserve supplied arity, ordered argument roles, polarity, bound values, and one claim key per actual assertion; never split arguments across clauses or schemas or alter values to force uniqueness.
127
156
 
128
157
  ## Symbol-First Traceability
129
158
 
130
- Represent implementation ownership with a `symbol` entity and an `implements`
131
- relationship from the symbol to the requirement. Do not rely on legacy
132
- `// implements REQ-xxx` comments as the traceability record.
159
+ Represent implementation ownership with a `symbol` entity that has
160
+ `sourceFile`, `implements` to the requirement, and `covered_by` to the test.
161
+ Prolog `symbol-coverage` also requires the test to `validates` the requirement
162
+ (or the requirement `verified_by` the test). `covered_by` alone is not
163
+ enough. Do not rely on legacy `// implements REQ-xxx` comments as the
164
+ traceability record.
133
165
 
134
166
  ## Complete Logical Coverage
135
167
 
@@ -26,7 +26,7 @@ per operation. Effects are authoritative for mutability and adapter annotations.
26
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
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
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 |
29
+ | `kb_ingest_proof` | `ingest-proof` | --input JSON | write | yes | kb-read, kb-write, workspace-read | peer; capability-selected | kibi.kb_ingest_proof.v1 | yes | unsafe | no | yes |
30
30
 
31
31
  ## JSON execution recipe
32
32
 
@@ -0,0 +1,150 @@
1
+ # Proof and Verification Workflow
2
+
3
+ Use this resource when a requirement must be proven before handoff, when
4
+ wiring a proof-bearing test, or when `kb_ingest_proof` or `kibi prove`
5
+ rejected evidence.
6
+
7
+ Kibi does not support test runners. Kibi supports proof evidence. Any
8
+ producer (Playwright, pytest, JUnit, TAP, shell commands, database harnesses)
9
+ reports what happened as `kibi.proof-run.v1`; Kibi evaluates proof.
10
+
11
+ ## Golden path
12
+
13
+ 1. Query the test (`kb_query`, `type: test`) and read its
14
+ `kibi.proof-contract.v1`, `proof_bindings`, and `verification_scope`.
15
+ 2. Run the configured producer through the canonical command:
16
+
17
+ ```bash
18
+ kibi prove --test TEST-<id>
19
+ # or: kibi prove --requirement REQ-<id> | --integration <id> | --all
20
+ ```
21
+
22
+ `kibi prove` captures the workspace snapshot, runs each integration's
23
+ producer once (`shell: false`), revalidates the snapshot, evaluates the
24
+ artifact against every selected contract, and appends idempotent
25
+ `kibi.proof-receipt.v1` receipts.
26
+ 3. Confirm with `kb_status` (fresh, current snapshot) and `kb_coverage`.
27
+
28
+ Never hand-write receipts. Kibi derives them from validated
29
+ `kibi.proof-run.v1` artifacts only.
30
+
31
+ ## Proof contracts
32
+
33
+ A proof-bearing test declares explicit obligations (never a Cartesian
34
+ cases-times-projects matrix):
35
+
36
+ ```yaml
37
+ verification_scope: end_to_end
38
+ verification_perspective: consumer
39
+ proof_contract:
40
+ version: kibi.proof-contract.v1
41
+ integration: web-e2e # id from .kb/proof/integrations.json
42
+ required_proofs:
43
+ - symbol_id: SYM-PW-4F2A9C61B7D03E85
44
+ target: chromium # browser, runtime, db, device, or default
45
+ success_policy: all_required_first_attempt
46
+ proof_bindings: # optional provenance metadata
47
+ - symbol_id: SYM-PW-4F2A9C61B7D03E85
48
+ target: chromium
49
+ native_id: tests/checkout.spec.ts::accepts a card
50
+ ```
51
+
52
+ Provenance lives in `proof_bindings`; the contract stays semantic.
53
+
54
+ ## Integration configuration
55
+
56
+ `.kb/proof/integrations.json` (`kibi.proof-integration.v1`) is tracked,
57
+ Kibi-managed configuration describing evidence production only:
58
+
59
+ - `producer: command` — Kibi synthesizes the envelope from the process
60
+ outcome; obligations are bound with `aggregate_run` provenance and the
61
+ single process invocation counts as the known first attempt.
62
+ - `producer: playwright` (or custom) — the child emits `kibi.proof-run.v1`
63
+ itself (bundled reporter: `kibi-cli/playwright-reporter`).
64
+ - `producer: junit` / `tap` — Kibi converts the native report at `artifact`
65
+ using each test's `proof_bindings`; standard formats carry no retry
66
+ history, so attempts are reported as `unavailable` and fail the strict
67
+ first-attempt policy closed.
68
+
69
+ Cosmetic edits (descriptions, labels) never stale proof. Execution-relevant
70
+ edits (command, artifact, targets, options, bindings, contract) change the
71
+ effective fingerprint and do.
72
+
73
+ ## Attempt semantics (factual, never optimistic)
74
+
75
+ - `attempts: {status: "complete", entries: [...]}` — known history; the
76
+ strict policy requires a passing **first** entry.
77
+ - `attempts: {status: "unavailable"}` — unknown native history; the strict
78
+ policy fails closed, except `aggregate_run` results, which are satisfied by
79
+ the Kibi-launched process attempt when the run passed with exit code 0.
80
+ - `run.outcome` is authoritative: a failed, errored, cancelled, interrupted,
81
+ or `no_results` run proves nothing, even with passing individual results.
82
+
83
+ ## Common rejections
84
+
85
+ - `No proof integration configuration` — bootstrap has not configured proof
86
+ for this repository yet; do not hand-wave, run the bootstrap proof step.
87
+ - `captured snapshot is not the live workspace snapshot` — the tree changed
88
+ between capture and ingest; re-run `kibi prove`.
89
+ - `artifact command_argv does not match the configured command` — the
90
+ artifact came from a different command than `integrations.json` configures.
91
+ - `attempt history unavailable` — the producer could not prove first-attempt
92
+ success for a native-case obligation; use a producer with complete history
93
+ or accept aggregate provenance.
94
+ - `proof_receipts is append-only` — receipts are append-only; update tests
95
+ through the engine (which appends) or include the existing history when
96
+ authoring test files directly.
97
+
98
+ ## After code changes
99
+
100
+ Receipts bind to the snapshot, contract hash, and execution fingerprint at
101
+ run time. Any code or source change moves the snapshot and stales receipts:
102
+ re-run `kibi prove` for the affected selection, then confirm `kb_status` and
103
+ `kb_coverage` before handoff.
104
+
105
+ Full reference: `docs/proving-requirements.md`.
106
+
107
+ ## Debugging proof regressions
108
+
109
+ When a proof ratchet fails, diagnose first. Do not treat
110
+ `proof/baseline.json` as the thing to edit.
111
+
112
+ 1. Do not refresh `proof/baseline.json` as the first fix.
113
+ 2. Identify the exact requirement and symbol responsible for the regression.
114
+ 3. Use Kibi proof diagnostics rather than reverse-engineering
115
+ `requirement_proof.pl`:
116
+
117
+ ```bash
118
+ kibi proof explain REQ-<id>
119
+ kibi proof explain SYM-<id>
120
+ kibi proof impact
121
+ ```
122
+
123
+ `kibi proof impact` compares the current Proof projection to
124
+ `HEAD:proof/baseline.json` (the committed ratchet snapshot, not the
125
+ working-tree file). It is diagnostic: fingerprint differences are reported
126
+ and the command exits 0 on successful evaluation. The strict ratchet remains
127
+ `scripts/check-proof-baseline.mjs`.
128
+ 4. For `missing_production_symbol_coverage`, inspect symbol role, owning
129
+ requirement, `covered_by`, candidate test scope, the requirement scenario
130
+ chain, and the current proof receipt. `kibi proof explain` prints those as
131
+ three labeled blocks so they cannot be confused:
132
+ `required_proofs` (TEST contract obligations), `executable_for` (test-code
133
+ identity), and `covered_by` (production coverage candidates with primary
134
+ plus optional secondary reasons).
135
+ 5. A behavioral production symbol requires qualifying behavioral/E2E evidence
136
+ under the current proof model.
137
+ 6. Unit coverage can satisfy structural/type-shape requirements only when the
138
+ symbol genuinely represents structural shape and the proof model allows it.
139
+ 7. `executable_for` identifies executable test code. Never use it on
140
+ production helpers merely to remove production coverage obligations.
141
+ 8. Do not trust TEST names. Resolve
142
+ `TEST -> proof_contract.required_proofs -> SYM -> source` and inspect what
143
+ the executable test actually exercises. Kibi does not infer “this TEST name
144
+ does not match that source file.”
145
+ 9. A passing proof producer does not automatically make every authored
146
+ `covered_by` relationship semantically correct.
147
+ 10. Prefer one meaningful E2E scenario covering multiple internal functions
148
+ plus focused unit tests for edge cases, rather than an E2E test per helper.
149
+ 11. Refresh the baseline only after a genuine intentional proof-state
150
+ improvement requires the ratchet snapshot to be updated.
@@ -25,7 +25,7 @@ Receipt reuse is safe only when the live verification snapshot, contract hash,
25
25
  freshness window, and every required case result still match. Otherwise rerun
26
26
  the contracted command. If the contract changed, retain every older receipt
27
27
  unchanged, append evidence for the current contract, and keep proof unresolved
28
- with `verification_contract_mismatch` until that current receipt exists.
28
+ with `proof_contract_mismatch` until that current receipt exists.
29
29
  Obsolete symbols require current extraction or Git evidence before
30
30
  remap/deletion; transfer coverage only when existing test evidence supports it,
31
31
  then sync and read back status. Same-version packages with different export
@@ -46,7 +46,7 @@ The canonical workflow for any KB operation follows this pattern:
46
46
  7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
47
47
  8. **Link**: validated `kb_upsert` with `requires_rule`, `requires_predicate`, `constrains`, or `requires_property`, sequentially
48
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
49
+ 10. **Prove execution**: read `kb_status.proofSnapshot`, run `kibi prove` so each configured integration executes once and its `kibi.proof-run.v1` artifact is evaluated against every selected test's `kibi.proof-contract.v1` obligations, appending idempotent `kibi.proof-receipt.v1` receipts; then re-run `kb_coverage`. Never promote durable test status into fresh evidence.
50
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
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
52
 
@@ -74,7 +74,7 @@ choose package managers, ground semantic claims, resolve contradictions, rerun
74
74
  E2E tests, rewrite receipt history, remap authored symbols, or accept
75
75
  limitations. Those actions remain explicit review/operator/execution steps.
76
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.
77
+ For `e2e_receipt_freshness_low`, query each listed requirement/test gap and run `kibi prove --requirement <id>` (or the covering integration); this appends proof receipts idempotently and preserves 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
78
 
79
79
  ## Creating a New Feature
80
80
  ```
@@ -101,12 +101,12 @@ Do not create a test-fact pair. Facts describe invariants; requirements or scena
101
101
  ## Fresh E2E Receipt Workflow
102
102
 
103
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.
104
+ 2. Read `kb_status` and retain its available `proofSnapshot`. Stop if the runtime reports `unknown`; proof must fail closed when the code identity cannot be computed.
105
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.
106
+ 4. Preserve every existing receipt byte-for-byte and append the derived `kibi.proof-receipt.v1` object with strictly later `finished_at`. Earlier receipts may bind older contracts or fingerprints; they remain audit history but cannot prove the current contract. Mutation and incremental sync reject history removal, rewriting, and reordering.
107
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
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.
109
+ Only the newest receipt matching the live snapshot, current contract hash, and current execution fingerprint 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_proof_receipt`, `stale_proof_receipt`, `failed_proof_receipt`, `invalid_proof_receipt`, `proof_contract_mismatch`, and `proof_snapshot_unavailable` are repair states, not warnings to waive.
110
110
 
111
111
  ## Predicate-First Requirement Modeling
112
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-runtime",
3
- "version": "1.0.1",
3
+ "version": "2.0.1",
4
4
  "description": "Narrow first-party runtime contracts and adapters for Kibi operations.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,16 +11,15 @@
11
11
  "default": "./dist/index.js"
12
12
  }
13
13
  },
14
- "files": [
15
- "dist"
16
- ],
14
+ "files": ["dist"],
17
15
  "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/",
16
+ "build": "tsc -p tsconfig.json && bun build src/index.ts --outfile dist/index.js --target node --format esm --packages bundle --external kibi-core --external kibi-plugin-builtin && 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
17
  "typecheck": "tsc -p tsconfig.json --noEmit"
20
18
  },
21
19
  "dependencies": {
22
20
  "gray-matter": "^4.0.3",
23
- "kibi-core": "^0.11.0"
21
+ "kibi-core": "^0.13.0",
22
+ "kibi-plugin-builtin": "^0.2.0"
24
23
  },
25
24
  "devDependencies": {
26
25
  "kibi-cli": "workspace:*"