kibi-cli 2.31.1 → 2.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -1
- package/dist/commands/check-generated.d.ts +5 -1
- package/dist/commands/check-generated.d.ts.map +1 -1
- package/dist/commands/check-generated.js +24 -35
- 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/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +8 -5
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +109 -5
- 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 +20 -1
- package/dist/commands/sync/manifest.d.ts +10 -1
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +106 -17
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +16 -5
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +19 -0
- package/dist/diagnostics.js +1 -1
- package/dist/engine.js +1 -1
- package/dist/extractors/markdown.d.ts +4 -2
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +17 -0
- package/dist/extractors/symbol-coordinates.js +2 -2
- package/dist/extractors/symbols-coordinator.d.ts +2 -4
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +1 -2
- 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 +72 -0
- package/dist/operations/migration/proof-contract-claims.d.ts.map +1 -0
- package/dist/operations/migration/proof-contract-claims.js +215 -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 +92 -0
- package/dist/operations/migration/symbol-coordinates-refresh.d.ts +3 -2
- package/dist/operations/migration/symbol-coordinates-refresh.d.ts.map +1 -1
- package/dist/operations/migration/symbol-coordinates-refresh.js +4 -3
- package/dist/operations/migration/untrack-symbol-coordinates.d.ts +23 -0
- package/dist/operations/migration/untrack-symbol-coordinates.d.ts.map +1 -0
- package/dist/operations/migration/untrack-symbol-coordinates.js +67 -0
- package/dist/operations/modeling/requirement-modeler.d.ts.map +1 -1
- package/dist/operations/modeling/requirement-modeler.js +48 -1
- package/dist/operations/modeling/requirement-types.d.ts +2 -1
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
- package/dist/operations/modeling/requirement-utils.d.ts +1 -1
- package/dist/operations/modeling/requirement-utils.d.ts.map +1 -1
- package/dist/operations/modeling/requirement-utils.js +8 -1
- 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/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +39 -20
- 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 +41 -0
- package/dist/operations/proof/claim-bindings.d.ts.map +1 -0
- package/dist/operations/proof/claim-bindings.js +364 -0
- package/dist/operations/proof/code-certificates.d.ts +155 -0
- package/dist/operations/proof/code-certificates.d.ts.map +1 -0
- package/dist/operations/proof/code-certificates.js +894 -0
- package/dist/operations/proof/code-models.d.ts +96 -0
- package/dist/operations/proof/code-models.d.ts.map +1 -0
- package/dist/operations/proof/code-models.js +601 -0
- package/dist/operations/proof/code-runner.d.ts +40 -0
- package/dist/operations/proof/code-runner.d.ts.map +1 -0
- package/dist/operations/proof/code-runner.js +164 -0
- package/dist/operations/proof/code-scope.d.ts +14 -1
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +44 -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 +42 -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/proof/regular-language.d.ts +89 -0
- package/dist/operations/proof/regular-language.d.ts.map +1 -0
- package/dist/operations/proof/regular-language.js +943 -0
- package/dist/operations/proof/source-code-readers.d.ts +12 -0
- package/dist/operations/proof/source-code-readers.d.ts.map +1 -0
- package/dist/operations/proof/source-code-readers.js +699 -0
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +2 -1
- 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-count-rules.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/strict-count-rules.js +8 -2
- package/dist/operations/semantic-advisor/strict-rules.d.ts +8 -0
- package/dist/operations/semantic-advisor/strict-rules.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/strict-rules.js +234 -4
- package/dist/operations/semantic-advisor/types.d.ts +3 -2
- 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/prolog.d.ts.map +1 -1
- package/dist/prolog.js +13 -3
- 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 +315 -11
- 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/composite.d.ts +16 -3
- package/dist/public/operations/specs/composite.d.ts.map +1 -1
- package/dist/public/operations/specs/modeling.d.ts +16 -3
- package/dist/public/operations/specs/modeling.d.ts.map +1 -1
- package/dist/public/operations/specs/modeling.js +22 -3
- package/dist/public/operations/specs/mutation-schemas.d.ts +289 -7
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +28 -4
- 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 +289 -7
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/proof-certificates.d.ts +163 -0
- package/dist/public/proof-certificates.d.ts.map +1 -0
- package/dist/public/proof-certificates.js +419 -0
- package/dist/public/proof-protocol.d.ts +259 -3
- package/dist/public/proof-protocol.d.ts.map +1 -1
- package/dist/public/proof-protocol.js +524 -3
- package/dist/public/proof-receipt.d.ts +90 -6
- package/dist/public/proof-receipt.d.ts.map +1 -1
- package/dist/public/proof-receipt.js +88 -7
- package/dist/public/proof-sources.d.ts +102 -0
- package/dist/public/proof-sources.d.ts.map +1 -0
- package/dist/public/proof-sources.js +1292 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +39 -2
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-commit-review/SKILL.md +8 -8
- package/dist/public/skills/kibi-commit-review/resources/staged-gate.md +12 -7
- package/dist/public/skills/kibi-decisions/SKILL.md +13 -2
- package/dist/public/skills/kibi-decisions/resources/decision-records.md +9 -1
- package/dist/public/skills/kibi-freshness/SKILL.md +5 -1
- package/dist/public/skills/kibi-traceability/SKILL.md +12 -1
- package/dist/public/skills/kibi-usage/SKILL.md +8 -4
- package/dist/public/skills/kibi-usage/resources/proof.md +221 -20
- package/dist/public/skills/kibi-usage/resources/workflows.md +4 -4
- package/dist/report/html-report.css +83 -11
- 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 +214 -22
- package/dist/report/report-view.d.ts +2 -2
- package/dist/report/report-view.d.ts.map +1 -1
- package/dist/report/report-view.js +8 -0
- package/dist/schemas/entity.schema.json +404 -5
- 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/evidence-model.d.ts +13 -12
- package/dist/traceability/evidence-model.d.ts.map +1 -1
- package/dist/traceability/evidence-model.js +1 -1
- package/dist/traceability/impact-knowledge.d.ts.map +1 -1
- package/dist/traceability/impact-knowledge.js +1 -0
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-diagnostics.js +24 -20
- package/dist/traceability/staged-impact-contract.d.ts +4 -4
- package/dist/traceability/staged-impact-contract.js +9 -9
- package/dist/traceability/staged-symbols-manifest.d.ts +11 -3
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +47 -140
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +1 -0
- package/dist/types/entities.d.ts +5 -2
- 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 +7 -1
- package/dist/utils/strict-modeling.d.ts +3 -2
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +37 -4
- package/dist/workspace-cwd.d.ts +15 -0
- package/dist/workspace-cwd.d.ts.map +1 -0
- package/dist/workspace-cwd.js +86 -0
- package/package.json +6 -2
- package/schema/entities.pl +6 -0
- package/schema/validation.pl +7 -2
- 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/modeling.ts +24 -5
- package/src/public/operations/specs/mutation-schemas.ts +30 -4
- package/src/public/operations/specs/reporting.ts +20 -10
- package/src/public/proof-certificates.ts +566 -0
- package/src/public/proof-protocol-types.d.ts +69 -1
- package/src/public/proof-protocol.ts +694 -3
- package/src/public/proof-receipt.ts +133 -7
- package/src/public/proof-sources.ts +1656 -0
- package/src/public/schemas/entity.ts +51 -3
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-commit-review/SKILL.md +8 -8
- package/src/public/skills/kibi-commit-review/resources/staged-gate.md +12 -7
- package/src/public/skills/kibi-decisions/SKILL.md +13 -2
- package/src/public/skills/kibi-decisions/resources/decision-records.md +9 -1
- package/src/public/skills/kibi-freshness/SKILL.md +5 -1
- package/src/public/skills/kibi-traceability/SKILL.md +12 -1
- package/src/public/skills/kibi-usage/SKILL.md +8 -4
- package/src/public/skills/kibi-usage/resources/proof.md +221 -20
- package/src/public/skills/kibi-usage/resources/workflows.md +4 -4
- package/src/schemas/entity.schema.json +404 -5
- 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
- package/dist/traceability/reviewed-coordinate-refresh.d.ts +0 -10
- package/dist/traceability/reviewed-coordinate-refresh.d.ts.map +0 -1
- package/dist/traceability/reviewed-coordinate-refresh.js +0 -49
|
@@ -0,0 +1,230 @@
|
|
|
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 { effectiveFirmness } from "../../decision-firmness.js";
|
|
20
|
+
import { authoredSupersededIds, isCurrentAuthoredEntity, readAuthoredEntity, } from "../../public/operations/entity-context.js";
|
|
21
|
+
import { readAllShards } from "../../relationships/shards.js";
|
|
22
|
+
import { listLaneMarkdownFiles, readText, withTopLevelField, writeFileAtomically, } from "./kb-sources.js";
|
|
23
|
+
/** Schema 11: record the floor of firm requirements that had no proof path. */
|
|
24
|
+
// implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
|
|
25
|
+
export const EVIDENCE_FLOOR_PIN_CODE = "evidence_floor_pin";
|
|
26
|
+
/** The floor the migration records: a person stands behind the requirement. */
|
|
27
|
+
const PINNED_FLOOR = "asserted";
|
|
28
|
+
function linkTargets(entity, type) {
|
|
29
|
+
const links = entity.data.links;
|
|
30
|
+
if (!Array.isArray(links))
|
|
31
|
+
return [];
|
|
32
|
+
return links.flatMap((link) => link !== null &&
|
|
33
|
+
typeof link === "object" &&
|
|
34
|
+
link.type === type &&
|
|
35
|
+
typeof link.target === "string"
|
|
36
|
+
? [link.target]
|
|
37
|
+
: []);
|
|
38
|
+
}
|
|
39
|
+
function authoredEntities(workspaceRoot, lane) {
|
|
40
|
+
const entities = [];
|
|
41
|
+
for (const file of listLaneMarkdownFiles(workspaceRoot, [lane])) {
|
|
42
|
+
const content = readText(file.absolutePath);
|
|
43
|
+
if (content === null)
|
|
44
|
+
continue;
|
|
45
|
+
const entity = readAuthoredEntity(content, file.relativePath);
|
|
46
|
+
if (entity !== null)
|
|
47
|
+
entities.push({ entity, content, relativePath: file.relativePath });
|
|
48
|
+
}
|
|
49
|
+
return entities;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An end-to-end test with a proof contract whose newest receipt passed: the
|
|
53
|
+
* least a requirement needs to have been tested, judged on the receipt the
|
|
54
|
+
* evidence ladder reads. A contract that was never run through kibi prove,
|
|
55
|
+
* one whose latest run failed, or a unit-scoped one cannot reach tested.
|
|
56
|
+
*/
|
|
57
|
+
function hasPassingProof(entity) {
|
|
58
|
+
if (entity.data.proof_contract === undefined)
|
|
59
|
+
return false;
|
|
60
|
+
if (entity.data.verification_scope !== "end_to_end")
|
|
61
|
+
return false;
|
|
62
|
+
const receipts = entity.data.proof_receipts;
|
|
63
|
+
if (!Array.isArray(receipts) || receipts.length === 0)
|
|
64
|
+
return false;
|
|
65
|
+
const latest = receipts.reduce((best, receipt, index) => {
|
|
66
|
+
if (receipt === null || typeof receipt !== "object")
|
|
67
|
+
return best;
|
|
68
|
+
const record = receipt;
|
|
69
|
+
// Finish times increase strictly; history order is the fallback.
|
|
70
|
+
const at = typeof record.finished_at === "string"
|
|
71
|
+
? record.finished_at
|
|
72
|
+
: String(index).padStart(12, "0");
|
|
73
|
+
return best === null || at >= best.at
|
|
74
|
+
? { at, outcome: record.outcome }
|
|
75
|
+
: best;
|
|
76
|
+
}, null);
|
|
77
|
+
return latest?.outcome === "passed";
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Requirement ids with a proof path: a linked scenario (specified_by) that an
|
|
81
|
+
* end-to-end test with a proof contract and a passing receipt verifies
|
|
82
|
+
* (scenario verified_by test, or test validates scenario), read from authored
|
|
83
|
+
* links and relationship shards.
|
|
84
|
+
*/
|
|
85
|
+
function requirementsWithProofPath(workspaceRoot, requirements) {
|
|
86
|
+
const scenariosOf = new Map();
|
|
87
|
+
const testsOf = new Map();
|
|
88
|
+
const add = (map, from, to) => {
|
|
89
|
+
const set = map.get(from) ?? new Set();
|
|
90
|
+
set.add(to);
|
|
91
|
+
map.set(from, set);
|
|
92
|
+
};
|
|
93
|
+
for (const requirement of requirements)
|
|
94
|
+
for (const target of linkTargets(requirement, "specified_by"))
|
|
95
|
+
add(scenariosOf, requirement.id, target);
|
|
96
|
+
for (const { entity } of authoredEntities(workspaceRoot, "scenarios"))
|
|
97
|
+
for (const target of linkTargets(entity, "verified_by"))
|
|
98
|
+
add(testsOf, entity.id, target);
|
|
99
|
+
const contracted = new Set();
|
|
100
|
+
for (const { entity } of authoredEntities(workspaceRoot, "tests")) {
|
|
101
|
+
if (hasPassingProof(entity))
|
|
102
|
+
contracted.add(entity.id);
|
|
103
|
+
for (const target of linkTargets(entity, "validates"))
|
|
104
|
+
add(testsOf, target, entity.id);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
for (const relationship of readAllShards(path.join(workspaceRoot, ".kb"))) {
|
|
108
|
+
if (relationship.type === "specified_by")
|
|
109
|
+
add(scenariosOf, relationship.from, relationship.to);
|
|
110
|
+
else if (relationship.type === "verified_by")
|
|
111
|
+
add(testsOf, relationship.from, relationship.to);
|
|
112
|
+
else if (relationship.type === "validates")
|
|
113
|
+
add(testsOf, relationship.to, relationship.from);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Malformed shards fail sync with their own diagnostic.
|
|
118
|
+
}
|
|
119
|
+
const withPath = new Set();
|
|
120
|
+
for (const [requirementId, scenarios] of scenariosOf)
|
|
121
|
+
for (const scenarioId of scenarios)
|
|
122
|
+
for (const testId of testsOf.get(scenarioId) ?? [])
|
|
123
|
+
if (contracted.has(testId))
|
|
124
|
+
withPath.add(requirementId);
|
|
125
|
+
return withPath;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Current firm requirements without required_evidence and without a proof
|
|
129
|
+
* path that has passed. From schema 11 a firm requirement needs tested
|
|
130
|
+
* evidence, which these have not reached, so the migration records their
|
|
131
|
+
* floor as asserted in the requirement itself, where a reviewer sees it and
|
|
132
|
+
* can raise it later. Requirements with a passing proof path keep the tested
|
|
133
|
+
* floor; `kept` lists them, since remaining gaps (a stale receipt, a missing
|
|
134
|
+
* covered_by) still show in kibi check. Read-only.
|
|
135
|
+
*/
|
|
136
|
+
// implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
|
|
137
|
+
export function planEvidenceFloorPins(workspaceRoot, ladder) {
|
|
138
|
+
const files = authoredEntities(workspaceRoot, "requirements").filter(({ entity }) => entity.type === "req");
|
|
139
|
+
const requirements = files.map(({ entity }) => entity);
|
|
140
|
+
const superseded = authoredSupersededIds(workspaceRoot, requirements);
|
|
141
|
+
const withPath = requirementsWithProofPath(workspaceRoot, requirements);
|
|
142
|
+
const targets = [];
|
|
143
|
+
const kept = [];
|
|
144
|
+
const skipped = [];
|
|
145
|
+
for (const { entity, content, relativePath } of files) {
|
|
146
|
+
if (entity.data.required_evidence !== undefined ||
|
|
147
|
+
entity.data.proof_exempt === true ||
|
|
148
|
+
!isCurrentAuthoredEntity(entity, superseded) ||
|
|
149
|
+
effectiveFirmness(entity.type, entity.data.firmness, entity.data.origin) !== "firm")
|
|
150
|
+
continue;
|
|
151
|
+
// The ladder on the compiled store judges every gap (failed latest
|
|
152
|
+
// receipts, missing coverage or coordinates), so a requirement it puts
|
|
153
|
+
// below the tested floor is pinned even with a passing receipt; one
|
|
154
|
+
// without any authored proof path is pinned whatever the store says,
|
|
155
|
+
// since the store may predate the authored sources.
|
|
156
|
+
if (withPath.has(entity.id) && ladder?.get(entity.id) !== "below") {
|
|
157
|
+
kept.push(entity.id);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const after = withTopLevelField(content, "required_evidence", PINNED_FLOOR);
|
|
161
|
+
if (after === null) {
|
|
162
|
+
skipped.push({
|
|
163
|
+
id: entity.id,
|
|
164
|
+
path: relativePath,
|
|
165
|
+
reason: "required_evidence could not be edited safely",
|
|
166
|
+
});
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
targets.push({
|
|
170
|
+
id: entity.id,
|
|
171
|
+
type: entity.type,
|
|
172
|
+
path: relativePath,
|
|
173
|
+
before: content,
|
|
174
|
+
after,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
targets,
|
|
179
|
+
skipped,
|
|
180
|
+
kept,
|
|
181
|
+
decidedBy: ladder === undefined || ladder === null ? "authored" : "ladder",
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** Write the planned floors; returns how many requirements were rewritten. */
|
|
185
|
+
// implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
|
|
186
|
+
export function applyEvidenceFloorPins(workspaceRoot, ladder) {
|
|
187
|
+
const plan = planEvidenceFloorPins(workspaceRoot, ladder);
|
|
188
|
+
for (const target of plan.targets)
|
|
189
|
+
writeFileAtomically(path.join(workspaceRoot, target.path), target.after);
|
|
190
|
+
return plan.targets.length;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Read the evidence ladder's floor verdicts from the branch's compiled store,
|
|
194
|
+
* so the migration keeps the tested floor only where kibi check will accept
|
|
195
|
+
* it. Returns null when no healthy, synced store is attached (never synced,
|
|
196
|
+
* damaged, another branch's store) or the evaluation fails; the migration
|
|
197
|
+
* then decides from authored receipts alone and says so.
|
|
198
|
+
*/
|
|
199
|
+
// implements REQ-kibi-evidence-floors, REQ-cli-schema-migration
|
|
200
|
+
export async function readLadderFloorVerdicts(workspaceRoot) {
|
|
201
|
+
try {
|
|
202
|
+
const [{ createCliRuntime }, { executeOperation }, { statusSpec }, { readEvidenceFloorRows },] = await Promise.all([
|
|
203
|
+
import("../../runtime/cli-runtime.js"),
|
|
204
|
+
import("../../public/operations/runtime-types.js"),
|
|
205
|
+
import("../../public/operations/specs/discovery.js"),
|
|
206
|
+
import("../../public/operations/evidence-floor.js"),
|
|
207
|
+
]);
|
|
208
|
+
const runtime = createCliRuntime({ workspaceRoot });
|
|
209
|
+
const status = (await executeOperation(runtime, statusSpec, {}))
|
|
210
|
+
.structuredContent;
|
|
211
|
+
if (status?.branchStore?.state !== "healthy" ||
|
|
212
|
+
status?.snapshotId === "missing" ||
|
|
213
|
+
status?.branchAttachment?.kind !== "exact")
|
|
214
|
+
return null;
|
|
215
|
+
const rows = await executeOperation(runtime, {
|
|
216
|
+
name: "kb_migrate_evidence_floor_preview",
|
|
217
|
+
effects: ["kb-read"],
|
|
218
|
+
requiresProlog: true,
|
|
219
|
+
execute: (_input, context) => readEvidenceFloorRows(context),
|
|
220
|
+
}, {});
|
|
221
|
+
const verdicts = new Map();
|
|
222
|
+
for (const row of rows)
|
|
223
|
+
if (row.requiredEvidence === "tested")
|
|
224
|
+
verdicts.set(row.id, row.status);
|
|
225
|
+
return verdicts;
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BodyContextTarget } from "./entity-body-context.js";
|
|
2
|
+
/** Schema 12: pin proves on a certificate contract with one provable claim. */
|
|
3
|
+
export declare const PROOF_CONTRACT_CLAIMS_PIN_CODE = "proof_contract_claims_pin";
|
|
4
|
+
/** Schema 12: certificate contracts a person must bind to their claims. */
|
|
5
|
+
export declare const PROOF_CONTRACT_CLAIMS_REVIEW_CODE = "proof_contract_claims_review";
|
|
6
|
+
/**
|
|
7
|
+
* A modeled claim a certificate contract's test reaches, with the binding a
|
|
8
|
+
* certificate of its kind would get: derived when the claim's fact derives
|
|
9
|
+
* an obligation for the kind, attested when the fact has no derivation,
|
|
10
|
+
* incompatible (with the reason) when the kind cannot express it.
|
|
11
|
+
*/
|
|
12
|
+
export type ClaimCandidate = Readonly<{
|
|
13
|
+
claim_key: string;
|
|
14
|
+
requirement_id: string;
|
|
15
|
+
fact_id: string;
|
|
16
|
+
binding: "derived" | "attested" | "incompatible";
|
|
17
|
+
reason?: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* A certificate-kind contract without proves, with every modeled claim of
|
|
21
|
+
* the requirements its test reaches through its scenarios.
|
|
22
|
+
*/
|
|
23
|
+
export type ClaimCandidateRow = Readonly<{
|
|
24
|
+
test_id: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
candidates: readonly ClaimCandidate[];
|
|
27
|
+
}>;
|
|
28
|
+
export type ProofContractClaimsReview = Readonly<{
|
|
29
|
+
id: string;
|
|
30
|
+
path: string;
|
|
31
|
+
kind: string;
|
|
32
|
+
candidates: readonly ClaimCandidate[];
|
|
33
|
+
}>;
|
|
34
|
+
export type ProofContractClaimsPlan = Readonly<{
|
|
35
|
+
targets: readonly BodyContextTarget[];
|
|
36
|
+
/** Contracts left without proves: no derived claim, or several. */
|
|
37
|
+
review: readonly ProofContractClaimsReview[];
|
|
38
|
+
skipped: readonly Readonly<{
|
|
39
|
+
id: string;
|
|
40
|
+
path: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
}>[];
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* What a person reviewing a contract without proves has to do, naming every
|
|
46
|
+
* claim its test reaches and how a certificate of its kind would bind it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function claimReviewInstruction(row: ProofContractClaimsReview): string;
|
|
49
|
+
/**
|
|
50
|
+
* Add proves to a test's proof_contract block, leaving every other byte of
|
|
51
|
+
* the document unchanged: the list goes after the block's last line, at the
|
|
52
|
+
* indentation of its other keys. Returns null when the contract is not a
|
|
53
|
+
* block mapping, already names proves, or the edit would not read back as
|
|
54
|
+
* exactly that change.
|
|
55
|
+
*/
|
|
56
|
+
export declare function withProofContractProves(content: string, keys: readonly string[]): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Certificate-kind contracts without proves, judged on the synced store: a
|
|
59
|
+
* contract whose test reaches exactly one claim its kind can derive an
|
|
60
|
+
* obligation for gets that claim pinned in proves; any other is left for a
|
|
61
|
+
* person to bind (review). Read-only.
|
|
62
|
+
*/
|
|
63
|
+
export declare function planProofContractClaimPins(workspaceRoot: string, rows: readonly ClaimCandidateRow[] | null): ProofContractClaimsPlan;
|
|
64
|
+
export declare function applyProofContractClaimPins(workspaceRoot: string, rows: readonly ClaimCandidateRow[] | null): ProofContractClaimsPlan;
|
|
65
|
+
/**
|
|
66
|
+
* The claim candidates of every certificate contract without proves, read
|
|
67
|
+
* from the branch's compiled store. Returns null when no healthy, synced
|
|
68
|
+
* store is attached or the evaluation fails; the migration then pins
|
|
69
|
+
* nothing, and proof-contract-claims lists the contracts.
|
|
70
|
+
*/
|
|
71
|
+
export declare function readProofContractClaimCandidates(workspaceRoot: string): Promise<readonly ClaimCandidateRow[] | null>;
|
|
72
|
+
//# sourceMappingURL=proof-contract-claims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-contract-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/proof-contract-claims.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,+EAA+E;AAE/E,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E,2EAA2E;AAE3E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,GAAG,UAAU,GAAG,cAAc,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,mEAAmE;IACnE,MAAM,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAC7C,OAAO,EAAE,SAAS,QAAQ,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CAC5E,CAAC,CAAC;AAUH;;;GAGG;AAEH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,yBAAyB,GAAG,MAAM,CAiB7E;AAMD;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,GAAG,IAAI,CAwCf;AAED;;;;;GAKG;AAEH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,GACxC,uBAAuB,CA+CzB;AAGD,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,GACxC,uBAAuB,CAKzB;AAED;;;;;GAKG;AAEH,wBAAsB,gCAAgC,CACpD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAC,CA6C9C"}
|
|
@@ -0,0 +1,215 @@
|
|
|
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 describeCandidate(candidate) {
|
|
30
|
+
const where = `${candidate.claim_key} (${candidate.requirement_id}, ${candidate.fact_id})`;
|
|
31
|
+
if (candidate.binding === "derived")
|
|
32
|
+
return `${where}: provable`;
|
|
33
|
+
if (candidate.binding === "attested")
|
|
34
|
+
return `${where}: attested only, the fact has no derivation`;
|
|
35
|
+
return `${where}: ${candidate.reason ?? "its kind cannot express the fact"}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* What a person reviewing a contract without proves has to do, naming every
|
|
39
|
+
* claim its test reaches and how a certificate of its kind would bind it.
|
|
40
|
+
*/
|
|
41
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
42
|
+
export function claimReviewInstruction(row) {
|
|
43
|
+
const factKind = row.kind === "exhaustive" || row.kind === "typecheck"
|
|
44
|
+
? "set"
|
|
45
|
+
: row.kind === "regex"
|
|
46
|
+
? "string"
|
|
47
|
+
: row.kind === "rule" || row.kind === "state_machine"
|
|
48
|
+
? "rule, predicate or set"
|
|
49
|
+
: "numeric";
|
|
50
|
+
if (row.candidates.length === 0)
|
|
51
|
+
return `${row.id} (${row.path}) has a ${row.kind} proof contract, but its test reaches no modeled claim through a scenario. Link the test to the scenario of the requirement it proves, then add proof_contract.proves with the claim keys its certificate establishes and run kibi prove --test ${row.id}.`;
|
|
52
|
+
const derived = row.candidates.filter((c) => c.binding === "derived");
|
|
53
|
+
const advice = derived.length > 1
|
|
54
|
+
? "Add proof_contract.proves with the claim keys its certificate establishes"
|
|
55
|
+
: `None is provable by a ${row.kind} certificate as modeled: add proof_contract.proves with the claim it establishes (it then counts as attested, not proved), or model that claim's grounding fact as a ${factKind} fact first`;
|
|
56
|
+
return `${row.id} (${row.path}) has a ${row.kind} proof contract without proves. Claims its test reaches: ${row.candidates.map(describeCandidate).join("; ")}. ${advice}, then run kibi prove --test ${row.id}.`;
|
|
57
|
+
}
|
|
58
|
+
function isRecord(value) {
|
|
59
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Add proves to a test's proof_contract block, leaving every other byte of
|
|
63
|
+
* the document unchanged: the list goes after the block's last line, at the
|
|
64
|
+
* indentation of its other keys. Returns null when the contract is not a
|
|
65
|
+
* block mapping, already names proves, or the edit would not read back as
|
|
66
|
+
* exactly that change.
|
|
67
|
+
*/
|
|
68
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
69
|
+
export function withProofContractProves(content, keys) {
|
|
70
|
+
const slice = sliceFrontmatter(content);
|
|
71
|
+
if (slice === null || keys.length === 0)
|
|
72
|
+
return null;
|
|
73
|
+
const lines = slice.text.split(/(?<=\n)/);
|
|
74
|
+
const start = lines.findIndex((line) => /^proof_contract:[ \t]*\r?\n$/.test(line));
|
|
75
|
+
if (start < 0)
|
|
76
|
+
return null;
|
|
77
|
+
let end = start + 1;
|
|
78
|
+
let indent = null;
|
|
79
|
+
while (end < lines.length) {
|
|
80
|
+
const line = lines[end] ?? "";
|
|
81
|
+
const leading = /^([ \t]+)\S/.exec(line);
|
|
82
|
+
if (leading === null)
|
|
83
|
+
break;
|
|
84
|
+
if (indent === null)
|
|
85
|
+
indent = leading[1] ?? "";
|
|
86
|
+
end += 1;
|
|
87
|
+
}
|
|
88
|
+
if (indent === null)
|
|
89
|
+
return null;
|
|
90
|
+
const inserted = [
|
|
91
|
+
`${indent}proves:${slice.eol}`,
|
|
92
|
+
...keys.map((key) => `${indent}${indent}- ${key}${slice.eol}`),
|
|
93
|
+
];
|
|
94
|
+
const text = [...lines.slice(0, end), ...inserted, ...lines.slice(end)].join("");
|
|
95
|
+
try {
|
|
96
|
+
const before = loadYaml(slice.text);
|
|
97
|
+
const next = loadYaml(text);
|
|
98
|
+
if (!isRecord(before) || !isRecord(next))
|
|
99
|
+
return null;
|
|
100
|
+
const contract = before.proof_contract;
|
|
101
|
+
if (!isRecord(contract) || contract.proves !== undefined)
|
|
102
|
+
return null;
|
|
103
|
+
const expected = {
|
|
104
|
+
...before,
|
|
105
|
+
proof_contract: { ...contract, proves: [...keys] },
|
|
106
|
+
};
|
|
107
|
+
if (!isDeepStrictEqual(next, expected))
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return `${slice.prefix}${text}${slice.suffix}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Certificate-kind contracts without proves, judged on the synced store: a
|
|
117
|
+
* contract whose test reaches exactly one claim its kind can derive an
|
|
118
|
+
* obligation for gets that claim pinned in proves; any other is left for a
|
|
119
|
+
* person to bind (review). Read-only.
|
|
120
|
+
*/
|
|
121
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
122
|
+
export function planProofContractClaimPins(workspaceRoot, rows) {
|
|
123
|
+
const byTest = new Map((rows ?? []).map((row) => [row.test_id, row]));
|
|
124
|
+
const targets = [];
|
|
125
|
+
const review = [];
|
|
126
|
+
const skipped = [];
|
|
127
|
+
if (byTest.size === 0)
|
|
128
|
+
return { targets, review, skipped };
|
|
129
|
+
for (const file of listLaneMarkdownFiles(workspaceRoot, ["tests"])) {
|
|
130
|
+
const content = readText(file.absolutePath);
|
|
131
|
+
if (content === null)
|
|
132
|
+
continue;
|
|
133
|
+
const entity = readAuthoredEntity(content, file.relativePath);
|
|
134
|
+
const row = entity === null ? undefined : byTest.get(entity.id);
|
|
135
|
+
if (entity === null || row === undefined)
|
|
136
|
+
continue;
|
|
137
|
+
const keys = [
|
|
138
|
+
...new Set(row.candidates
|
|
139
|
+
.filter((c) => c.binding === "derived")
|
|
140
|
+
.map((c) => c.claim_key)),
|
|
141
|
+
].sort();
|
|
142
|
+
if (keys.length !== 1) {
|
|
143
|
+
review.push({
|
|
144
|
+
id: entity.id,
|
|
145
|
+
path: file.relativePath,
|
|
146
|
+
kind: row.kind,
|
|
147
|
+
candidates: row.candidates,
|
|
148
|
+
});
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const after = withProofContractProves(content, keys);
|
|
152
|
+
if (after === null) {
|
|
153
|
+
skipped.push({
|
|
154
|
+
id: entity.id,
|
|
155
|
+
path: file.relativePath,
|
|
156
|
+
reason: "its proof_contract is not a block mapping Kibi can extend in place",
|
|
157
|
+
});
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
targets.push({
|
|
161
|
+
id: entity.id,
|
|
162
|
+
type: "test",
|
|
163
|
+
path: file.relativePath,
|
|
164
|
+
before: content,
|
|
165
|
+
after,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return { targets, review, skipped };
|
|
169
|
+
}
|
|
170
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
171
|
+
export function applyProofContractClaimPins(workspaceRoot, rows) {
|
|
172
|
+
const plan = planProofContractClaimPins(workspaceRoot, rows);
|
|
173
|
+
for (const target of plan.targets)
|
|
174
|
+
writeFileAtomically(path.join(workspaceRoot, target.path), target.after);
|
|
175
|
+
return plan;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The claim candidates of every certificate contract without proves, read
|
|
179
|
+
* from the branch's compiled store. Returns null when no healthy, synced
|
|
180
|
+
* store is attached or the evaluation fails; the migration then pins
|
|
181
|
+
* nothing, and proof-contract-claims lists the contracts.
|
|
182
|
+
*/
|
|
183
|
+
// implements REQ-kibi-claim-bound-proofs, REQ-cli-schema-migration
|
|
184
|
+
export async function readProofContractClaimCandidates(workspaceRoot) {
|
|
185
|
+
try {
|
|
186
|
+
const [{ createCliRuntime }, { executeOperation }, { statusSpec }, { runOperationJsonQuery },] = await Promise.all([
|
|
187
|
+
import("../../runtime/cli-runtime.js"),
|
|
188
|
+
import("../../public/operations/runtime-types.js"),
|
|
189
|
+
import("../../public/operations/specs/discovery.js"),
|
|
190
|
+
import("../../public/operations/prolog-json.js"),
|
|
191
|
+
]);
|
|
192
|
+
const runtime = createCliRuntime({ workspaceRoot });
|
|
193
|
+
const status = (await executeOperation(runtime, statusSpec, {}))
|
|
194
|
+
.structuredContent;
|
|
195
|
+
if (status?.branchStore?.state !== "healthy" ||
|
|
196
|
+
status?.snapshotId === "missing" ||
|
|
197
|
+
status?.branchAttachment?.kind !== "exact")
|
|
198
|
+
return null;
|
|
199
|
+
const rows = await executeOperation(runtime, {
|
|
200
|
+
name: "kb_migrate_proof_contract_claims_preview",
|
|
201
|
+
effects: ["kb-read"],
|
|
202
|
+
requiresProlog: true,
|
|
203
|
+
execute: async (_input, context) => {
|
|
204
|
+
const prolog = context.prolog ?? (await context.ensureProlog?.());
|
|
205
|
+
if (prolog === undefined)
|
|
206
|
+
return [];
|
|
207
|
+
return runOperationJsonQuery(prolog, "claim_obligations.pl", "claim_obligations:proof_contract_claim_candidates_json(JsonString)", "Proof contract claim candidates");
|
|
208
|
+
},
|
|
209
|
+
}, {});
|
|
210
|
+
return Array.isArray(rows) ? rows : null;
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -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":"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"}
|