kibi-cli 2.32.0 → 2.36.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 (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
@@ -0,0 +1,164 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { spawnSync } from "node:child_process";
19
+ import { existsSync } from "node:fs";
20
+ import path from "node:path";
21
+ /**
22
+ * How Kibi runs a small evaluator script against the workspace's own code:
23
+ * the TypeScript and JavaScript runners (bun, the workspace's tsx, node with
24
+ * type stripping) and the Python interpreters a project uses. The proof kinds
25
+ * that read a model from the code (exhaustive domains, rule tables, state
26
+ * machines, patterns, data schemas, route tables) all load code this way.
27
+ */
28
+ // Node's type stripping resolves only exact specifiers. TypeScript apps
29
+ // import relative modules without an extension, or with `.js` for a `.ts`
30
+ // file; this resolve hook retries those as the TypeScript files they name.
31
+ export const TS_RESOLVE_HOOKS = `
32
+ const SUFFIXES = [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", "/index.ts", "/index.tsx", "/index.js"];
33
+ export async function resolve(specifier, context, next) {
34
+ try {
35
+ return await next(specifier, context);
36
+ } catch (error) {
37
+ if (error?.code !== "ERR_MODULE_NOT_FOUND" || !/^\\.\\.?\\//.test(specifier)) throw error;
38
+ const base = specifier.replace(/\\.[cm]?js$/, "");
39
+ for (const suffix of SUFFIXES) {
40
+ try {
41
+ return await next(base + suffix, context);
42
+ } catch {}
43
+ }
44
+ throw error;
45
+ }
46
+ }
47
+ `;
48
+ export function workspaceBin(workspaceRoot, name) {
49
+ let dir = path.resolve(workspaceRoot);
50
+ for (;;) {
51
+ const candidate = path.join(dir, "node_modules", ".bin", name);
52
+ if (existsSync(candidate))
53
+ return candidate;
54
+ if (path.dirname(dir) === dir)
55
+ return null;
56
+ dir = path.dirname(dir);
57
+ }
58
+ }
59
+ /**
60
+ * The Python interpreters a domain loads with, most specific first: the
61
+ * KIBI_PYTHON override, the active virtualenv, a project virtualenv (`.venv`
62
+ * or `venv`) between the domain file and the workspace root, then python3
63
+ * and python on PATH. The system interpreter usually cannot import the
64
+ * project's dependencies, so a project environment comes before it.
65
+ */
66
+ // implements REQ-kibi-code-proof-kinds
67
+ export function pythonDomainInterpreters(workspaceRoot, sourceFile, env = process.env) {
68
+ const interpreters = [];
69
+ const add = (candidate) => {
70
+ if (candidate && !interpreters.includes(candidate))
71
+ interpreters.push(candidate);
72
+ };
73
+ add(env.KIBI_PYTHON?.trim() || undefined);
74
+ const venvPython = (venv) => [
75
+ path.join(venv, "bin", "python"),
76
+ path.join(venv, "Scripts", "python.exe"),
77
+ ].find((candidate) => existsSync(candidate));
78
+ if (env.VIRTUAL_ENV)
79
+ add(venvPython(env.VIRTUAL_ENV));
80
+ const root = path.resolve(workspaceRoot);
81
+ let dir = path.dirname(path.resolve(root, sourceFile));
82
+ for (;;) {
83
+ for (const name of [".venv", "venv"])
84
+ add(venvPython(path.join(dir, name)));
85
+ if (dir === root || path.dirname(dir) === dir)
86
+ break;
87
+ if (!dir.startsWith(`${root}${path.sep}`))
88
+ break;
89
+ dir = path.dirname(dir);
90
+ }
91
+ add("python3");
92
+ add("python");
93
+ return interpreters;
94
+ }
95
+ /** The line of a runner's stderr that names the failure. */
96
+ function failureLine(stderr, python) {
97
+ const lines = stderr
98
+ .trim()
99
+ .split("\n")
100
+ .map((line) => line.trim())
101
+ .filter((line) => line !== "");
102
+ // A Python traceback names the exception on its last line.
103
+ return (python ? lines.at(-1) : lines[0]) ?? "";
104
+ }
105
+ /**
106
+ * Run an evaluator script against the workspace code and return the JSON it
107
+ * prints last. A TypeScript or JavaScript file runs with bun when it is on
108
+ * PATH, else the workspace's tsx, else node's type stripping (which retries
109
+ * extensionless relative imports as TypeScript files); a Python file (`.py`)
110
+ * runs with the first interpreter pythonDomainInterpreters finds. A runner
111
+ * whose output `accept` rejects (or that fails to start) yields to the next.
112
+ */
113
+ // implements REQ-kibi-non-numeric-proof-kinds
114
+ export function runCodeEvaluator(workspaceRoot, sourceFile, scripts, args, accept = () => true, options = {}) {
115
+ const python = /\.py$/i.test(sourceFile);
116
+ const tsx = python ? null : workspaceBin(workspaceRoot, "tsx");
117
+ const runners = python
118
+ ? pythonDomainInterpreters(workspaceRoot, sourceFile).map((interpreter) => [
119
+ interpreter,
120
+ ["-c", scripts.python],
121
+ ])
122
+ : (options.runners ?? ["bun", "tsx", "node"]).flatMap((runner) => {
123
+ if (runner === "bun")
124
+ return [["bun", ["-e", scripts.js]]];
125
+ if (runner === "tsx")
126
+ return tsx === null
127
+ ? []
128
+ : [[tsx, ["--eval", scripts.js, "--"]]];
129
+ return [
130
+ [
131
+ process.execPath,
132
+ [
133
+ "--experimental-strip-types",
134
+ "--no-warnings",
135
+ "--input-type=module",
136
+ "-e",
137
+ scripts.js,
138
+ ],
139
+ ],
140
+ ];
141
+ });
142
+ let failure = "";
143
+ for (const [command, argv] of runners) {
144
+ const run = spawnSync(command, [...argv, ...args], {
145
+ cwd: workspaceRoot,
146
+ encoding: "utf8",
147
+ timeout: 60_000,
148
+ maxBuffer: 64 * 1024 * 1024,
149
+ });
150
+ if (run.error)
151
+ continue;
152
+ const line = (run.stdout ?? "").trim().split("\n").pop() ?? "";
153
+ try {
154
+ const parsed = JSON.parse(line);
155
+ if (accept(parsed))
156
+ return { ok: true, value: parsed, python };
157
+ }
158
+ catch {
159
+ // Fall through to the next runner.
160
+ }
161
+ failure = failureLine(run.stderr ?? "", python);
162
+ }
163
+ return { ok: false, failure, python };
164
+ }
@@ -1,4 +1,5 @@
1
1
  import type { PrologPort } from "../../public/operations/runtime-types.js";
2
+ import { type SourceSpec } from "../../public/proof-sources.js";
2
3
  import { type ProofContract } from "../../public/proof-protocol.js";
3
4
  /**
4
5
  * Which symbols a proof receipt's per-contract binding covers. Receipt ingest
@@ -22,6 +23,8 @@ export declare function loadCoveredBySymbolsByTest(prolog: Pick<PrologPort, "que
22
23
  * make every receipt of that test silently fall back to snapshot matching.
23
24
  */
24
25
  export declare function receiptBindingContract(raw: unknown): ProofContract | null;
26
+ /** Every project source a contract reads: its source, source counts and source domains. */
27
+ export declare function contractSources(contract: ProofContract): SourceSpec[];
25
28
  export type ReceiptBindingInput = Readonly<{
26
29
  workspaceRoot: string;
27
30
  readFile: (absolutePath: string) => Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"code-scope.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/code-scope.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,gCAAgC,CAAC;AAKxC;;;;;;;;;;;GAWG;AAEH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,gBAAgB,EAAE,SAAS,MAAM,EAAE,GAClC,MAAM,EAAE,CAoBV;AAED,4EAA4E;AAE5E,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAiBjD;AAQD;;;;;GAKG;AAEH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAmBzE;AAGD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,2EAA2E;IAC3E,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AAEH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7B;AAED;;;;;;;;GAQG;AAEH,wBAAsB,2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AC7C,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7B;AAED;;;;;;;;GAQG;AAEH,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC,CAuCxC"}
@@ -11,6 +11,7 @@ import { join } from "node:path";
11
11
  import { resolveBoundSymbolScope } from "../../extractors/manifest.js";
12
12
  import { normalizeEntityId, parseTriples } from "../../prolog/codec.js";
13
13
  import { receiptBindingHash } from "../../public/proof-fingerprint.js";
14
+ import { sourceDependencies } from "../../public/proof-sources.js";
14
15
  import { optionalProofContractFields, } from "../../public/proof-protocol.js";
15
16
  import { normalizeRepoRelativePath } from "../../utils/repo-relative-path.js";
16
17
  import { resolveContainedSourcePath } from "../mutation/source-authoring.js";
@@ -98,6 +99,20 @@ export function receiptBindingContract(raw) {
98
99
  ...optionalProofContractFields(contract),
99
100
  };
100
101
  }
102
+ /** Every project source a contract reads: its source, source counts and source domains. */
103
+ // implements REQ-kibi-source-proof-kinds
104
+ export function contractSources(contract) {
105
+ const specs = [];
106
+ if (contract.source !== undefined)
107
+ specs.push(contract.source);
108
+ for (const entry of contract.value_source ?? [])
109
+ if ("source" in entry)
110
+ specs.push(entry.source);
111
+ for (const entry of Object.values(contract.domains ?? {}))
112
+ if ("source" in entry)
113
+ specs.push(entry.source);
114
+ return specs;
115
+ }
101
116
  /**
102
117
  * The current per-contract binding hash of one proof-bearing test, or
103
118
  * undefined when the test has no markdown source the binding can hash.
@@ -140,8 +155,17 @@ export async function currentReceiptBindingHashes(input) {
140
155
  const withoutReceipts = removeFrontmatterBlock(authored, "proof_receipts") ?? authored;
141
156
  const withoutLinks = removeFrontmatterBlock(withoutReceipts, "links") ?? withoutReceipts;
142
157
  const codeScope = resolveBoundSymbolScope(join(input.workspaceRoot, ".kb", "symbols.yaml"), receiptCodeScopeSymbolIds(contract, input.test.proof_bindings, input.coveredBySymbols));
143
- const current = receiptBindingHash(contract, withoutLinks, codeScope);
144
- const legacy = receiptBindingHash(contract, withoutReceipts, codeScope);
158
+ // A contract that reads project sources stales when what it reads
159
+ // changes: each file's contents and the set of files a glob matches.
160
+ const scope = [
161
+ ...codeScope,
162
+ ...contractSources(contract).flatMap((spec) => sourceDependencies(input.workspaceRoot, spec).map((dependency) => ({
163
+ symbolId: dependency.id,
164
+ sourceHash: dependency.hash,
165
+ }))),
166
+ ];
167
+ const current = receiptBindingHash(contract, withoutLinks, scope);
168
+ const legacy = receiptBindingHash(contract, withoutReceipts, scope);
145
169
  return legacy === current ? [current] : [current, legacy];
146
170
  }
147
171
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"ingest-proof.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/ingest-proof.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAkBjF,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,+BAA+B,CAAC;AAoBvC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,I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,CACtC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAuC5B"}
@@ -14,7 +14,7 @@ import { executeUpsert } from "../mutation/upsert.js";
14
14
  import { acquireWorkspaceMutationLock, releaseWorkspaceMutationLock, } from "../mutation/workspace-mutation-lock.js";
15
15
  import { MutationRollbackFailureError } from "../mutation/saga.js";
16
16
  import { patchReceiptsIntoDocument } from "./receipt-document.js";
17
- import { judgeClaimBindings } from "./claim-bindings.js";
17
+ import { judgeClaimBindings, receiptEvidenceLevel } from "./claim-bindings.js";
18
18
  import { checkCodeCertificate } from "./code-certificates.js";
19
19
  async function rollbackUncommittedReceipts(pending, originalError, lifecycle) {
20
20
  const failures = [];
@@ -297,6 +297,7 @@ async function executeIngestProofUnlocked(args, context, lifecycle) {
297
297
  })),
298
298
  ...(evaluation.gaps.length > 0 ? { gaps: evaluation.gaps } : {}),
299
299
  ...verdict,
300
+ evidence_level: receiptEvidenceLevel(verdict.evidence_level, claimBindings),
300
301
  ...(claimBindings !== undefined ? { claim_bindings: claimBindings } : {}),
301
302
  };
302
303
  prepared.push({
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Exact decisions about the languages of regular expressions, for the regex
3
+ * proof kind. A pattern is parsed into a regular expression over UTF-16 code
4
+ * units, compiled to an NFA, and compared with another by exploring the
5
+ * product of their lazily determinized automata. Every answer is a decision,
6
+ * not a sample: two patterns are equivalent only when no string tells them
7
+ * apart, and a "no" comes with the shortest string that does.
8
+ *
9
+ * Only the regular part of the syntax is accepted. Backreferences,
10
+ * lookaround, word boundaries, inline flags, Unicode property escapes and the
11
+ * stateful or line-based flags (g, y, m, v; Python MULTILINE, VERBOSE,
12
+ * LOCALE) are refused with a reason, so a pattern Kibi cannot model exactly
13
+ * never earns an answer.
14
+ *
15
+ * Strings are well-formed UTF-16 text: every string Kibi compares is a
16
+ * sequence of Unicode scalar values (no lone surrogates). A JavaScript
17
+ * pattern without the u flag still works on code units, so it may match half
18
+ * of a surrogate pair inside such a string, and that is modeled.
19
+ */
20
+ /** Which engine's syntax and semantics a pattern follows. */
21
+ export type RegexFlavor = "js" | "python";
22
+ /** How a pattern is applied to a string. */
23
+ export type MatchMode =
24
+ /** RegExp.prototype.test and Python re.search: a match anywhere counts. */
25
+ "search"
26
+ /** The whole string must match (a fact's pattern). */
27
+ | "full";
28
+ /** A pattern as a language: its source, flags, flavor and how it is applied. */
29
+ export type PatternSpec = Readonly<{
30
+ source: string;
31
+ flags?: string;
32
+ flavor: RegexFlavor;
33
+ mode: MatchMode;
34
+ }>;
35
+ /** A language Kibi can compare: a pattern, or exactly one string. */
36
+ export type LanguageSpec = (PatternSpec & {
37
+ type: "pattern";
38
+ }) | Readonly<{
39
+ type: "literal";
40
+ value: string;
41
+ }>;
42
+ type Interval = readonly [number, number];
43
+ type Ranges = Interval[];
44
+ /** A pattern Kibi refuses to model; the message says why. */
45
+ export declare class UnsupportedPattern extends Error {
46
+ }
47
+ type Edge = Readonly<{
48
+ type: "eps";
49
+ to: number;
50
+ }> | Readonly<{
51
+ type: "units";
52
+ ranges: Ranges;
53
+ to: number;
54
+ }> | Readonly<{
55
+ type: "assert";
56
+ kind: "bol" | "eol" | "eolnl";
57
+ to: number;
58
+ }>;
59
+ declare class Nfa {
60
+ readonly edges: Edge[][];
61
+ state(): number;
62
+ add(from: number, edge: Edge): void;
63
+ }
64
+ type Compiled = Readonly<{
65
+ nfa: Nfa;
66
+ start: number;
67
+ accept: number;
68
+ mode: MatchMode;
69
+ }>;
70
+ /** Compile a language to an NFA over UTF-16 code units, or refuse it. */
71
+ export declare function compileLanguage(spec: LanguageSpec): Compiled;
72
+ /** What Kibi decided about two languages. */
73
+ export type LanguageDecision = Readonly<{
74
+ holds: true;
75
+ }> | Readonly<{
76
+ holds: false;
77
+ witness: string;
78
+ reason: string;
79
+ }>;
80
+ /** Whether two languages hold exactly the same strings. */
81
+ export declare function languagesEqual(left: LanguageSpec, right: LanguageSpec): LanguageDecision;
82
+ /** Whether no string is in both languages. */
83
+ export declare function languagesDisjoint(left: LanguageSpec, right: LanguageSpec): LanguageDecision;
84
+ /** Whether every string of `left` is in `right`. */
85
+ export declare function languageIncluded(left: LanguageSpec, right: LanguageSpec): LanguageDecision;
86
+ /** Whether a language holds `text` (a well-formed string). */
87
+ export declare function languageAccepts(spec: LanguageSpec, text: string): boolean;
88
+ export {};
89
+ //# sourceMappingURL=regular-language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regular-language.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/regular-language.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,6DAA6D;AAE7D,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE1C,4CAA4C;AAE5C,MAAM,MAAM,SAAS;AACnB,2EAA2E;AACzE,QAAQ;AACV,sDAAsD;GACpD,MAAM,CAAC;AAEX,gFAAgF;AAEhF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC,CAAC;AAEH,qEAAqE;AAErE,MAAM,MAAM,YAAY,GACpB,CAAC,WAAW,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,GACnC,QAAQ,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjD,KAAK,QAAQ,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,KAAK,MAAM,GAAG,QAAQ,EAAE,CAAC;AAOzB,6DAA6D;AAC7D,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAmjBhD,KAAK,IAAI,GACL,QAAQ,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAA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