kibi-cli 2.31.0 → 2.32.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.
- package/dist/cli-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +19 -7
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +2 -0
- package/dist/commands/check.d.ts +1 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +14 -5
- package/dist/commands/discovery-table.d.ts.map +1 -1
- package/dist/commands/discovery-table.js +51 -4
- package/dist/commands/doctor.js +19 -4
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +89 -3
- package/dist/commands/prove.d.ts +48 -1
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +293 -8
- package/dist/commands/report.d.ts +1 -0
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +70 -5
- package/dist/commands/signoff.d.ts.map +1 -1
- package/dist/commands/signoff.js +21 -2
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +20 -4
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +16 -5
- package/dist/diagnostics.js +1 -1
- package/dist/engine.js +1 -1
- package/dist/extractors/markdown.d.ts +3 -1
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +17 -0
- package/dist/operations/bootstrap/candidate-helpers.d.ts +3 -0
- package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidate-helpers.js +4 -0
- package/dist/operations/migration/evidence-floor.d.ts +41 -0
- package/dist/operations/migration/evidence-floor.d.ts.map +1 -0
- package/dist/operations/migration/evidence-floor.js +230 -0
- package/dist/operations/migration/proof-contract-claims.d.ts +59 -0
- package/dist/operations/migration/proof-contract-claims.d.ts.map +1 -0
- package/dist/operations/migration/proof-contract-claims.js +182 -0
- package/dist/operations/migration/schema6.d.ts +6 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +94 -0
- package/dist/operations/mutation/omitted-properties.d.ts +11 -0
- package/dist/operations/mutation/omitted-properties.d.ts.map +1 -0
- package/dist/operations/mutation/omitted-properties.js +76 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +1 -0
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +6 -2
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +5 -3
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +7 -1
- package/dist/operations/mutation/validation.d.ts +2 -0
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +4 -0
- package/dist/operations/proof/claim-bindings.d.ts +23 -0
- package/dist/operations/proof/claim-bindings.d.ts.map +1 -0
- package/dist/operations/proof/claim-bindings.js +211 -0
- package/dist/operations/proof/code-certificates.d.ts +135 -0
- package/dist/operations/proof/code-certificates.d.ts.map +1 -0
- package/dist/operations/proof/code-certificates.js +785 -0
- package/dist/operations/proof/code-scope.d.ts +11 -1
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +20 -2
- package/dist/operations/proof/compact-receipts.d.ts.map +1 -1
- package/dist/operations/proof/compact-receipts.js +4 -3
- package/dist/operations/proof/explain.d.ts +32 -0
- package/dist/operations/proof/explain.d.ts.map +1 -1
- package/dist/operations/proof/explain.js +91 -0
- package/dist/operations/proof/ingest-proof.d.ts +9 -1
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +41 -2
- package/dist/operations/proof/receipt-compaction.d.ts +2 -0
- package/dist/operations/proof/receipt-compaction.d.ts.map +1 -1
- package/dist/operations/proof/receipt-compaction.js +6 -2
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/shared.js +4 -0
- package/dist/operations/semantic-advisor/strict-rules.js +3 -3
- package/dist/operations/semantic-advisor/types.d.ts +2 -1
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/plugins/approved-source-analyzers.generated.d.ts +6 -6
- package/dist/plugins/approved-source-analyzers.generated.js +6 -6
- package/dist/proof/command-test-report.d.ts +4 -3
- package/dist/proof/command-test-report.d.ts.map +1 -1
- package/dist/proof/command-test-report.js +4 -10
- package/dist/proof/evaluate.d.ts.map +1 -1
- package/dist/proof/evaluate.js +18 -2
- package/dist/proof/inspect.d.ts.map +1 -1
- package/dist/proof/inspect.js +58 -0
- package/dist/proof/producers/playwright-reporter.d.ts +3 -0
- package/dist/proof/producers/playwright-reporter.d.ts.map +1 -1
- package/dist/proof/producers/playwright-reporter.js +25 -2
- package/dist/proof/step-runner.d.ts +36 -0
- package/dist/proof/step-runner.d.ts.map +1 -0
- package/dist/proof/step-runner.js +234 -0
- package/dist/public/evidence-levels.d.ts +12 -0
- package/dist/public/evidence-levels.d.ts.map +1 -0
- package/dist/public/evidence-levels.js +19 -0
- package/dist/public/impact/coverage-depth-quality.d.ts +7 -0
- package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
- package/dist/public/impact/coverage-depth-quality.js +59 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +3 -1
- package/dist/public/operations/catalog.d.ts +167 -6
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts +2 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +6 -0
- package/dist/public/operations/evidence-floor.d.ts +48 -0
- package/dist/public/operations/evidence-floor.d.ts.map +1 -0
- package/dist/public/operations/evidence-floor.js +143 -0
- package/dist/public/operations/migration-plan.d.ts +19 -5
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +22 -5
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +4 -1
- package/dist/public/operations/proof-contract-claims.d.ts +26 -0
- package/dist/public/operations/proof-contract-claims.d.ts.map +1 -0
- package/dist/public/operations/proof-contract-claims.js +71 -0
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +3 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +157 -5
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +15 -2
- package/dist/public/operations/specs/proof.d.ts +9 -0
- package/dist/public/operations/specs/proof.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +19 -10
- package/dist/public/operations/specs/upsert.d.ts +157 -5
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/proof-certificates.d.ts +89 -0
- package/dist/public/proof-certificates.d.ts.map +1 -0
- package/dist/public/proof-certificates.js +207 -0
- package/dist/public/proof-protocol.d.ts +126 -3
- package/dist/public/proof-protocol.d.ts.map +1 -1
- package/dist/public/proof-protocol.js +239 -3
- package/dist/public/proof-receipt.d.ts +89 -6
- package/dist/public/proof-receipt.d.ts.map +1 -1
- package/dist/public/proof-receipt.js +83 -7
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +18 -1
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-commit-review/SKILL.md +4 -3
- package/dist/public/skills/kibi-commit-review/resources/staged-gate.md +6 -1
- package/dist/public/skills/kibi-decisions/SKILL.md +10 -2
- package/dist/public/skills/kibi-decisions/resources/decision-records.md +6 -1
- package/dist/public/skills/kibi-decisions/resources/signoff-views.md +3 -2
- package/dist/public/skills/kibi-freshness/SKILL.md +5 -1
- package/dist/public/skills/kibi-traceability/SKILL.md +11 -1
- package/dist/public/skills/kibi-usage/SKILL.md +6 -4
- package/dist/public/skills/kibi-usage/resources/proof.md +124 -19
- package/dist/public/skills/kibi-usage/resources/workflows.md +4 -4
- package/dist/report/html-report.css +38 -1
- package/dist/report/html-report.d.ts +8 -0
- package/dist/report/html-report.d.ts.map +1 -1
- package/dist/report/html-report.js +141 -6
- package/dist/report/report-view.d.ts +1 -1
- package/dist/report/report-view.d.ts.map +1 -1
- package/dist/report/report-view.js +7 -0
- package/dist/schemas/entity.schema.json +212 -4
- package/dist/search-answer.d.ts.map +1 -1
- package/dist/search-answer.js +1 -0
- package/dist/signoff/html.d.ts.map +1 -1
- package/dist/signoff/html.js +3 -0
- package/dist/signoff/markdown.d.ts.map +1 -1
- package/dist/signoff/markdown.js +3 -0
- package/dist/signoff/model.d.ts +20 -0
- package/dist/signoff/model.d.ts.map +1 -1
- package/dist/signoff/model.js +20 -1
- package/dist/traceability/impact-knowledge.d.ts.map +1 -1
- package/dist/traceability/impact-knowledge.js +1 -0
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +1 -0
- package/dist/types/entities.d.ts +4 -1
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/merge-driver-setup.d.ts +8 -1
- package/dist/utils/merge-driver-setup.d.ts.map +1 -1
- package/dist/utils/merge-driver-setup.js +23 -2
- package/dist/utils/rule-registry.generated.d.ts +10 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +12 -0
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.d.ts.map +1 -1
- package/dist/utils/schema-version.js +5 -1
- package/package.json +6 -2
- package/schema/entities.pl +6 -0
- package/schema/validation.pl +4 -1
- package/src/public/evidence-levels.ts +23 -0
- package/src/public/impact/coverage-depth-quality.ts +73 -0
- package/src/public/impact/full-kb-quality.ts +6 -1
- package/src/public/operations/check-executor.ts +13 -0
- package/src/public/operations/evidence-floor.ts +203 -0
- package/src/public/operations/migration-plan.ts +39 -6
- package/src/public/operations/node-ports.ts +3 -1
- package/src/public/operations/proof-contract-claims.ts +103 -0
- package/src/public/operations/specs/check-rules.generated.ts +3 -1
- package/src/public/operations/specs/mutation-schemas.ts +17 -2
- package/src/public/operations/specs/reporting.ts +20 -10
- package/src/public/proof-certificates.ts +271 -0
- package/src/public/proof-protocol-types.d.ts +17 -1
- package/src/public/proof-protocol.ts +318 -3
- package/src/public/proof-receipt.ts +127 -7
- package/src/public/schemas/entity.ts +19 -1
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-commit-review/SKILL.md +4 -3
- package/src/public/skills/kibi-commit-review/resources/staged-gate.md +6 -1
- package/src/public/skills/kibi-decisions/SKILL.md +10 -2
- package/src/public/skills/kibi-decisions/resources/decision-records.md +6 -1
- package/src/public/skills/kibi-decisions/resources/signoff-views.md +3 -2
- package/src/public/skills/kibi-freshness/SKILL.md +5 -1
- package/src/public/skills/kibi-traceability/SKILL.md +11 -1
- package/src/public/skills/kibi-usage/SKILL.md +6 -4
- package/src/public/skills/kibi-usage/resources/proof.md +124 -19
- package/src/public/skills/kibi-usage/resources/workflows.md +4 -4
- package/src/schemas/entity.schema.json +212 -4
- package/dist/commands/proof-impact.d.ts +0 -7
- package/dist/commands/proof-impact.d.ts.map +0 -1
- package/dist/commands/proof-impact.js +0 -39
- package/dist/operations/proof/baseline-diff.d.ts +0 -41
- package/dist/operations/proof/baseline-diff.d.ts.map +0 -1
- package/dist/operations/proof/baseline-diff.js +0 -153
- package/dist/operations/proof/impact.d.ts +0 -51
- package/dist/operations/proof/impact.d.ts.map +0 -1
- package/dist/operations/proof/impact.js +0 -138
|
@@ -0,0 +1,182 @@
|
|
|
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 path from "node:path";
|
|
19
|
+
import { isDeepStrictEqual } from "node:util";
|
|
20
|
+
import { load as loadYaml } from "js-yaml";
|
|
21
|
+
import { readAuthoredEntity } from "../../public/operations/entity-context.js";
|
|
22
|
+
import { listLaneMarkdownFiles, readText, sliceFrontmatter, writeFileAtomically, } from "./kb-sources.js";
|
|
23
|
+
/** Schema 12: pin proves on a certificate contract with one provable claim. */
|
|
24
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
25
|
+
export const PROOF_CONTRACT_CLAIMS_PIN_CODE = "proof_contract_claims_pin";
|
|
26
|
+
/** Schema 12: certificate contracts a person must bind to their claims. */
|
|
27
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
28
|
+
export const PROOF_CONTRACT_CLAIMS_REVIEW_CODE = "proof_contract_claims_review";
|
|
29
|
+
function isRecord(value) {
|
|
30
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Add proves to a test's proof_contract block, leaving every other byte of
|
|
34
|
+
* the document unchanged: the list goes after the block's last line, at the
|
|
35
|
+
* indentation of its other keys. Returns null when the contract is not a
|
|
36
|
+
* block mapping, already names proves, or the edit would not read back as
|
|
37
|
+
* exactly that change.
|
|
38
|
+
*/
|
|
39
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
40
|
+
export function withProofContractProves(content, keys) {
|
|
41
|
+
const slice = sliceFrontmatter(content);
|
|
42
|
+
if (slice === null || keys.length === 0)
|
|
43
|
+
return null;
|
|
44
|
+
const lines = slice.text.split(/(?<=\n)/);
|
|
45
|
+
const start = lines.findIndex((line) => /^proof_contract:[ \t]*\r?\n$/.test(line));
|
|
46
|
+
if (start < 0)
|
|
47
|
+
return null;
|
|
48
|
+
let end = start + 1;
|
|
49
|
+
let indent = null;
|
|
50
|
+
while (end < lines.length) {
|
|
51
|
+
const line = lines[end] ?? "";
|
|
52
|
+
const leading = /^([ \t]+)\S/.exec(line);
|
|
53
|
+
if (leading === null)
|
|
54
|
+
break;
|
|
55
|
+
if (indent === null)
|
|
56
|
+
indent = leading[1] ?? "";
|
|
57
|
+
end += 1;
|
|
58
|
+
}
|
|
59
|
+
if (indent === null)
|
|
60
|
+
return null;
|
|
61
|
+
const inserted = [
|
|
62
|
+
`${indent}proves:${slice.eol}`,
|
|
63
|
+
...keys.map((key) => `${indent}${indent}- ${key}${slice.eol}`),
|
|
64
|
+
];
|
|
65
|
+
const text = [...lines.slice(0, end), ...inserted, ...lines.slice(end)].join("");
|
|
66
|
+
try {
|
|
67
|
+
const before = loadYaml(slice.text);
|
|
68
|
+
const next = loadYaml(text);
|
|
69
|
+
if (!isRecord(before) || !isRecord(next))
|
|
70
|
+
return null;
|
|
71
|
+
const contract = before.proof_contract;
|
|
72
|
+
if (!isRecord(contract) || contract.proves !== undefined)
|
|
73
|
+
return null;
|
|
74
|
+
const expected = {
|
|
75
|
+
...before,
|
|
76
|
+
proof_contract: { ...contract, proves: [...keys] },
|
|
77
|
+
};
|
|
78
|
+
if (!isDeepStrictEqual(next, expected))
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return `${slice.prefix}${text}${slice.suffix}`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Certificate-kind contracts without proves, judged on the synced store: a
|
|
88
|
+
* contract whose test reaches exactly one claim its kind can derive an
|
|
89
|
+
* obligation for gets that claim pinned in proves; any other is left for a
|
|
90
|
+
* person to bind (review). Read-only.
|
|
91
|
+
*/
|
|
92
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
93
|
+
export function planProofContractClaimPins(workspaceRoot, rows) {
|
|
94
|
+
const byTest = new Map((rows ?? []).map((row) => [row.test_id, row]));
|
|
95
|
+
const targets = [];
|
|
96
|
+
const review = [];
|
|
97
|
+
const skipped = [];
|
|
98
|
+
if (byTest.size === 0)
|
|
99
|
+
return { targets, review, skipped };
|
|
100
|
+
for (const file of listLaneMarkdownFiles(workspaceRoot, ["tests"])) {
|
|
101
|
+
const content = readText(file.absolutePath);
|
|
102
|
+
if (content === null)
|
|
103
|
+
continue;
|
|
104
|
+
const entity = readAuthoredEntity(content, file.relativePath);
|
|
105
|
+
const row = entity === null ? undefined : byTest.get(entity.id);
|
|
106
|
+
if (entity === null || row === undefined)
|
|
107
|
+
continue;
|
|
108
|
+
const keys = [...new Set(row.candidates.map((c) => c.claim_key))].sort();
|
|
109
|
+
if (keys.length !== 1) {
|
|
110
|
+
review.push({
|
|
111
|
+
id: entity.id,
|
|
112
|
+
path: file.relativePath,
|
|
113
|
+
kind: row.kind,
|
|
114
|
+
candidates: keys,
|
|
115
|
+
});
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const after = withProofContractProves(content, keys);
|
|
119
|
+
if (after === null) {
|
|
120
|
+
skipped.push({
|
|
121
|
+
id: entity.id,
|
|
122
|
+
path: file.relativePath,
|
|
123
|
+
reason: "its proof_contract is not a block mapping Kibi can extend in place",
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
targets.push({
|
|
128
|
+
id: entity.id,
|
|
129
|
+
type: "test",
|
|
130
|
+
path: file.relativePath,
|
|
131
|
+
before: content,
|
|
132
|
+
after,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return { targets, review, skipped };
|
|
136
|
+
}
|
|
137
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
138
|
+
export function applyProofContractClaimPins(workspaceRoot, rows) {
|
|
139
|
+
const plan = planProofContractClaimPins(workspaceRoot, rows);
|
|
140
|
+
for (const target of plan.targets)
|
|
141
|
+
writeFileAtomically(path.join(workspaceRoot, target.path), target.after);
|
|
142
|
+
return plan;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The claim candidates of every certificate contract without proves, read
|
|
146
|
+
* from the branch's compiled store. Returns null when no healthy, synced
|
|
147
|
+
* store is attached or the evaluation fails; the migration then pins
|
|
148
|
+
* nothing, and proof-contract-claims lists the contracts.
|
|
149
|
+
*/
|
|
150
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
151
|
+
export async function readProofContractClaimCandidates(workspaceRoot) {
|
|
152
|
+
try {
|
|
153
|
+
const [{ createCliRuntime }, { executeOperation }, { statusSpec }, { runOperationJsonQuery },] = await Promise.all([
|
|
154
|
+
import("../../runtime/cli-runtime.js"),
|
|
155
|
+
import("../../public/operations/runtime-types.js"),
|
|
156
|
+
import("../../public/operations/specs/discovery.js"),
|
|
157
|
+
import("../../public/operations/prolog-json.js"),
|
|
158
|
+
]);
|
|
159
|
+
const runtime = createCliRuntime({ workspaceRoot });
|
|
160
|
+
const status = (await executeOperation(runtime, statusSpec, {}))
|
|
161
|
+
.structuredContent;
|
|
162
|
+
if (status?.branchStore?.state !== "healthy" ||
|
|
163
|
+
status?.snapshotId === "missing" ||
|
|
164
|
+
status?.branchAttachment?.kind !== "exact")
|
|
165
|
+
return null;
|
|
166
|
+
const rows = await executeOperation(runtime, {
|
|
167
|
+
name: "kb_migrate_proof_contract_claims_preview",
|
|
168
|
+
effects: ["kb-read"],
|
|
169
|
+
requiresProlog: true,
|
|
170
|
+
execute: async (_input, context) => {
|
|
171
|
+
const prolog = context.prolog ?? (await context.ensureProlog?.());
|
|
172
|
+
if (prolog === undefined)
|
|
173
|
+
return [];
|
|
174
|
+
return runOperationJsonQuery(prolog, "claim_obligations.pl", "claim_obligations:proof_contract_claim_candidates_json(JsonString)", "Proof contract claim candidates");
|
|
175
|
+
},
|
|
176
|
+
}, {});
|
|
177
|
+
return Array.isArray(rows) ? rows : null;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type MigrationAction } from "../../public/operations/migration-plan.js";
|
|
2
2
|
import { CLOSE_SUPERSEDED_REQUIREMENTS_CODE, MIGRATION_SYNC_ACTION_ID, MIGRATION_SYNC_CODE, SOURCE_PATH_REWRITE_CODE } from "../../public/operations/schema6-check-actions.js";
|
|
3
|
+
import { type LadderFloorVerdicts } from "./evidence-floor.js";
|
|
4
|
+
import { type ClaimCandidateRow } from "./proof-contract-claims.js";
|
|
3
5
|
/** The KB schema generation that introduced entity `origin`. */
|
|
4
6
|
export declare const ORIGIN_SCHEMA_VERSION = 6;
|
|
5
7
|
/** The KB schema generation that requires body context on current entities. */
|
|
@@ -58,6 +60,10 @@ export type Schema6MigrationFragment = Readonly<{
|
|
|
58
60
|
export declare function buildSchema6MigrationFragment(input: {
|
|
59
61
|
workspaceRoot: string;
|
|
60
62
|
currentSchemaVersion: number | null;
|
|
63
|
+
/** The evidence ladder's floor verdicts on the synced store, when read. */
|
|
64
|
+
ladderFloors?: LadderFloorVerdicts | null;
|
|
65
|
+
/** Claim candidates of certificate contracts without proves, when read. */
|
|
66
|
+
claimCandidates?: readonly ClaimCandidateRow[] | null;
|
|
61
67
|
}): Schema6MigrationFragment;
|
|
62
68
|
/**
|
|
63
69
|
* Actions for the superseded-requirement-open and source-path-dangling
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema6.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/schema6.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema6.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/schema6.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAEL,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EAEnB,wBAAwB,EAOzB,MAAM,kDAAkD,CAAC;AAkB1D,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,qBAAqB,CAAC;AAmB7B,OAAO,EACL,KAAK,iBAAiB,EAIvB,MAAM,4BAA4B,CAAC;AAqCpC,gEAAgE;AAEhE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,+EAA+E;AAE/E,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,4DAA4D;AAE5D,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD,yEAAyE;AAEzE,eAAO,MAAM,gCAAgC,gCAAgC,CAAC;AAC9E,gEAAgE;AAEhE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E;;;GAGG;AAEH,eAAO,MAAM,+CAA+C,+CACd,CAAC;AAC/C,iFAAiF;AAEjF,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E,+EAA+E;AAE/E,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AAExE,eAAO,MAAM,kCAAkC,6BAA6B,CAAC;AAC7E,yEAAyE;AAEzE,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AAEpE,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AACzE,OAAO,EACL,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,GACzB,CAAC;AAiNF;;;;;;;GAOG;AAEH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,GACpB,eAAe,EAAE,CAkFnB;AAyBD;;;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eAAe,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CA8Jf;AAED;;;GAGG;AAEH,eAAO,MAAM,+BAA+B,EAAE,WAAW,CAAC,MAAM,CAK9D,CAAC;AAGH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAetD,CAAC"}
|
|
@@ -18,17 +18,21 @@
|
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import { extractFromMarkdown, } from "../../extractors/markdown.js";
|
|
20
20
|
import { FIRMNESS_FROM_ORIGIN_SCHEMA_VERSION } from "../../public/operations/decision-firmness.js";
|
|
21
|
+
import { EVIDENCE_FLOOR_SCHEMA_VERSION } from "../../public/operations/evidence-floor.js";
|
|
21
22
|
import { migrationAction, } from "../../public/operations/migration-plan.js";
|
|
23
|
+
import { CLAIM_BINDING_SCHEMA_VERSION } from "../../public/operations/proof-contract-claims.js";
|
|
22
24
|
import { CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID, CLOSE_SUPERSEDED_REQUIREMENTS_CODE, MIGRATION_SYNC_ACTION_ID, MIGRATION_SYNC_CODE, SOURCE_PATH_REWRITE_ACTION_ID, SOURCE_PATH_REWRITE_CODE, closeSupersededRequirementsActionInput, exceptionUnapprovedActionInput, migrationSyncActionInput, sourcePathReviewActionInput, sourcePathRewriteActionInput, supersessionCycleReviewActionInput, } from "../../public/operations/schema6-check-actions.js";
|
|
23
25
|
import { readAllShards } from "../../relationships/shards.js";
|
|
24
26
|
import { KB_PATHS } from "../../utils/kb-paths.js";
|
|
25
27
|
import { CONTEXT_MISSING_TAG_CODE, SEMANTIC_TEXT_PIN_CODE, applyContextMissingTags, applySemanticTextPins, countByType, planContextMissingTags, planSemanticTextPins, } from "./entity-body-context.js";
|
|
26
28
|
import { ENTITY_TYPE_BACKFILL_ACTION_ID, ENTITY_TYPE_BACKFILL_CODE, applyEntityTypeBackfill, planEntityTypeBackfill, } from "./entity-type.js";
|
|
29
|
+
import { EVIDENCE_FLOOR_PIN_CODE, applyEvidenceFloorPins, planEvidenceFloorPins, } from "./evidence-floor.js";
|
|
27
30
|
import { FIRM_SUPERSEDE_ACKNOWLEDGE_CODE, applyFirmSupersedeAcknowledgement, planFirmSupersedeAcknowledgement, } from "./firm-supersede.js";
|
|
28
31
|
import { applyInventoryRederivation, applyInventoryRederivationDroppingGrounding, planInventoryRederivation, } from "./inventory-rederive.js";
|
|
29
32
|
import { listLaneMarkdownFiles } from "./kb-sources.js";
|
|
30
33
|
import { applyOriginBackfill, planOriginBackfill } from "./origin-backfill.js";
|
|
31
34
|
import { POLARITY_VALUE_BACKFILL_CODE, applyPolarityValueBackfill, planPolarityValueBackfill, } from "./polarity-values.js";
|
|
35
|
+
import { PROOF_CONTRACT_CLAIMS_PIN_CODE, PROOF_CONTRACT_CLAIMS_REVIEW_CODE, planProofContractClaimPins, } from "./proof-contract-claims.js";
|
|
32
36
|
import { DELIVERED_REQUIREMENT_TAG, applyDeliveredStatusMappings, applyRequirementStatusMapping, planRequirementStatusMappings, } from "./requirement-status.js";
|
|
33
37
|
import { applySourcePathRepairs, findSourceRepairs, plannedSourcePathRepairs, } from "./source-paths.js";
|
|
34
38
|
import { applySupersededClosures, planSupersededClosures, } from "./superseded-closure.js";
|
|
@@ -581,6 +585,88 @@ export function buildSchema6MigrationFragment(input) {
|
|
|
581
585
|
}));
|
|
582
586
|
}
|
|
583
587
|
}
|
|
588
|
+
// Schema 11: a firm requirement needs tested evidence. Record an asserted
|
|
589
|
+
// floor on current firm requirements without a passing proof path, so the
|
|
590
|
+
// upgraded knowledge base passes evidence-floor.
|
|
591
|
+
if (input.currentSchemaVersion === null ||
|
|
592
|
+
input.currentSchemaVersion < EVIDENCE_FLOOR_SCHEMA_VERSION) {
|
|
593
|
+
const floors = planEvidenceFloorPins(input.workspaceRoot, input.ladderFloors);
|
|
594
|
+
if (floors.targets.length > 0) {
|
|
595
|
+
const id = "evidence-floor-pin";
|
|
596
|
+
sourceRewriteActionIds.push(id);
|
|
597
|
+
actions.push(migrationAction({
|
|
598
|
+
id,
|
|
599
|
+
code: EVIDENCE_FLOOR_PIN_CODE,
|
|
600
|
+
category: "schema",
|
|
601
|
+
safety: "automatic",
|
|
602
|
+
autoApplicable: true,
|
|
603
|
+
invocation: {
|
|
604
|
+
kind: "cli",
|
|
605
|
+
command_argv: ["kibi", "migrate", "--yes"],
|
|
606
|
+
},
|
|
607
|
+
affectedEntityIds: floors.targets.map((row) => row.id),
|
|
608
|
+
affectedFiles: floors.targets.map((row) => row.path),
|
|
609
|
+
postconditions: [{ rule: "evidence-floor", findings: 0 }],
|
|
610
|
+
evidence: {
|
|
611
|
+
reason: "Schema 11 fails a current requirement whose evidence is below its floor, and a firm requirement without required_evidence needs tested evidence. These firm requirements are below tested (judged by the evidence ladder on the synced store when one could be read, else by their latest end-to-end receipt), so each records required_evidence: asserted in its front matter, where a reviewer can raise it once a proof exists.",
|
|
612
|
+
count: floors.targets.length,
|
|
613
|
+
skipped: floors.skipped,
|
|
614
|
+
preserves: "every other front matter key and the body bytes",
|
|
615
|
+
},
|
|
616
|
+
}));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
// Schema 12: a certificate contract names the claims it proves. Pin proves
|
|
620
|
+
// where the test reaches one provable claim; list the rest for review.
|
|
621
|
+
if ((input.currentSchemaVersion === null ||
|
|
622
|
+
input.currentSchemaVersion < CLAIM_BINDING_SCHEMA_VERSION) &&
|
|
623
|
+
input.claimCandidates) {
|
|
624
|
+
const claims = planProofContractClaimPins(input.workspaceRoot, input.claimCandidates);
|
|
625
|
+
if (claims.targets.length > 0) {
|
|
626
|
+
const id = "proof-contract-claims-pin";
|
|
627
|
+
sourceRewriteActionIds.push(id);
|
|
628
|
+
actions.push(migrationAction({
|
|
629
|
+
id,
|
|
630
|
+
code: PROOF_CONTRACT_CLAIMS_PIN_CODE,
|
|
631
|
+
category: "schema",
|
|
632
|
+
safety: "automatic",
|
|
633
|
+
autoApplicable: true,
|
|
634
|
+
invocation: {
|
|
635
|
+
kind: "cli",
|
|
636
|
+
command_argv: ["kibi", "migrate", "--yes"],
|
|
637
|
+
},
|
|
638
|
+
affectedEntityIds: claims.targets.map((row) => row.id),
|
|
639
|
+
affectedFiles: claims.targets.map((row) => row.path),
|
|
640
|
+
evidence: {
|
|
641
|
+
reason: "Schema 12 requires every certificate-kind proof contract to name the claims it proves. Each of these tests reaches exactly one claim its proof kind can derive an obligation for, so the migration writes it to proof_contract.proves. The contract changes, so run kibi prove for these tests afterwards.",
|
|
642
|
+
count: claims.targets.length,
|
|
643
|
+
skipped: claims.skipped,
|
|
644
|
+
preserves: "every other front matter key and the body bytes",
|
|
645
|
+
},
|
|
646
|
+
}));
|
|
647
|
+
}
|
|
648
|
+
for (const row of claims.review)
|
|
649
|
+
actions.push(migrationAction({
|
|
650
|
+
id: `proof-contract-claims-review-${row.id}`,
|
|
651
|
+
code: PROOF_CONTRACT_CLAIMS_REVIEW_CODE,
|
|
652
|
+
category: "semantic",
|
|
653
|
+
safety: "review",
|
|
654
|
+
invocation: {
|
|
655
|
+
kind: "review",
|
|
656
|
+
instruction: row.candidates.length === 0
|
|
657
|
+
? `${row.id} (${row.path}) has a ${row.kind} proof contract but reaches no claim ${/^[aeiou]/.test(row.kind) ? "an" : "a"} ${row.kind} certificate can derive an obligation for. Add proof_contract.proves with the claim key its certificate establishes (it then counts as attested, not proved), or model that claim's grounding fact as a ${row.kind === "exhaustive" || row.kind === "typecheck" ? "set" : "numeric"} fact first. Then run kibi prove --test ${row.id}.`
|
|
658
|
+
: `${row.id} (${row.path}) has a ${row.kind} proof contract and could prove any of ${row.candidates.join(", ")}. Add proof_contract.proves with the claim keys its certificate establishes, then run kibi prove --test ${row.id}.`,
|
|
659
|
+
},
|
|
660
|
+
affectedEntityIds: [row.id],
|
|
661
|
+
affectedFiles: [row.path],
|
|
662
|
+
postconditions: [
|
|
663
|
+
{ rule: "proof-contract-claims", entityId: row.id, findings: 0 },
|
|
664
|
+
],
|
|
665
|
+
dispositionRequired: true,
|
|
666
|
+
allowedDispositions: ["fixed", "deferred"],
|
|
667
|
+
evidence: { kind: row.kind, candidates: row.candidates },
|
|
668
|
+
}));
|
|
669
|
+
}
|
|
584
670
|
const drift = planInventoryRederivation(input.workspaceRoot);
|
|
585
671
|
for (const plan of drift) {
|
|
586
672
|
const action = plan.safe ? rederiveAction(plan) : reviewAction(plan);
|
|
@@ -797,6 +883,13 @@ export async function applySchema6MigrationAction(action, context) {
|
|
|
797
883
|
applyFirmSupersedeAcknowledgement(context.workspaceRoot);
|
|
798
884
|
return;
|
|
799
885
|
}
|
|
886
|
+
case EVIDENCE_FLOOR_PIN_CODE: {
|
|
887
|
+
// The plan decided the pins with the evidence ladder; apply the same
|
|
888
|
+
// set even though source rewrites before it may have left the store
|
|
889
|
+
// behind the authored files.
|
|
890
|
+
applyEvidenceFloorPins(context.workspaceRoot, new Map((action.affectedEntityIds ?? []).map((id) => [id, "below"])));
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
800
893
|
case SEMANTIC_INVENTORY_REDERIVE_CODE: {
|
|
801
894
|
const requirementId = action.affectedEntityIds[0];
|
|
802
895
|
if (requirementId === undefined)
|
|
@@ -890,6 +983,7 @@ export const SCHEMA6_AUTOMATIC_CODES = new Set([
|
|
|
890
983
|
CONTEXT_MISSING_TAG_CODE,
|
|
891
984
|
SUPERSEDES_REASON_ACKNOWLEDGE_CODE,
|
|
892
985
|
FIRM_SUPERSEDE_ACKNOWLEDGE_CODE,
|
|
986
|
+
EVIDENCE_FLOOR_PIN_CODE,
|
|
893
987
|
SEMANTIC_INVENTORY_REDERIVE_CODE,
|
|
894
988
|
REQ_STATUS_DELIVERED_MAP_CODE,
|
|
895
989
|
ENTITY_ORIGIN_BACKFILL_CODE,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StoredEntityLookup } from "./stored-entity.js";
|
|
2
|
+
import type { StagedUpsertState, UpsertInput } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* An update keeps every property it leaves out. The authored file already
|
|
5
|
+
* does (the writer patches its front matter), so the compiled entity must
|
|
6
|
+
* too: otherwise a relationship-only upsert stores the requirement without,
|
|
7
|
+
* say, its `required_evidence`, and the store disagrees with the file until a
|
|
8
|
+
* rebuild.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withStoredOmittedProperties(input: UpsertInput, lookup: StoredEntityLookup, staged?: StagedUpsertState): Promise<UpsertInput>;
|
|
11
|
+
//# sourceMappingURL=omitted-properties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omitted-properties.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/omitted-properties.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA8BjE;;;;;;GAMG;AAEH,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAiBtB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { isUpsertEntityProperty } from "./validation.js";
|
|
19
|
+
/**
|
|
20
|
+
* Stored fields an update never inherits by omission: identity and write
|
|
21
|
+
* times, fields derived from other fields, and fields other upsert steps
|
|
22
|
+
* resolve with their own rules (origin, firmness, receipt history, the
|
|
23
|
+
* requirement proposition ledger).
|
|
24
|
+
*/
|
|
25
|
+
const NOT_INHERITED = new Set([
|
|
26
|
+
"id",
|
|
27
|
+
"type",
|
|
28
|
+
"created_at",
|
|
29
|
+
"updated_at",
|
|
30
|
+
"source",
|
|
31
|
+
"origin",
|
|
32
|
+
"firmness",
|
|
33
|
+
"approval_ref",
|
|
34
|
+
"proof_receipts",
|
|
35
|
+
"claim_key",
|
|
36
|
+
"text_ref",
|
|
37
|
+
"semantic_text",
|
|
38
|
+
"semantic_clauses",
|
|
39
|
+
"semantic_inventory",
|
|
40
|
+
"semantic_inventory_version",
|
|
41
|
+
"semantic_source_field",
|
|
42
|
+
"semantic_source_hash",
|
|
43
|
+
"logic_claims",
|
|
44
|
+
]);
|
|
45
|
+
/**
|
|
46
|
+
* An update keeps every property it leaves out. The authored file already
|
|
47
|
+
* does (the writer patches its front matter), so the compiled entity must
|
|
48
|
+
* too: otherwise a relationship-only upsert stores the requirement without,
|
|
49
|
+
* say, its `required_evidence`, and the store disagrees with the file until a
|
|
50
|
+
* rebuild.
|
|
51
|
+
*/
|
|
52
|
+
// implements REQ-kibi-operation-interface-parity
|
|
53
|
+
export async function withStoredOmittedProperties(input, lookup, staged) {
|
|
54
|
+
const stored = staged?.entities.get(input.id) ?? (await lookup.entity());
|
|
55
|
+
if (stored === undefined || stored === null)
|
|
56
|
+
return input;
|
|
57
|
+
if (stored.type !== undefined && stored.type !== input.type)
|
|
58
|
+
return input;
|
|
59
|
+
const properties = (input.properties ?? {});
|
|
60
|
+
const inherited = {};
|
|
61
|
+
for (const [key, value] of Object.entries(stored)) {
|
|
62
|
+
if (value === undefined || value === null)
|
|
63
|
+
continue;
|
|
64
|
+
if (NOT_INHERITED.has(key) || !isUpsertEntityProperty(key))
|
|
65
|
+
continue;
|
|
66
|
+
if (properties[key] !== undefined)
|
|
67
|
+
continue;
|
|
68
|
+
inherited[key] = value;
|
|
69
|
+
}
|
|
70
|
+
if (Object.keys(inherited).length === 0)
|
|
71
|
+
return input;
|
|
72
|
+
return {
|
|
73
|
+
...input,
|
|
74
|
+
properties: { ...inherited, ...properties },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0DpD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,CAMR;AAGD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAOxE;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-fact.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/strict-fact.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strict-fact.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/strict-fact.ts"],"names":[],"mappings":"AAYA,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgBrD;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,EAAE,CA+EV;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,GACrB,IAAI,CAUN;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,IAAI,CAmDN"}
|
|
@@ -5,6 +5,7 @@ const PROPERTY_VALUE_FIELDS = [
|
|
|
5
5
|
"value_int",
|
|
6
6
|
"value_number",
|
|
7
7
|
"value_bool",
|
|
8
|
+
"value_set",
|
|
8
9
|
];
|
|
9
10
|
// implements REQ-kibi-operation-interface-parity
|
|
10
11
|
export function valueFieldHint(value) {
|
|
@@ -19,7 +20,10 @@ export function valueFieldHint(value) {
|
|
|
19
20
|
if (typeof value === "string") {
|
|
20
21
|
return `Use value_type: "string" plus value_string: ${JSON.stringify(value)}.`;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return `Use value_type: "set" plus value_set: ${JSON.stringify(value)}.`;
|
|
25
|
+
}
|
|
26
|
+
return "Use value_type plus exactly one of value_string, value_int, value_number, value_bool, or value_set.";
|
|
23
27
|
}
|
|
24
28
|
// implements REQ-kibi-operation-interface-parity
|
|
25
29
|
export function factKindShapeHints(entity) {
|
|
@@ -38,7 +42,7 @@ export function factKindShapeHints(entity) {
|
|
|
38
42
|
hints.push(`fact_kind 'property_value' requires ${missing.join(", ")}.`);
|
|
39
43
|
}
|
|
40
44
|
if (present.length !== 1) {
|
|
41
|
-
hints.push("fact_kind 'property_value' requires exactly one typed value field: value_string, value_int, value_number, or
|
|
45
|
+
hints.push("fact_kind 'property_value' requires exactly one typed value field: value_string, value_int, value_number, value_bool, or value_set.");
|
|
42
46
|
}
|
|
43
47
|
if (hints.length > 0) {
|
|
44
48
|
hints.push("Next action: use kb_model_requirement for prose claims, or provide subject_key, property_key, operator, value_type, and one value_* field in kb_upsert.properties.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAajF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BpD;;;;GAIG;AAEH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA+B3E,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC3E,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAajF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BpD;;;;GAIG;AAEH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA+B3E,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC3E,OAAO,CAAC,IAAI,CAAC,CAoDf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { collectGranularityCandidates } from "kibi-plugin-builtin";
|
|
2
2
|
import { InputError } from "../../cli-errors.js";
|
|
3
|
-
import { resolveWorkspaceSourceAbsolute } from "../../utils/repo-relative-path.js";
|
|
4
3
|
import { ALLOWED_GRANULARITY_REASONS_PROSE, coarseLinkBehavioralNames, getBehavioralSymbolNames, getNonBehavioralSymbolNames, inferSymbolRole, isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../../public/symbol-granularity.js";
|
|
4
|
+
import { resolveWorkspaceSourceAbsolute } from "../../utils/repo-relative-path.js";
|
|
5
5
|
function candidate(name, kind) {
|
|
6
6
|
return { name, kind, role: inferSymbolRole(kind) };
|
|
7
7
|
}
|
|
@@ -86,8 +86,10 @@ export async function validateSymbolGranularity(payload, relationships, context,
|
|
|
86
86
|
// A declaration named like the symbol is coarse only through its own
|
|
87
87
|
// behavioral members (a class and its public methods), the same test the
|
|
88
88
|
// staged gate and `kibi check` apply; any other title is judged against
|
|
89
|
-
// every behavioral declaration in the file.
|
|
90
|
-
|
|
89
|
+
// every behavioral declaration in the file. An exported constant is its
|
|
90
|
+
// own declaration with exact coordinates (a certificate proof's domain is
|
|
91
|
+
// one), so it is granular whatever its role.
|
|
92
|
+
const behavioral = exact
|
|
91
93
|
? coarseLinkBehavioralNames(entity.title, available)
|
|
92
94
|
: getBehavioralSymbolNames(available);
|
|
93
95
|
if (behavioral.length === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAexE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"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AK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAClE,GAAG,IAAI,CAAC,CAmBR;AAyBD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CA4gBzC"}
|
|
@@ -16,6 +16,7 @@ import { assertLogicalGroundingClaimKeys, assertSemanticInventoryBoundary, } fro
|
|
|
16
16
|
import { entityContextWarnings } from "./context-warning.js";
|
|
17
17
|
import { buildUpsertCommitGoal, formatUpsertError } from "./contradictions.js";
|
|
18
18
|
import { assertFirmDecisionUnchanged } from "./firm-decision-guard.js";
|
|
19
|
+
import { withStoredOmittedProperties } from "./omitted-properties.js";
|
|
19
20
|
import { resolveUpsertOrigin } from "./origin.js";
|
|
20
21
|
import { planRecoveryNotes, settlePendingPlanApplyJournals, withPlanRecoveryNotes, } from "./plan-apply-journal.js";
|
|
21
22
|
import { assertPredicateArgumentVocabulary } from "./predicate-vocabulary-guard.js";
|
|
@@ -279,7 +280,12 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
|
|
|
279
280
|
// than later by the staged gate.
|
|
280
281
|
if (checked.entity.sourceFile === undefined)
|
|
281
282
|
await validateSymbolGranularity(checked.entity, checked.relationships, context, async () => staged?.entities.get(payload.id) ?? (await lookup.entity()));
|
|
282
|
-
|
|
283
|
+
const withSemantics = await withStoredRequirementSemantics(payload, prolog, staged, lookup);
|
|
284
|
+
// An uncompiled file is judged as the writer will patch it (below), so only
|
|
285
|
+
// a compiled entity lends its omitted properties to the stored write.
|
|
286
|
+
let input = uncompiledSource === null
|
|
287
|
+
? await withStoredOmittedProperties(withSemantics, lookup, staged)
|
|
288
|
+
: withSemantics;
|
|
283
289
|
let validated = input === payload ? checked : validateUpsertInput(input, context.clock());
|
|
284
290
|
if (uncompiledSource !== null)
|
|
285
291
|
lookup = {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isAllowedGranularityReason } from "../../public/symbol-granularity.js";
|
|
2
2
|
import type { UpsertInput, ValidatedUpsert } from "./types.js";
|
|
3
|
+
/** Whether the upsert entity schema defines `key` as an entity property. */
|
|
4
|
+
export declare function isUpsertEntityProperty(key: string): boolean;
|
|
3
5
|
export declare function validateUpsertInput(input: UpsertInput, now: Date): ValidatedUpsert;
|
|
4
6
|
export { isAllowedGranularityReason };
|
|
5
7
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAU5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAU5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA2D/D,4EAA4E;AAC5E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAK3D;AA4JD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,IAAI,GACR,eAAe,CA6DjB;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -59,6 +59,10 @@ const DOCUMENT_TEXT_PROPERTIES = new Set([
|
|
|
59
59
|
"summary",
|
|
60
60
|
"details",
|
|
61
61
|
]);
|
|
62
|
+
/** Whether the upsert entity schema defines `key` as an entity property. */
|
|
63
|
+
export function isUpsertEntityProperty(key) {
|
|
64
|
+
return Object.hasOwn(upsertEntitySchema.properties, key);
|
|
65
|
+
}
|
|
62
66
|
/** Every top-level entity key the upsert entity schema does not define. */
|
|
63
67
|
function unknownEntityProperties(entity) {
|
|
64
68
|
const known = upsertEntitySchema.properties;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
|
+
import type { ProofContract } from "../../public/proof-protocol.js";
|
|
3
|
+
import type { ClaimBinding } from "../../public/proof-receipt.js";
|
|
4
|
+
import { type CertificateVerdict } from "./code-certificates.js";
|
|
5
|
+
/**
|
|
6
|
+
* The type-level witness Kibi writes for a typecheck claim binding: it
|
|
7
|
+
* compiles only when the domain type has exactly the fact's members.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setEqualityWitness(importPath: string, members: readonly string[], membersType: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* How a certificate binds to each claim its contract names in proves. Kibi
|
|
12
|
+
* derives what the certificate must establish from each claim's grounding
|
|
13
|
+
* fact (claim_obligations.pl) and checks the certificate against it; a claim
|
|
14
|
+
* whose fact has no derivation is only attested by the author. Returns
|
|
15
|
+
* undefined for a contract that names no claims.
|
|
16
|
+
*/
|
|
17
|
+
export declare function judgeClaimBindings(context: OperationContext, input: Readonly<{
|
|
18
|
+
testId: string;
|
|
19
|
+
contract: ProofContract;
|
|
20
|
+
verdict: CertificateVerdict;
|
|
21
|
+
coveredBySymbols: readonly string[];
|
|
22
|
+
}>): Promise<ClaimBinding[] | undefined>;
|
|
23
|
+
//# sourceMappingURL=claim-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-bindings.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/claim-bindings.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,wBAAwB,CAAC;AA+ChC;;;GAGG;AAEH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,WAAW,EAAE,MAAM,GAClB,MAAM,CAWR;AA8GD;;;;;;GAMG;AAEH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC,GACD,OAAO,CAAC,YAAY,EAAE,GAAG,SAAS,CAAC,CAuErC"}
|