kibi-cli 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/cli-register-proof.d.ts.map +1 -1
  2. package/dist/cli-register-proof.js +16 -2
  3. package/dist/commands/check.d.ts.map +1 -1
  4. package/dist/commands/check.js +5 -1
  5. package/dist/commands/doctor.d.ts.map +1 -1
  6. package/dist/commands/doctor.js +83 -4
  7. package/dist/commands/prove.js +1 -1
  8. package/dist/operations/modeling/model-requirement.d.ts +5 -0
  9. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  10. package/dist/operations/modeling/model-requirement.js +17 -5
  11. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  12. package/dist/operations/modeling/predicate-applyplan.js +16 -6
  13. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  14. package/dist/operations/planning/apply-plan.js +15 -0
  15. package/dist/proof/inspect.d.ts +18 -1
  16. package/dist/proof/inspect.d.ts.map +1 -1
  17. package/dist/proof/inspect.js +17 -8
  18. package/dist/proof/integration-plan.d.ts +57 -0
  19. package/dist/proof/integration-plan.d.ts.map +1 -0
  20. package/dist/proof/integration-plan.js +331 -0
  21. package/dist/proof/integrations.js +1 -1
  22. package/dist/public/operations/catalog.d.ts +2 -2
  23. package/dist/public/operations/check-executor.d.ts +16 -0
  24. package/dist/public/operations/check-executor.d.ts.map +1 -1
  25. package/dist/public/operations/check-executor.js +80 -0
  26. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  27. package/dist/public/operations/discovery-executors.js +13 -3
  28. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  29. package/dist/public/operations/migration-plan.js +28 -0
  30. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  31. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  32. package/dist/public/operations/specs/check-rules.generated.js +2 -1
  33. package/dist/public/operations/specs/check.d.ts +1 -1
  34. package/dist/public/operations/specs/composite.d.ts +16 -3
  35. package/dist/public/operations/specs/composite.d.ts.map +1 -1
  36. package/dist/public/operations/specs/composite.js +79 -2
  37. package/dist/public/operations/specs/modeling.d.ts +1 -1
  38. package/dist/public/operations/specs/modeling.js +1 -1
  39. package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -1
  40. package/dist/public/skills/kibi-usage/SKILL.md +14 -6
  41. package/dist/public/skills/kibi-usage/resources/proof.md +15 -3
  42. package/dist/utils/branch-store.d.ts +32 -0
  43. package/dist/utils/branch-store.d.ts.map +1 -1
  44. package/dist/utils/branch-store.js +122 -1
  45. package/dist/utils/rule-registry.generated.d.ts +5 -0
  46. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  47. package/dist/utils/rule-registry.generated.js +6 -0
  48. package/dist/utils/strict-modeling.d.ts +12 -0
  49. package/dist/utils/strict-modeling.d.ts.map +1 -1
  50. package/dist/utils/strict-modeling.js +12 -1
  51. package/package.json +2 -2
  52. package/src/public/operations/check-executor.ts +105 -0
  53. package/src/public/operations/discovery-executors.ts +19 -2
  54. package/src/public/operations/migration-plan.ts +35 -0
  55. package/src/public/operations/specs/check-rules.generated.ts +2 -1
  56. package/src/public/operations/specs/composite.ts +110 -11
  57. package/src/public/operations/specs/modeling.ts +1 -1
  58. package/src/public/skills/kibi-bootstrap/SKILL.md +2 -1
  59. package/src/public/skills/kibi-usage/SKILL.md +14 -6
  60. package/src/public/skills/kibi-usage/resources/proof.md +15 -3
@@ -0,0 +1,331 @@
1
+ import { createHash } from "node:crypto";
2
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "node:fs";
3
+ import path from "node:path";
4
+ import { buildMigrationPlan, migrationAction, } from "../public/operations/migration-plan.js";
5
+ import { PROOF_CONTRACT_VERSION, PROOF_INTEGRATION_VERSION, } from "../public/proof-protocol.js";
6
+ import { PROOF_INTEGRATIONS_PATH, integrationsPath, proofIntegrationErrors, } from "./integrations.js";
7
+ /** Migration action code of a reviewed proof integration write. */
8
+ export const PROOF_INTEGRATION_CONFIGURE = "proof_integration_configure";
9
+ /**
10
+ * Files the proposal is derived from. Their hashes are bound into the plan,
11
+ * so a plan reviewed against one package.json is refused after it changed.
12
+ */
13
+ const PROPOSAL_SOURCES = [
14
+ "package.json",
15
+ "bun.lock",
16
+ "bun.lockb",
17
+ "pnpm-lock.yaml",
18
+ "yarn.lock",
19
+ "playwright.config.ts",
20
+ "playwright.config.mjs",
21
+ "playwright.config.js",
22
+ "vitest.config.ts",
23
+ "vitest.config.mjs",
24
+ "vitest.config.js",
25
+ "jest.config.ts",
26
+ "jest.config.mjs",
27
+ "jest.config.js",
28
+ "pytest.ini",
29
+ "pyproject.toml",
30
+ "setup.cfg",
31
+ "tox.ini",
32
+ "go.mod",
33
+ "Cargo.toml",
34
+ "pom.xml",
35
+ "build.gradle",
36
+ "build.gradle.kts",
37
+ "Gemfile",
38
+ "Rakefile",
39
+ ];
40
+ /** npm writes this placeholder into a fresh package.json; it runs no tests. */
41
+ const NPM_PLACEHOLDER_TEST = /no test specified/i;
42
+ function readPackageJson(root) {
43
+ try {
44
+ const parsed = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
45
+ return parsed !== null &&
46
+ typeof parsed === "object" &&
47
+ !Array.isArray(parsed)
48
+ ? parsed
49
+ : null;
50
+ }
51
+ catch {
52
+ return null;
53
+ }
54
+ }
55
+ function packageTestCommand(root) {
56
+ const pkg = readPackageJson(root);
57
+ const scripts = pkg !== null &&
58
+ pkg.scripts !== null &&
59
+ typeof pkg.scripts === "object" &&
60
+ !Array.isArray(pkg.scripts)
61
+ ? pkg.scripts
62
+ : {};
63
+ const test = scripts.test;
64
+ if (typeof test !== "string" || test.trim() === "")
65
+ return null;
66
+ if (NPM_PLACEHOLDER_TEST.test(test))
67
+ return null;
68
+ const has = (file) => existsSync(path.join(root, file));
69
+ if (has("bun.lock") || has("bun.lockb"))
70
+ return ["bun", "run", "test"];
71
+ if (has("pnpm-lock.yaml"))
72
+ return ["pnpm", "test"];
73
+ if (has("yarn.lock"))
74
+ return ["yarn", "test"];
75
+ return ["npm", "test"];
76
+ }
77
+ /** Ordered: the first runner whose marker file exists wins. */
78
+ const RUNNER_COMMANDS = [
79
+ {
80
+ runner: "playwright",
81
+ id: "e2e",
82
+ files: [
83
+ "playwright.config.ts",
84
+ "playwright.config.mjs",
85
+ "playwright.config.js",
86
+ ],
87
+ command: ["npx", "playwright", "test"],
88
+ },
89
+ {
90
+ runner: "vitest",
91
+ id: "unit",
92
+ files: ["vitest.config.ts", "vitest.config.mjs", "vitest.config.js"],
93
+ command: ["npx", "vitest", "run"],
94
+ },
95
+ {
96
+ runner: "jest",
97
+ id: "unit",
98
+ files: ["jest.config.ts", "jest.config.mjs", "jest.config.js"],
99
+ command: ["npx", "jest", "--ci"],
100
+ },
101
+ {
102
+ runner: "pytest",
103
+ id: "unit",
104
+ files: ["pytest.ini", "pyproject.toml", "setup.cfg", "tox.ini"],
105
+ command: ["pytest"],
106
+ },
107
+ {
108
+ runner: "go test",
109
+ id: "unit",
110
+ files: ["go.mod"],
111
+ command: ["go", "test", "./..."],
112
+ },
113
+ {
114
+ runner: "cargo test",
115
+ id: "unit",
116
+ files: ["Cargo.toml"],
117
+ command: ["cargo", "test"],
118
+ },
119
+ {
120
+ runner: "maven",
121
+ id: "unit",
122
+ files: ["pom.xml"],
123
+ command: ["mvn", "test"],
124
+ },
125
+ {
126
+ runner: "gradle",
127
+ id: "unit",
128
+ files: ["build.gradle", "build.gradle.kts"],
129
+ command: ["gradle", "test"],
130
+ },
131
+ {
132
+ runner: "rake test",
133
+ id: "unit",
134
+ files: ["Rakefile"],
135
+ command: ["bundle", "exec", "rake", "test"],
136
+ },
137
+ ];
138
+ /**
139
+ * The command-producer integration Kibi proposes for the repository's test
140
+ * runner: the package.json `test` script when there is one (it is what the
141
+ * project already runs), otherwise the first detected runner. A command
142
+ * integration is the universal floor: Kibi judges the run by its exit code
143
+ * (aggregate-run provenance), so it works for every runner without a
144
+ * reporter; a native producer can replace it later through an update plan.
145
+ */
146
+ // implements REQ-kibi-verification-evidence-contract
147
+ export function proposeProofIntegration(root, overrideId) {
148
+ const npmCommand = packageTestCommand(root);
149
+ const detected = npmCommand !== null
150
+ ? {
151
+ runner: `package.json test script (${npmCommand.join(" ")})`,
152
+ id: "unit",
153
+ command: npmCommand,
154
+ }
155
+ : RUNNER_COMMANDS.find((entry) => entry.files.some((file) => existsSync(path.join(root, file))));
156
+ if (detected === undefined)
157
+ return null;
158
+ const id = overrideId ?? detected.id;
159
+ return {
160
+ runner: detected.runner,
161
+ integration: {
162
+ id,
163
+ producer: "command",
164
+ command: [...detected.command],
165
+ targets: ["default"],
166
+ description: `Command proof: runs ${detected.command.join(" ")} once per kibi prove and judges every selected test by its exit code.`,
167
+ },
168
+ contractDefaults: {
169
+ version: PROOF_CONTRACT_VERSION,
170
+ integration: id,
171
+ required_proofs: [{ symbol_id: "SYM-<symbol the test proves>", target: "default" }],
172
+ success_policy: "all_required_first_attempt",
173
+ },
174
+ };
175
+ }
176
+ function sha256(bytes) {
177
+ return createHash("sha256").update(bytes).digest("hex");
178
+ }
179
+ function fileHash(filePath) {
180
+ try {
181
+ return sha256(readFileSync(filePath));
182
+ }
183
+ catch {
184
+ return null;
185
+ }
186
+ }
187
+ function sourceHashes(root) {
188
+ const hashes = {};
189
+ for (const file of PROPOSAL_SOURCES) {
190
+ const hash = fileHash(path.join(root, file));
191
+ if (hash !== null)
192
+ hashes[file] = hash;
193
+ }
194
+ return hashes;
195
+ }
196
+ function readIntegrationsFile(root) {
197
+ try {
198
+ const parsed = JSON.parse(readFileSync(integrationsPath(root), "utf8"));
199
+ return proofIntegrationErrors(parsed).length === 0 ? parsed : null;
200
+ }
201
+ catch {
202
+ return null;
203
+ }
204
+ }
205
+ /**
206
+ * Build the hash-bound `kibi.migration-plan.v2` that writes
207
+ * `.kb/proof/integrations.json` through Kibi. Without `update`, a plan is
208
+ * produced only while the file does not exist; with `update` it adds or
209
+ * replaces the named integration of an existing, valid file. The plan carries the file's
210
+ * current hash and the hashes of the files the proposal was derived from;
211
+ * `kb_apply_plan` refuses it once either changed.
212
+ */
213
+ // implements REQ-kibi-verification-evidence-contract
214
+ export function buildProofIntegrationPlan(root, options = {}) {
215
+ const filePath = integrationsPath(root);
216
+ const exists = existsSync(filePath);
217
+ const update = options.update?.trim() || undefined;
218
+ if (exists && update === undefined) {
219
+ return {
220
+ plan: null,
221
+ proposal: null,
222
+ reason: `${PROOF_INTEGRATIONS_PATH} already exists; Kibi will not overwrite it. Run kibi proof inspect --update <integration id> for a plan that adds or replaces one named integration.`,
223
+ };
224
+ }
225
+ if (!exists && update !== undefined) {
226
+ return {
227
+ plan: null,
228
+ proposal: null,
229
+ reason: `${PROOF_INTEGRATIONS_PATH} does not exist yet. Run kibi proof inspect without --update for a plan that creates it.`,
230
+ };
231
+ }
232
+ if (update !== undefined && readIntegrationsFile(root) === null)
233
+ return {
234
+ plan: null,
235
+ proposal: null,
236
+ reason: `${PROOF_INTEGRATIONS_PATH} is not a valid ${PROOF_INTEGRATION_VERSION} file, so Kibi cannot update one integration in it. Run kibi prove for the validation error.`,
237
+ };
238
+ const proposal = proposeProofIntegration(root, update);
239
+ if (proposal === null) {
240
+ return {
241
+ plan: null,
242
+ proposal: null,
243
+ reason: "No test runner detected (no package.json test script and no known runner configuration), so Kibi has no command to propose. Proof integration stays deferred until the first proof-bearing test introduces a harness.",
244
+ };
245
+ }
246
+ const action = migrationAction({
247
+ id: `proof-integration-${proposal.integration.id}`,
248
+ code: PROOF_INTEGRATION_CONFIGURE,
249
+ category: "proof",
250
+ safety: "automatic",
251
+ autoApplicable: true,
252
+ invocation: {
253
+ kind: "review",
254
+ instruction: `Review the proposed ${proposal.integration.producer} integration '${proposal.integration.id}' (command: ${proposal.integration.command.join(" ")}), then apply this plan with kb_apply_plan (plan, approvedPlanHash, approvedActionIds) to ${update === undefined ? "create" : "update"} ${PROOF_INTEGRATIONS_PATH}.`,
255
+ },
256
+ affectedFiles: [PROOF_INTEGRATIONS_PATH],
257
+ evidence: {
258
+ path: PROOF_INTEGRATIONS_PATH,
259
+ mode: update === undefined ? "create" : "update",
260
+ integration: proposal.integration,
261
+ runner: proposal.runner,
262
+ contractDefaults: proposal.contractDefaults,
263
+ previousFileHash: update === undefined ? null : fileHash(filePath),
264
+ sourceHashes: sourceHashes(root),
265
+ },
266
+ postconditions: [
267
+ { file: PROOF_INTEGRATIONS_PATH, version: PROOF_INTEGRATION_VERSION },
268
+ ],
269
+ });
270
+ return {
271
+ plan: buildMigrationPlan({
272
+ evaluatedDomains: ["proof"],
273
+ actions: [action],
274
+ }),
275
+ proposal,
276
+ reason: `Applying the plan ${update === undefined ? "creates" : "updates"} ${PROOF_INTEGRATIONS_PATH} with the ${proposal.integration.producer} integration '${proposal.integration.id}' (${proposal.integration.command.join(" ")}). Proof-bearing tests then name it in proof_contract.integration and kibi prove runs it.`,
277
+ };
278
+ }
279
+ function isRecord(value) {
280
+ return value !== null && typeof value === "object" && !Array.isArray(value);
281
+ }
282
+ /**
283
+ * Apply one reviewed `proof_integration_configure` action: write
284
+ * `.kb/proof/integrations.json` (`kibi.proof-integration.v1`). A create is
285
+ * refused when the file exists; an update is refused unless the file still
286
+ * has the hash the plan was built against, and it adds or replaces only the
287
+ * named integration. Either is refused when
288
+ * a file the proposal was derived from changed since planning.
289
+ */
290
+ // implements REQ-kibi-verification-evidence-contract
291
+ export function applyProofIntegrationAction(action, root) {
292
+ const evidence = action.evidence;
293
+ const integration = evidence.integration;
294
+ if (evidence.path !== PROOF_INTEGRATIONS_PATH ||
295
+ (evidence.mode !== "create" && evidence.mode !== "update") ||
296
+ !isRecord(integration) ||
297
+ typeof integration.id !== "string")
298
+ throw new Error(`Proof integration action '${action.id}' is malformed; rerun kibi proof inspect for a new plan.`);
299
+ const planned = isRecord(evidence.sourceHashes) ? evidence.sourceHashes : {};
300
+ const live = sourceHashes(root);
301
+ const changed = [
302
+ ...new Set([...Object.keys(planned), ...Object.keys(live)]),
303
+ ].filter((file) => planned[file] !== live[file]);
304
+ if (changed.length > 0)
305
+ throw new Error(`Proof integration plan refused: ${changed.join(", ")} changed since planning; rerun kibi proof inspect and review the new plan.`);
306
+ const filePath = integrationsPath(root);
307
+ let integrations;
308
+ if (evidence.mode === "create") {
309
+ if (existsSync(filePath))
310
+ throw new Error(`Proof integration plan refused: ${PROOF_INTEGRATIONS_PATH} already exists and this plan only creates it. Run kibi proof inspect --update <integration id> for a plan that adds or replaces one named integration.`);
311
+ integrations = [integration];
312
+ }
313
+ else {
314
+ if (fileHash(filePath) !== evidence.previousFileHash)
315
+ throw new Error(`Proof integration plan refused: ${PROOF_INTEGRATIONS_PATH} changed since planning; rerun kibi proof inspect --update ${integration.id}.`);
316
+ const current = readIntegrationsFile(root);
317
+ if (current === null)
318
+ throw new Error(`Proof integration plan refused: ${PROOF_INTEGRATIONS_PATH} is not a valid ${PROOF_INTEGRATION_VERSION} file.`);
319
+ integrations = current.integrations.some((entry) => entry.id === integration.id)
320
+ ? current.integrations.map((entry) => entry.id === integration.id ? integration : entry)
321
+ : [...current.integrations, integration];
322
+ }
323
+ const file = { version: PROOF_INTEGRATION_VERSION, integrations };
324
+ const errors = proofIntegrationErrors(file);
325
+ if (errors.length > 0)
326
+ throw new Error(`Proof integration plan refused: the result would be invalid (${errors.join("; ")}).`);
327
+ mkdirSync(path.dirname(filePath), { recursive: true });
328
+ const temporary = `${filePath}.${process.pid}.tmp`;
329
+ writeFileSync(temporary, `${JSON.stringify(file, null, 2)}\n`, "utf8");
330
+ renameSync(temporary, filePath);
331
+ }
@@ -70,7 +70,7 @@ export function loadProofIntegrations(workspaceRoot) {
70
70
  if (!existsSync(filePath)) {
71
71
  return {
72
72
  available: false,
73
- error: `No proof integration configuration at ${PROOF_INTEGRATIONS_PATH}. Run bootstrap for this repository to configure proof producers.`,
73
+ error: `No proof integration configuration at ${PROOF_INTEGRATIONS_PATH}. Run kibi proof inspect --json and apply its integrationPlan with kb_apply_plan to configure one.`,
74
74
  };
75
75
  }
76
76
  let parsed;
@@ -572,7 +572,7 @@ export declare const OPERATION_CATALOG: readonly [{
572
572
  };
573
573
  readonly requirementId: {
574
574
  readonly type: "string";
575
- readonly description: "Optional existing requirement ID to receive the requires_rule relationship.";
575
+ readonly description: "Optional requirement ID. The strict write set updates this requirement instead of minting a REQ-AUTO id, and a typed logic rule attaches its requires_rule relationship to it.";
576
576
  };
577
577
  readonly claimKey: {
578
578
  readonly type: "string";
@@ -1732,7 +1732,7 @@ export declare const OPERATION_CATALOG: readonly [{
1732
1732
  readonly type: "string";
1733
1733
  readonly enum: readonly string[];
1734
1734
  };
1735
- readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
1735
+ readonly description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers. If omitted, server runs canonical and advisory rules plus the full-KB qualityDiagnostics audit scan, including usage telemetry acceptance when evidence exists; migration rules run only when explicitly selected. Advisory and migration findings are non-blocking qualityDiagnostics. If supplied, server preserves scoped validation and skips the full-KB advisory scan.";
1736
1736
  };
1737
1737
  readonly sourceFiles: {
1738
1738
  readonly type: "array";
@@ -1,3 +1,4 @@
1
+ import type { Violation } from "../check-types.js";
1
2
  import { type CheckDiagnostic, type CheckStructuredContent, buildStructuredContent, buildSummary } from "./check-format-shared.js";
2
3
  import { getEffectiveRules, resolveCheckRules } from "./check-helpers.js";
3
4
  import type { OperationContext } from "./runtime-types.js";
@@ -16,6 +17,21 @@ export type { CheckDiagnostic, CheckStructuredContent };
16
17
  export { buildStructuredContent, buildSummary, getEffectiveRules, resolveCheckRules, };
17
18
  export type CheckExecutionOptions = {
18
19
  readonly collectFullQualityDiagnosticsForExplicitRules?: boolean;
20
+ /**
21
+ * The engine reads the current branch's store although the context carries
22
+ * no branch attachment (the `kibi check` engine path). A context with a
23
+ * branch attachment (the CLI and MCP runtimes) implies it; without either,
24
+ * the attached store is unknown (an explicit --kb-path store or an injected
25
+ * test store) and the branch-store compilation check is skipped.
26
+ */
27
+ readonly branchStoreAttached?: boolean;
19
28
  };
29
+ /**
30
+ * The one finding for a branch whose store was never compiled while .kb/
31
+ * holds authored sources. Every store-backed rule would read an empty KB
32
+ * (source-relationship-parity alone reports each authored relationship as
33
+ * missing), so kb_check reports this instead of any of them.
34
+ */
35
+ export declare function uncompiledBranchStoreViolation(context: OperationContext, workspaceRoot: string): Violation | null;
20
36
  export declare function executeCheck(args: CheckInput, context: OperationContext, options?: CheckExecutionOptions): Promise<OperationResult<CheckPayload>>;
21
37
  //# sourceMappingURL=check-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-executor.d.ts","sourceRoot":"","sources":["../../../src/public/operations/check-executor.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAGL,iBAAiB,EAGjB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAW5B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AAMvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,CAAC;AACxD,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,6CA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AAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,6CAA6C,CAAC,EAAE,OAAO,CAAC;IACjE;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAoDF;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,MAAM,GACpB,SAAS,GAAG,IAAI,CAgClB;AAGD,wBAAsB,YAAY,CAChC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAgOxC"}
@@ -1,4 +1,6 @@
1
1
  import { runAggregatedChecks } from "../../commands/aggregated-checks.js";
2
+ import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
3
+ import { BRANCH_STORE_NOT_COMPILED_RULE, inspectBranchStore, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
2
4
  import { collectFullKbQualityDiagnostics } from "../impact-diagnostics.js";
3
5
  import { buildStructuredContent, buildSummary, } from "./check-format-shared.js";
4
6
  import { analyzeKbCheckImpact, collectQueryPlanSafetyViolations, getEffectiveRules, partitionCheckFindings, qualityDiagnosticsFromImpact, resolveCheckRules, stagedEntityIdStyleDiagnostics, } from "./check-helpers.js";
@@ -51,6 +53,44 @@ async function readStatusMigrationPlan(context) {
51
53
  throw error;
52
54
  }
53
55
  }
56
+ /**
57
+ * The one finding for a branch whose store was never compiled while .kb/
58
+ * holds authored sources. Every store-backed rule would read an empty KB
59
+ * (source-relationship-parity alone reports each authored relationship as
60
+ * missing), so kb_check reports this instead of any of them.
61
+ */
62
+ // implements REQ-cli-status-pre-first-sync
63
+ export function uncompiledBranchStoreViolation(context, workspaceRoot) {
64
+ let attachment;
65
+ try {
66
+ attachment =
67
+ context.branchAttachment ?? resolveBranchAttachment(workspaceRoot);
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ if ("error" in attachment)
73
+ return null;
74
+ const store = inspectBranchStore(workspaceRoot, attachment.kbBranch);
75
+ const reason = uncompiledBranchStoreReason(workspaceRoot, store, attachment.kbBranch);
76
+ if (reason === null)
77
+ return null;
78
+ return {
79
+ rule: BRANCH_STORE_NOT_COMPILED_RULE,
80
+ entityId: attachment.kbBranch,
81
+ description: String(reason.detail),
82
+ suggestion: "Run kibi sync to compile this branch's store from the authored .kb/ sources (or apply the branch-store-compile action of the returned migrationPlan with kb_apply_plan), then rerun kb_check. Run kibi init once to install the git hooks that compile a new branch on checkout.",
83
+ source: store.path,
84
+ evidence: {
85
+ store: { state: store.state, path: store.path },
86
+ authoredSources: reason.authoredSources,
87
+ ...(reason.generation !== undefined
88
+ ? { generation: reason.generation }
89
+ : {}),
90
+ remediation: reason.remediation,
91
+ },
92
+ };
93
+ }
54
94
  // implements REQ-kibi-operation-interface-parity, REQ-002
55
95
  export async function executeCheck(args, context, options = {}) {
56
96
  try {
@@ -73,6 +113,46 @@ export async function executeCheck(args, context, options = {}) {
73
113
  const maxDiagnosticsOption = args.maxDiagnostics !== undefined
74
114
  ? { maxDiagnostics: args.maxDiagnostics }
75
115
  : {};
116
+ const uncompiled = context.branchAttachment !== undefined ||
117
+ options.branchStoreAttached === true
118
+ ? uncompiledBranchStoreViolation(context, workspaceRoot)
119
+ : null;
120
+ if (uncompiled !== null) {
121
+ const violations = [uncompiled];
122
+ const statusPlan = await readStatusMigrationPlan(context);
123
+ const migrationPlan = await migrationPlanForCheck(context, violations, [], statusPlan);
124
+ return {
125
+ content: [
126
+ {
127
+ type: "text",
128
+ text: buildSummary({
129
+ violations,
130
+ impactResult,
131
+ qualityDiagnostics: [],
132
+ }),
133
+ },
134
+ ],
135
+ structuredContent: buildStructuredContent({
136
+ violations,
137
+ diagnostics: [
138
+ {
139
+ category: "SYNC_ERROR",
140
+ severity: "error",
141
+ message: uncompiled.description,
142
+ ...(uncompiled.source !== undefined
143
+ ? { file: uncompiled.source }
144
+ : {}),
145
+ ...(uncompiled.suggestion !== undefined
146
+ ? { suggestion: uncompiled.suggestion }
147
+ : {}),
148
+ },
149
+ ],
150
+ qualityDiagnostics: [],
151
+ impactResult,
152
+ migrationPlan,
153
+ }),
154
+ };
155
+ }
76
156
  if (rulesAllowlist.size === 0) {
77
157
  const qualityDiagnostics = hasExplicitRules &&
78
158
  options.collectFullQualityDiagnosticsForExplicitRules !== true
@@ -1 +1 @@
1
- {"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,KAAK,qBAAqB,EAI3B,MAAM,6BAA6B,CAAC;AASrC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAA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,EAAE,OAAO,CAAC;KACpC,CAAC;IACF,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,QAAQ,CACjD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB,EAAE,CAAC;QACJ,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACzD,CAAC;CACH,CAAC;AAqBF,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA2CxC;AAmDD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAgHzC;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CA6SzC"}
@@ -7,7 +7,7 @@ import { SwiplResolutionError } from "../../prolog/swipl-resolver.js";
7
7
  import { buildSearchAnswer } from "../../search-answer.js";
8
8
  import { rankEntities } from "../../search-ranking.js";
9
9
  import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
10
- import { branchStoreReason, inspectBranchStore, storeLockJournalReason, } from "../../utils/branch-store.js";
10
+ import { BRANCH_STORE_NOT_COMPILED, branchStoreReason, inspectBranchStore, storeLockJournalReason, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
11
11
  import { loadSearchCandidates, paginateResults, queryEntitiesViaQuery, reloadFullEntities, validateEntityType, } from "./discovery-entities.js";
12
12
  import { buildActionsFromStatus, readMigrationConfigStatus, } from "./migration-plan.js";
13
13
  import { OperationJsonDecodeError, runOperationJsonQuery, } from "./prolog-json.js";
@@ -273,7 +273,12 @@ export async function executeStatus(_input, context) {
273
273
  }
274
274
  const snapshotEvidence = await readWorkspaceSnapshot(context);
275
275
  const existingReasons = payload.staleReasons ?? [];
276
- const storeReason = branchStoreReason(store);
276
+ // implements REQ-cli-status-pre-first-sync
277
+ // A missing or empty store beside authored sources gets the one reason
278
+ // whose remediation works (kibi sync); `kibi branch ensure` alone would
279
+ // leave the store empty.
280
+ const storeReason = uncompiledBranchStoreReason(context.workspaceRoot, store, attachment.kbBranch) ?? branchStoreReason(store);
281
+ const storeUncompiled = storeReason?.code === BRANCH_STORE_NOT_COMPILED;
277
282
  const lockReason = storeLockJournalReason(store.path);
278
283
  const compilerReason = compilerFingerprintReason(store.path);
279
284
  const engineReason = engineStatus
@@ -306,6 +311,11 @@ export async function executeStatus(_input, context) {
306
311
  // Source hashes can all match while the compilation itself is lossy, so
307
312
  // a compiler contract change alone makes the store stale.
308
313
  ...(compilerReason ? { syncState: "stale", dirty: true } : {}),
314
+ // An empty store has no stale file to report, yet nothing in it is
315
+ // current: the authored sources were never compiled.
316
+ ...(storeUncompiled && store.state === "healthy"
317
+ ? { syncState: "stale", dirty: true }
318
+ : {}),
309
319
  branchAttachment: attachment,
310
320
  branchStore: store,
311
321
  ...(engineStatus ? { engineStatus } : {}),
@@ -437,7 +447,7 @@ export async function executeStatus(_input, context) {
437
447
  content: [
438
448
  {
439
449
  type: "text",
440
- text: `Branch ${payload.branch} is ${payload.syncState} (snapshot ${payload.snapshotId}, dirty=${payload.dirty}, proofSnapshot=${enrichedPayload.proofSnapshot})`,
450
+ text: `Branch ${payload.branch} is ${enrichedPayload.syncState} (snapshot ${payload.snapshotId}, dirty=${enrichedPayload.dirty}, proofSnapshot=${enrichedPayload.proofSnapshot})${storeUncompiled ? `. Blocking: ${String(storeReason?.detail)} Run kibi sync.` : ""}`,
441
451
  },
442
452
  ],
443
453
  structuredContent: statusWithPlan,
@@ -1 +1 @@
1
- {"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../../src/public/operations/migration-plan.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,sBAAsB,EAAG,wBAAiC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,SAAS,CAAC;AACvD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC1C,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEP,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EACJ,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WAAW,GACX,cAAc,GACd,QAAQ,GACR,UAAU,GACV,OAAO,GACP,SAAS,CAAC;IACd,KAAK,EAAE,oBAAoB,CAAC;IAC5B,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU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IACtB,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5D,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,GAAG,aAAa,CA+OhB"}
@@ -1,6 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import * as path from "node:path";
4
+ import { BRANCH_STORE_NOT_COMPILED } from "../../utils/branch-store.js";
4
5
  import { legacyConfigExists } from "../../utils/config.js";
5
6
  import { readKbManifestStatus } from "../../utils/kb-manifest.js";
6
7
  import { getSchemaVersionStatus, normalizeSchemaVersion, } from "../../utils/schema-version.js";
@@ -537,8 +538,35 @@ export function buildActionsFromStatus(input) {
537
538
  autoApplicable: configStatus.status !== "newer",
538
539
  }));
539
540
  }
541
+ // implements REQ-cli-status-pre-first-sync
542
+ // A branch store that was never compiled while .kb/ holds authored sources
543
+ // is fixed only by compiling it: `kibi branch ensure` alone leaves an empty
544
+ // manifest. The compile step runs after the store exists and after any
545
+ // schema migration, so it compiles the migrated sources.
546
+ const uncompiled = (input.staleReasons ?? []).find((reason) => reason.code === BRANCH_STORE_NOT_COMPILED);
547
+ if (uncompiled !== undefined) {
548
+ actions.push(migrationAction({
549
+ id: "branch-store-compile",
550
+ code: BRANCH_STORE_NOT_COMPILED,
551
+ category: "storage",
552
+ safety: "automatic",
553
+ invocation: { kind: "cli", command_argv: ["kibi", "sync"] },
554
+ affectedFiles: [
555
+ typeof store?.path === "string" ? store.path : ".kb/branches",
556
+ ],
557
+ evidence: { reason: uncompiled },
558
+ dependsOn: actions
559
+ .map((action) => action.id)
560
+ .filter((id) => id === "branch-store-ensure" || id === "schema-config-upgrade"),
561
+ postconditions: [{ branchStore: "compiled" }],
562
+ autoApplicable: true,
563
+ }));
564
+ }
540
565
  for (const reason of input.staleReasons ?? []) {
541
566
  const code = typeof reason.code === "string" ? reason.code : "stale_source";
567
+ // Planned above as an automatic compile step, not a review.
568
+ if (code === BRANCH_STORE_NOT_COMPILED)
569
+ continue;
542
570
  const file = typeof reason.path === "string" ? reason.path : "";
543
571
  actions.push(migrationAction({
544
572
  id: `freshness-${code}-${file}`,
@@ -1,5 +1,5 @@
1
1
  /** Every selectable kb_check rule name, registry order. */
2
2
  export declare const SELECTABLE_RULE_NAMES: readonly string[];
3
3
  /** Comma-separated "Allowed:" fragment for the kb_check rules description. */
4
- export declare const SELECTABLE_RULES_ALLOWED = "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers";
4
+ export declare const SELECTABLE_RULES_ALLOWED = "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, branch-store-not-compiled, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, related-requirement-unmodeled, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance, entity-context-missing, entity-context-acknowledged, policy-ownership, policy-markers";
5
5
  //# sourceMappingURL=check-rules.generated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-rules.generated.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/check-rules.generated.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EA+ClD,CAAC;AAGF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,ggCAC09B,CAAC"}
1
+ {"version":3,"file":"check-rules.generated.d.ts","sourceRoot":"","sources":["../../../../src/public/operations/specs/check-rules.generated.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAgDlD,CAAC;AAGF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,2hCACq/B,CAAC"}