kibi-cli 1.0.1 → 2.1.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-errors.d.ts +3 -1
- package/dist/cli-errors.d.ts.map +1 -1
- package/dist/cli-errors.js +4 -1
- package/dist/cli-json-command.d.ts +1 -0
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +13 -4
- package/dist/cli-operation-loader.js +3 -3
- package/dist/cli-operation-metadata.d.ts +4 -3
- package/dist/cli-operation-metadata.d.ts.map +1 -1
- package/dist/cli-operation-metadata.js +7 -5
- package/dist/cli-protocol.js +1 -1
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +7 -0
- package/dist/cli-register-proof.d.ts +3 -0
- package/dist/cli-register-proof.d.ts.map +1 -0
- package/dist/cli-register-proof.js +127 -0
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +7 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +19 -10
- package/dist/commands/branch.d.ts +1 -0
- package/dist/commands/branch.d.ts.map +1 -1
- package/dist/commands/branch.js +8 -4
- package/dist/commands/check-generated.d.ts +7 -0
- package/dist/commands/check-generated.d.ts.map +1 -0
- package/dist/commands/check-generated.js +192 -0
- package/dist/commands/check.d.ts +14 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +193 -46
- package/dist/commands/coverage.d.ts +1 -0
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +6 -0
- package/dist/commands/doctor.d.ts +22 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +170 -23
- package/dist/commands/engine.d.ts +12 -0
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +42 -0
- package/dist/commands/github-init.d.ts +1 -0
- package/dist/commands/github-init.d.ts.map +1 -1
- package/dist/commands/github-init.js +9 -5
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +49 -10
- package/dist/commands/migrate.d.ts +4 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +7 -7
- package/dist/commands/proof-explain.d.ts +10 -0
- package/dist/commands/proof-explain.d.ts.map +1 -0
- package/dist/commands/proof-explain.js +45 -0
- package/dist/commands/proof-impact.d.ts +7 -0
- package/dist/commands/proof-impact.d.ts.map +1 -0
- package/dist/commands/proof-impact.js +39 -0
- package/dist/commands/proof-migrate-legacy.d.ts +7 -0
- package/dist/commands/proof-migrate-legacy.d.ts.map +1 -0
- package/dist/commands/proof-migrate-legacy.js +45 -0
- package/dist/commands/proof-prune.d.ts +8 -0
- package/dist/commands/proof-prune.d.ts.map +1 -0
- package/dist/commands/proof-prune.js +53 -0
- package/dist/commands/prove.d.ts +37 -0
- package/dist/commands/prove.d.ts.map +1 -0
- package/dist/commands/prove.js +470 -0
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +18 -3
- package/dist/commands/sync/discovery.d.ts +3 -0
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +36 -28
- package/dist/commands/sync/manifest.d.ts +2 -1
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +55 -21
- package/dist/commands/sync/persistence.d.ts +4 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +31 -14
- package/dist/commands/sync/staging.d.ts +1 -0
- package/dist/commands/sync/staging.d.ts.map +1 -1
- package/dist/commands/sync/staging.js +5 -2
- package/dist/commands/sync/untracked-targets.d.ts +24 -0
- package/dist/commands/sync/untracked-targets.d.ts.map +1 -0
- package/dist/commands/sync/untracked-targets.js +108 -0
- package/dist/commands/sync.d.ts +11 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +74 -30
- package/dist/engine-daemon.d.ts +3 -1
- package/dist/engine-daemon.d.ts.map +1 -1
- package/dist/engine-daemon.js +49 -20
- package/dist/engine.d.ts +17 -77
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +331 -91
- package/dist/env/bootstrap.d.ts +84 -0
- package/dist/env/bootstrap.d.ts.map +1 -0
- package/dist/env/bootstrap.js +310 -0
- package/dist/extractors/manifest.d.ts +5 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +46 -1
- package/dist/extractors/markdown.d.ts +7 -3
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +60 -24
- package/dist/extractors/playwright-cases.js +1 -1
- package/dist/extractors/relationships.d.ts +6 -0
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +1 -1
- package/dist/extractors/symbol-coordinates.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.d.ts +8 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +40 -0
- package/dist/extractors/symbols-ts.d.ts +9 -19
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +34 -429
- package/dist/intent-search.d.ts +1 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +11 -8
- package/dist/logic/ir.d.ts +1 -0
- package/dist/logic/ir.d.ts.map +1 -1
- package/dist/logic/ir.js +1 -1
- package/dist/operations/bootstrap/activation.d.ts +2 -1
- package/dist/operations/bootstrap/activation.d.ts.map +1 -1
- package/dist/operations/bootstrap/activation.js +11 -3
- package/dist/operations/bootstrap/generate.d.ts +2 -1
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +6 -3
- package/dist/operations/bootstrap/guidance.d.ts +1 -0
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +1 -1
- package/dist/operations/modeling/model-requirement.d.ts +5 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +57 -46
- package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applicability.js +103 -4
- package/dist/operations/modeling/predicate-catalog-2.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-2.js +18 -2
- package/dist/operations/modeling/predicate-catalog-3.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-3.js +17 -1
- package/dist/operations/modeling/predicate-catalog-5.d.ts +10 -0
- package/dist/operations/modeling/predicate-catalog-5.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-5.js +291 -0
- package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog.js +4 -0
- package/dist/operations/modeling/predicate-loader.d.ts +1 -0
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +4 -3
- package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-ranker.js +4 -1
- package/dist/operations/modeling/predicate-types.d.ts +1 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-usage-hints-4.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-4.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-4.js +84 -0
- package/dist/operations/modeling/suggest-predicates.d.ts +4 -2
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +82 -22
- package/dist/operations/mutation/contradictions.d.ts +2 -1
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +26 -5
- package/dist/operations/mutation/delete.d.ts +3 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +100 -32
- package/dist/operations/mutation/relationships.d.ts +1 -0
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +6 -4
- package/dist/operations/mutation/saga.d.ts +51 -0
- package/dist/operations/mutation/saga.d.ts.map +1 -0
- package/dist/operations/mutation/saga.js +67 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +3 -2
- package/dist/operations/mutation/source-authoring.d.ts +5 -1
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +79 -46
- package/dist/operations/mutation/strict-fact.d.ts +1 -0
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +8 -5
- package/dist/operations/mutation/symbol-compiler-lock.d.ts +5 -2
- package/dist/operations/mutation/symbol-compiler-lock.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-compiler-lock.js +65 -2
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +11 -89
- package/dist/operations/mutation/symbol-refresh.d.ts +1 -0
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +10 -8
- package/dist/operations/mutation/upsert.d.ts +18 -2
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +86 -54
- package/dist/operations/mutation/validate-upsert.js +2 -2
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +46 -4
- package/dist/operations/mutation/warnings.d.ts +1 -0
- package/dist/operations/mutation/warnings.d.ts.map +1 -1
- package/dist/operations/mutation/warnings.js +7 -5
- package/dist/operations/mutation/workspace-mutation-lock.d.ts +60 -0
- package/dist/operations/mutation/workspace-mutation-lock.d.ts.map +1 -0
- package/dist/operations/mutation/workspace-mutation-lock.js +362 -0
- package/dist/operations/planning/apply-plan.d.ts +8 -106
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +113 -36
- package/dist/operations/planning/compile-intent.d.ts +51 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +133 -17
- package/dist/operations/proof/baseline-diff.d.ts +41 -0
- package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
- package/dist/operations/proof/baseline-diff.js +153 -0
- package/dist/operations/proof/explain.d.ts +75 -0
- package/dist/operations/proof/explain.d.ts.map +1 -0
- package/dist/operations/proof/explain.js +294 -0
- package/dist/operations/proof/impact.d.ts +45 -0
- package/dist/operations/proof/impact.d.ts.map +1 -0
- package/dist/operations/proof/impact.js +118 -0
- package/dist/operations/proof/ingest-proof.d.ts +34 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -0
- package/dist/operations/proof/ingest-proof.js +348 -0
- package/dist/operations/proof/migrate-legacy-receipts.d.ts +30 -0
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -0
- package/dist/operations/proof/migrate-legacy-receipts.js +92 -0
- package/dist/operations/proof/prune-receipts.d.ts +35 -0
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -0
- package/dist/operations/proof/prune-receipts.js +91 -0
- package/dist/operations/proof/receipt-document.d.ts +29 -0
- package/dist/operations/proof/receipt-document.d.ts.map +1 -0
- package/dist/operations/proof/receipt-document.js +117 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +1 -0
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +64 -93
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +20 -7
- package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
- package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
- package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
- package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
- package/dist/operations/semantic-advisor/strict-count-rules.d.ts +2 -0
- package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/strict-count-rules.js +40 -25
- package/dist/operations/semantic-advisor/types.d.ts +1 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/plugins/compose-ontology-packs.d.ts +51 -0
- package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
- package/dist/plugins/compose-ontology-packs.js +257 -0
- package/dist/plugins/compose-semantic-classifier.d.ts +42 -0
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
- package/dist/plugins/compose-semantic-classifier.js +211 -0
- package/dist/plugins/external-allowlist.d.ts +10 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -0
- package/dist/plugins/external-allowlist.js +16 -0
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +33 -0
- package/dist/plugins/load-plugin.d.ts +19 -0
- package/dist/plugins/load-plugin.d.ts.map +1 -0
- package/dist/plugins/load-plugin.js +59 -0
- package/dist/plugins/project-config.d.ts +28 -0
- package/dist/plugins/project-config.d.ts.map +1 -0
- package/dist/plugins/project-config.js +90 -0
- package/dist/plugins/registry.d.ts +93 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +338 -0
- package/dist/plugins/resolve-package.d.ts +47 -0
- package/dist/plugins/resolve-package.d.ts.map +1 -0
- package/dist/plugins/resolve-package.js +262 -0
- package/dist/plugins/source-analysis-service.d.ts +44 -0
- package/dist/plugins/source-analysis-service.d.ts.map +1 -0
- package/dist/plugins/source-analysis-service.js +232 -0
- package/dist/prolog/codec.d.ts +13 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +269 -154
- package/dist/prolog/error-terms.d.ts +47 -0
- package/dist/prolog/error-terms.d.ts.map +1 -0
- package/dist/prolog/error-terms.js +334 -0
- package/dist/prolog/janitor.d.ts +50 -0
- package/dist/prolog/janitor.d.ts.map +1 -0
- package/dist/prolog/janitor.js +154 -0
- package/dist/prolog/store-lock.d.ts +45 -0
- package/dist/prolog/store-lock.d.ts.map +1 -0
- package/dist/prolog/store-lock.js +195 -0
- package/dist/prolog.d.ts +7 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +55 -17
- package/dist/proof/evaluate.d.ts +27 -0
- package/dist/proof/evaluate.d.ts.map +1 -0
- package/dist/proof/evaluate.js +151 -0
- package/dist/proof/inspect.d.ts +12 -0
- package/dist/proof/inspect.d.ts.map +1 -0
- package/dist/proof/inspect.js +236 -0
- package/dist/proof/integrations.d.ts +35 -0
- package/dist/proof/integrations.d.ts.map +1 -0
- package/dist/proof/integrations.js +123 -0
- package/dist/proof/producers/junit-adapter.d.ts +26 -0
- package/dist/proof/producers/junit-adapter.d.ts.map +1 -0
- package/dist/proof/producers/junit-adapter.js +186 -0
- package/dist/{public → proof/producers}/playwright-case-id.d.ts +1 -1
- package/dist/proof/producers/playwright-case-id.d.ts.map +1 -0
- package/dist/{public → proof/producers}/playwright-case-id.js +1 -1
- package/dist/proof/producers/playwright-reporter.d.ts +27 -0
- package/dist/proof/producers/playwright-reporter.d.ts.map +1 -0
- package/dist/proof/producers/playwright-reporter.js +138 -0
- package/dist/proof/producers/tap-adapter.d.ts +10 -0
- package/dist/proof/producers/tap-adapter.d.ts.map +1 -0
- package/dist/proof/producers/tap-adapter.js +200 -0
- package/dist/proof/receipt-outcome.d.ts +2 -0
- package/dist/proof/receipt-outcome.d.ts.map +1 -0
- package/dist/proof/receipt-outcome.js +1 -0
- package/dist/public/diagnostic-usage.js +6 -6
- package/dist/public/distribution-parity.d.ts +7 -1
- package/dist/public/distribution-parity.d.ts.map +1 -1
- package/dist/public/distribution-parity.js +15 -10
- package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
- package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/public/extractors/symbols-coordinator.js +1 -1
- package/dist/public/impact/analyzer.d.ts +1 -1
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +6 -4
- package/dist/public/impact/coverage-depth-quality.d.ts +1 -0
- package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
- package/dist/public/impact/coverage-depth-quality.js +1 -1
- package/dist/public/impact/diagnostics.d.ts.map +1 -1
- package/dist/public/impact/diagnostics.js +2 -2
- package/dist/public/impact/diff-meaning.d.ts +1 -0
- package/dist/public/impact/diff-meaning.d.ts.map +1 -1
- package/dist/public/impact/diff-meaning.js +5 -2
- package/dist/public/impact/full-kb-quality.d.ts +5 -2
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +329 -64
- package/dist/public/operations/catalog.d.ts +450 -196
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/catalog.js +6 -4
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +4 -8
- package/dist/public/operations/check-helpers.d.ts +1 -1
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +1 -1
- package/dist/public/operations/contracts.d.ts +7 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +66 -34
- package/dist/public/operations/discovery-entities.d.ts +15 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +38 -0
- package/dist/public/operations/discovery-executors.d.ts +9 -9
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +39 -31
- package/dist/public/operations/index.d.ts +1 -1
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +1 -1
- package/dist/public/operations/migration-plan.d.ts +4 -3
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +23 -21
- package/dist/public/operations/node-ports.js +6 -6
- package/dist/public/operations/prolog-json.d.ts +1 -1
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +7 -7
- package/dist/public/operations/repair-plan.d.ts +3 -3
- package/dist/public/operations/repair-plan.d.ts.map +1 -1
- package/dist/public/operations/repair-plan.js +49 -19
- package/dist/public/operations/result-envelope.d.ts +1 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +12 -10
- package/dist/public/operations/runtime-types.d.ts +21 -1
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +5 -0
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -0
- package/dist/public/operations/specs/check-rules.generated.js +35 -0
- package/dist/public/operations/specs/check.d.ts +7 -2
- package/dist/public/operations/specs/check.d.ts.map +1 -1
- package/dist/public/operations/specs/check.js +8 -20
- package/dist/public/operations/specs/discovery.d.ts +3 -0
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +3 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts +257 -163
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +15 -7
- package/dist/public/operations/specs/planning.d.ts +9 -0
- package/dist/public/operations/specs/planning.d.ts.map +1 -1
- package/dist/public/operations/specs/planning.js +6 -0
- package/dist/public/operations/specs/proof.d.ts +212 -0
- package/dist/public/operations/specs/proof.d.ts.map +1 -0
- package/dist/public/operations/specs/proof.js +30 -0
- package/dist/public/operations/specs/reporting.d.ts +20 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +112 -12
- package/dist/public/operations/specs/semantic.d.ts +1 -1
- package/dist/public/operations/specs/semantic.d.ts.map +1 -1
- package/dist/public/operations/specs/semantic.js +54 -4
- package/dist/public/operations/specs/upsert.d.ts +257 -163
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.d.ts +11 -0
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +121 -4
- package/dist/public/operations/types.d.ts +6 -1
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/proof-fingerprint.d.ts +54 -0
- package/dist/public/proof-fingerprint.d.ts.map +1 -0
- package/dist/public/proof-fingerprint.js +141 -0
- package/dist/public/proof-protocol.d.ts +354 -0
- package/dist/public/proof-protocol.d.ts.map +1 -0
- package/dist/public/proof-protocol.js +454 -0
- package/dist/public/proof-receipt.d.ts +279 -0
- package/dist/public/proof-receipt.d.ts.map +1 -0
- package/dist/public/proof-receipt.js +377 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +21 -7
- package/dist/public/skills/kibi-freshness/SKILL.md +1 -1
- package/dist/public/skills/kibi-usage/SKILL.md +44 -12
- package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/dist/public/skills/kibi-usage/resources/proof.md +150 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +6 -6
- package/dist/public/symbol-granularity.d.ts +3 -14
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.generated.d.ts +16 -0
- package/dist/public/symbol-granularity.generated.d.ts.map +1 -0
- package/dist/public/symbol-granularity.generated.js +53 -0
- package/dist/public/symbol-granularity.js +6 -47
- package/dist/public/telemetry-acceptance.d.ts +3 -77
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +4 -2
- package/dist/public/telemetry-remediation.js +1 -1
- package/dist/report/html-report.css +1240 -0
- package/dist/report/html-report.d.ts +4 -2
- package/dist/report/html-report.d.ts.map +1 -1
- package/dist/report/html-report.js +37 -300
- package/dist/runtime/cli-runtime.d.ts +2 -0
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +32 -7
- package/dist/schemas/entity.schema.json +355 -215
- package/dist/search-ranking.d.ts +1 -0
- package/dist/search-ranking.d.ts.map +1 -1
- package/dist/search-ranking.js +3 -0
- package/dist/traceability/evidence-model.d.ts +28 -0
- package/dist/traceability/evidence-model.d.ts.map +1 -1
- package/dist/traceability/git-staged.d.ts +20 -0
- package/dist/traceability/git-staged.d.ts.map +1 -1
- package/dist/traceability/git-staged.js +145 -1
- package/dist/traceability/staged-diagnostics.d.ts +7 -0
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-diagnostics.js +78 -7
- package/dist/traceability/staged-file-coverage.d.ts +33 -0
- package/dist/traceability/staged-file-coverage.d.ts.map +1 -0
- package/dist/traceability/staged-file-coverage.js +284 -0
- package/dist/traceability/staged-impact-contract.js +4 -4
- package/dist/traceability/staged-symbols-manifest.d.ts +13 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +138 -27
- package/dist/traceability/symbol-extract.d.ts +24 -2
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +64 -208
- package/dist/traceability/temp-kb.d.ts +2 -0
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +13 -4
- package/dist/types/entities.d.ts +5 -3
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/branch-resolver.d.ts +1 -0
- package/dist/utils/branch-resolver.d.ts.map +1 -1
- package/dist/utils/branch-resolver.js +7 -4
- package/dist/utils/branch-store.d.ts +6 -0
- package/dist/utils/branch-store.d.ts.map +1 -1
- package/dist/utils/branch-store.js +27 -0
- package/dist/utils/kb-paths.d.ts +1 -1
- package/dist/utils/kb-paths.d.ts.map +1 -1
- package/dist/utils/kb-paths.js +1 -1
- package/dist/utils/rule-registry.d.ts +1 -11
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.d.ts +102 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -0
- package/dist/utils/rule-registry.generated.js +131 -0
- package/dist/utils/rule-registry.js +12 -113
- package/dist/utils/strict-modeling.d.ts +1 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +1 -1
- package/package.json +20 -20
- package/src/public/diagnostic-usage.ts +6 -6
- package/src/public/distribution-parity.ts +17 -10
- package/src/public/extractors/symbols-coordinator.ts +1 -0
- package/src/public/impact/analyzer.ts +15 -12
- package/src/public/impact/coverage-depth-quality.ts +1 -1
- package/src/public/impact/diagnostics.ts +2 -1
- package/src/public/impact/diff-meaning.ts +11 -4
- package/src/public/impact/full-kb-quality.ts +463 -72
- package/src/public/operations/catalog.ts +10 -4
- package/src/public/operations/check-executor.ts +4 -8
- package/src/public/operations/check-helpers.ts +2 -2
- package/src/public/operations/contracts.ts +78 -34
- package/src/public/operations/discovery-entities.ts +53 -0
- package/src/public/operations/discovery-executors.ts +64 -48
- package/src/public/operations/index.ts +1 -1
- package/src/public/operations/migration-plan.ts +32 -25
- package/src/public/operations/node-ports.ts +6 -6
- package/src/public/operations/prolog-json.ts +13 -5
- package/src/public/operations/repair-plan.ts +60 -23
- package/src/public/operations/result-envelope.ts +15 -10
- package/src/public/operations/runtime-types.ts +26 -2
- package/src/public/operations/specs/check-rules.generated.ts +38 -0
- package/src/public/operations/specs/check.ts +12 -21
- package/src/public/operations/specs/discovery.ts +3 -0
- package/src/public/operations/specs/mutation-schemas.ts +22 -9
- package/src/public/operations/specs/planning.ts +7 -0
- package/src/public/operations/specs/proof.ts +43 -0
- package/src/public/operations/specs/reporting.ts +140 -13
- package/src/public/operations/specs/semantic.ts +79 -17
- package/src/public/operations/symbol-repair-plan.ts +166 -7
- package/src/public/operations/types.ts +6 -1
- package/src/public/proof-fingerprint.ts +216 -0
- package/src/public/proof-protocol-types.d.ts +96 -0
- package/src/public/proof-protocol.ts +589 -0
- package/src/public/proof-receipt.ts +499 -0
- package/src/public/schemas/entity.ts +26 -10
- package/src/public/skills/kibi-freshness/SKILL.md +1 -1
- package/src/public/skills/kibi-usage/SKILL.md +44 -12
- package/src/public/skills/kibi-usage/resources/operation-access.md +1 -1
- package/src/public/skills/kibi-usage/resources/proof.md +150 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +6 -6
- package/src/public/symbol-granularity.generated.ts +74 -0
- package/src/public/symbol-granularity.ts +34 -59
- package/src/public/telemetry-acceptance-types.d.ts +98 -0
- package/src/public/telemetry-acceptance.ts +22 -100
- package/src/public/telemetry-remediation.ts +1 -1
- package/src/schemas/entity.schema.json +355 -215
- package/dist/cli-register-verification.d.ts +0 -3
- package/dist/cli-register-verification.d.ts.map +0 -1
- package/dist/cli-register-verification.js +0 -16
- package/dist/commands/verify.d.ts +0 -10
- package/dist/commands/verify.d.ts.map +0 -1
- package/dist/commands/verify.js +0 -126
- package/dist/operations/verification/ingest-verification.d.ts +0 -29
- package/dist/operations/verification/ingest-verification.d.ts.map +0 -1
- package/dist/operations/verification/ingest-verification.js +0 -192
- package/dist/public/operations/specs/verification.d.ts +0 -78
- package/dist/public/operations/specs/verification.d.ts.map +0 -1
- package/dist/public/operations/specs/verification.js +0 -62
- package/dist/public/playwright-case-id.d.ts.map +0 -1
- package/dist/public/verification-receipt.d.ts +0 -242
- package/dist/public/verification-receipt.d.ts.map +0 -1
- package/dist/public/verification-receipt.js +0 -296
- package/dist/verification/playwright-reporter.d.ts +0 -21
- package/dist/verification/playwright-reporter.d.ts.map +0 -1
- package/dist/verification/playwright-reporter.js +0 -114
- package/src/public/operations/specs/verification.ts +0 -78
- package/src/public/playwright-case-id.ts +0 -35
- package/src/public/verification-receipt.ts +0 -412
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
import { execFileSync } from "node:child_process";
|
|
11
|
+
import { executeCoverage } from "../../public/operations/specs/reporting.js";
|
|
12
|
+
import { diffFingerprints, fingerprintRequirements, renderRequirementDiffs, } from "./baseline-diff.js";
|
|
13
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
14
|
+
export const COMMITTED_BASELINE_PATH = "proof/baseline.json";
|
|
15
|
+
function asNumber(value) {
|
|
16
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
17
|
+
}
|
|
18
|
+
function gitErrorText(error) {
|
|
19
|
+
if (error && typeof error === "object" && "stderr" in error) {
|
|
20
|
+
const stderr = error.stderr;
|
|
21
|
+
if (typeof stderr === "string" && stderr.trim() !== "")
|
|
22
|
+
return stderr;
|
|
23
|
+
if (Buffer.isBuffer(stderr) && stderr.length > 0) {
|
|
24
|
+
return stderr.toString("utf8");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return error instanceof Error ? error.message : String(error);
|
|
28
|
+
}
|
|
29
|
+
function committedBaselineReadError(relativePath, error) {
|
|
30
|
+
const text = gitErrorText(error);
|
|
31
|
+
if (/not a git repository/i.test(text) ||
|
|
32
|
+
/ambiguous argument 'HEAD'/i.test(text) ||
|
|
33
|
+
/unknown revision/i.test(text) ||
|
|
34
|
+
/needed a single revision/i.test(text) ||
|
|
35
|
+
/bad revision 'HEAD'/i.test(text)) {
|
|
36
|
+
return new Error(`proof impact: repository is not in a suitable Git state to read HEAD:${relativePath}`);
|
|
37
|
+
}
|
|
38
|
+
if (/does not exist in 'HEAD'/i.test(text) ||
|
|
39
|
+
/exists on disk, but not in 'HEAD'/i.test(text) ||
|
|
40
|
+
/path '.*' does not exist/i.test(text)) {
|
|
41
|
+
return new Error(`proof impact: HEAD:${relativePath} is missing or unreadable`);
|
|
42
|
+
}
|
|
43
|
+
return new Error(`proof impact: could not read HEAD:${relativePath}: ${text.trim()}`);
|
|
44
|
+
}
|
|
45
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
46
|
+
export function readCommittedHeadFile(workspaceRoot, relativePath) {
|
|
47
|
+
try {
|
|
48
|
+
return execFileSync("git", ["-C", workspaceRoot, "show", `HEAD:${relativePath}`], {
|
|
49
|
+
encoding: "utf8",
|
|
50
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
51
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw committedBaselineReadError(relativePath, error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
59
|
+
export async function loadCommittedBaseline(workspaceRoot, readCommittedFile = readCommittedHeadFile) {
|
|
60
|
+
const raw = await readCommittedFile(workspaceRoot, COMMITTED_BASELINE_PATH);
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(raw);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new Error(`proof impact: HEAD:${COMMITTED_BASELINE_PATH} is not valid JSON`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Diagnostic only: successful evaluation always exits 0. Ratchet lives in check-proof-baseline.mjs. */
|
|
69
|
+
export function proofImpactExitCode(_result) {
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
73
|
+
export function buildProofImpact(baseline, coverage) {
|
|
74
|
+
const rows = Array.isArray(coverage.rows)
|
|
75
|
+
? coverage.rows
|
|
76
|
+
: [];
|
|
77
|
+
const summary = coverage.summary ?? {};
|
|
78
|
+
const proofNotApplicable = asNumber(summary.proofNotApplicable);
|
|
79
|
+
const total = asNumber(summary.total);
|
|
80
|
+
const proofProven = asNumber(summary.proofProven);
|
|
81
|
+
const currentUnproven = asNumber(summary.proofMissing) + asNumber(summary.proofUnresolved);
|
|
82
|
+
const current = fingerprintRequirements(rows);
|
|
83
|
+
const changes = diffFingerprints(baseline.requirements, current);
|
|
84
|
+
return {
|
|
85
|
+
rows,
|
|
86
|
+
result: {
|
|
87
|
+
comparisonTarget: COMMITTED_BASELINE_PATH,
|
|
88
|
+
baselineVersion: baseline.version ?? "unknown",
|
|
89
|
+
currentRequirements: total - proofNotApplicable,
|
|
90
|
+
proofProven,
|
|
91
|
+
currentUnproven,
|
|
92
|
+
changes,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
97
|
+
export function renderProofImpact(result, rows) {
|
|
98
|
+
const header = [
|
|
99
|
+
`Proof impact compared to committed ${result.comparisonTarget}`,
|
|
100
|
+
`baseline version: ${result.baselineVersion}`,
|
|
101
|
+
`current requirements: ${result.currentRequirements}`,
|
|
102
|
+
`proofProven: ${result.proofProven}`,
|
|
103
|
+
`currentUnproven: ${result.currentUnproven}`,
|
|
104
|
+
`changed requirements: ${result.changes.length}`,
|
|
105
|
+
"",
|
|
106
|
+
];
|
|
107
|
+
const diff = renderRequirementDiffs(result.changes, rows);
|
|
108
|
+
return `${header.join("\n")}${diff || "No requirement fingerprint changes versus the committed baseline.\n"}`;
|
|
109
|
+
}
|
|
110
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
111
|
+
export async function executeProofImpact(context, options = {}) {
|
|
112
|
+
const baseline = await loadCommittedBaseline(context.workspaceRoot, options.readCommittedFile ?? readCommittedHeadFile);
|
|
113
|
+
const coverage = options.loadCoverage
|
|
114
|
+
? await options.loadCoverage(context)
|
|
115
|
+
: await executeCoverage({ by: "req", includePassing: true, limit: 100_000, offset: 0 }, context);
|
|
116
|
+
const { result, rows } = buildProofImpact(baseline, coverage.structuredContent);
|
|
117
|
+
return { result, rows, text: renderProofImpact(result, rows) };
|
|
118
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ProofGap } from "../../proof/evaluate.js";
|
|
2
|
+
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
3
|
+
import { type ProofReceipt } from "../../public/proof-receipt.js";
|
|
4
|
+
export type IngestProofArgs = Readonly<{
|
|
5
|
+
snapshot: string;
|
|
6
|
+
artifact: Readonly<Record<string, unknown>>;
|
|
7
|
+
testIds?: readonly string[];
|
|
8
|
+
}>;
|
|
9
|
+
export type IngestProofTestResult = Readonly<{
|
|
10
|
+
testId: string;
|
|
11
|
+
outcome: ProofReceipt["outcome"];
|
|
12
|
+
receiptId: string;
|
|
13
|
+
applied: boolean;
|
|
14
|
+
duplicate: boolean;
|
|
15
|
+
receiptCount: number;
|
|
16
|
+
gaps: readonly ProofGap[];
|
|
17
|
+
}>;
|
|
18
|
+
export type IngestProofResult = Readonly<{
|
|
19
|
+
artifactDigest: string;
|
|
20
|
+
environmentHash: string;
|
|
21
|
+
integration: string | null;
|
|
22
|
+
passed: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
unchanged: number;
|
|
25
|
+
results: readonly IngestProofTestResult[];
|
|
26
|
+
}>;
|
|
27
|
+
export declare function executeIngestProof(args: IngestProofArgs, context: OperationContext): Promise<{
|
|
28
|
+
content: Array<{
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}>;
|
|
32
|
+
structuredContent: IngestProofResult;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=ingest-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest-proof.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/ingest-proof.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAkBjF,OAAO,EAEL,KAAK,YAAY,EAGlB,MAAM,+BAA+B,CAAC;AAUvC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC3B,CAAC,CAAC;AAGH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC3C,CAAC,CAAC;AAoKH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,CAAC,CAgSD"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { resolveBoundSymbolScope } from "../../extractors/manifest.js";
|
|
3
|
+
import { evaluateContractAgainstRun, } from "../../proof/evaluate.js";
|
|
4
|
+
import { loadProofIntegrations, resolveIntegration, toExecution, } from "../../proof/integrations.js";
|
|
5
|
+
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
6
|
+
import { readWorkspaceSnapshot } from "../../public/operations/workspace-snapshot.js";
|
|
7
|
+
import { environmentHash as canonicalEnvironmentHash, effectiveProofFingerprint, jsonDigest, proofContractHash, receiptBindingHash, } from "../../public/proof-fingerprint.js";
|
|
8
|
+
import { PROOF_CONTRACT_VERSION, PROOF_RECEIPT_VERSION, proofBindingsErrors, proofRunArtifactErrors, } from "../../public/proof-protocol.js";
|
|
9
|
+
import { MAX_PROOF_RECEIPTS, proofReceiptCurrentBindingErrors, proofReceiptHistoryErrors, } from "../../public/proof-receipt.js";
|
|
10
|
+
import { projectEntityProperties } from "../mutation/entity-projection.js";
|
|
11
|
+
import { resolveContainedSourcePath } from "../mutation/source-authoring.js";
|
|
12
|
+
import { executeUpsert } from "../mutation/upsert.js";
|
|
13
|
+
import { patchReceiptsIntoDocument, removeFrontmatterBlock, } from "./receipt-document.js";
|
|
14
|
+
function text(value) {
|
|
15
|
+
return typeof value === "string" ? value.trim() : "";
|
|
16
|
+
}
|
|
17
|
+
function record(value) {
|
|
18
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
19
|
+
? value
|
|
20
|
+
: null;
|
|
21
|
+
}
|
|
22
|
+
function requiredString(value, label) {
|
|
23
|
+
const result = text(value);
|
|
24
|
+
if (!result)
|
|
25
|
+
throw new Error(`Proof ingest failed: ${label} must be non-empty`);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function parseContract(test) {
|
|
29
|
+
const contract = record(test.proof_contract);
|
|
30
|
+
const candidate = contract ?? {};
|
|
31
|
+
const { version, integration, required_proofs, success_policy } = candidate;
|
|
32
|
+
const normalized = {
|
|
33
|
+
version: version,
|
|
34
|
+
integration: String(integration ?? ""),
|
|
35
|
+
required_proofs: Array.isArray(required_proofs)
|
|
36
|
+
? required_proofs.map((entry) => {
|
|
37
|
+
const row = record(entry);
|
|
38
|
+
return {
|
|
39
|
+
symbol_id: String(row?.symbol_id ?? ""),
|
|
40
|
+
target: String(row?.target ?? ""),
|
|
41
|
+
};
|
|
42
|
+
})
|
|
43
|
+
: [],
|
|
44
|
+
success_policy: success_policy,
|
|
45
|
+
};
|
|
46
|
+
if (!contract || contract.version !== PROOF_CONTRACT_VERSION)
|
|
47
|
+
throw new Error(`Proof ingest failed: test ${String(test.id)} has no proof_contract (${PROOF_CONTRACT_VERSION})`);
|
|
48
|
+
return normalized;
|
|
49
|
+
}
|
|
50
|
+
function parseBindings(test) {
|
|
51
|
+
const raw = test.proof_bindings;
|
|
52
|
+
if (raw === undefined || raw === null)
|
|
53
|
+
return [];
|
|
54
|
+
if (!Array.isArray(raw))
|
|
55
|
+
throw new Error(`Proof ingest failed: test ${String(test.id)} proof_bindings must be an array`);
|
|
56
|
+
const errors = proofBindingsErrors(raw);
|
|
57
|
+
if (errors.length > 0)
|
|
58
|
+
throw new Error(`Proof ingest failed: test ${String(test.id)} ${errors.join("; ")}`);
|
|
59
|
+
return raw.map((entry) => {
|
|
60
|
+
const row = record(entry) ?? {};
|
|
61
|
+
return {
|
|
62
|
+
symbol_id: String(row.symbol_id ?? ""),
|
|
63
|
+
target: String(row.target ?? ""),
|
|
64
|
+
...(row.native_id !== undefined
|
|
65
|
+
? { native_id: String(row.native_id) }
|
|
66
|
+
: {}),
|
|
67
|
+
...(row.aliases !== undefined
|
|
68
|
+
? { aliases: row.aliases.map(String) }
|
|
69
|
+
: {}),
|
|
70
|
+
...(row.source_file !== undefined
|
|
71
|
+
? { source_file: String(row.source_file) }
|
|
72
|
+
: {}),
|
|
73
|
+
...(row.line !== undefined ? { line: Number(row.line) } : {}),
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function enforceNativeCaseBindings(testId, contract, bindings, artifact) {
|
|
78
|
+
const requiredKeys = new Set(contract.required_proofs.map((obligation) => `${obligation.target}\0${obligation.symbol_id}`));
|
|
79
|
+
const nativeResults = artifact.proof_results.filter((result) => result.binding === "native_case" &&
|
|
80
|
+
requiredKeys.has(`${result.target}\0${result.symbol_id}`));
|
|
81
|
+
const seenNativeIds = new Set();
|
|
82
|
+
for (const result of nativeResults) {
|
|
83
|
+
const nativeId = typeof result.native_id === "string" ? result.native_id : "";
|
|
84
|
+
const resultLabel = `${result.symbol_id}/${result.target}`;
|
|
85
|
+
if (!nativeId) {
|
|
86
|
+
throw new Error(`Proof ingest failed: test ${testId} native_case result ${resultLabel} has no native_id`);
|
|
87
|
+
}
|
|
88
|
+
if (seenNativeIds.has(nativeId)) {
|
|
89
|
+
throw new Error(`Proof ingest failed: test ${testId} duplicate native result for native_id '${nativeId}'`);
|
|
90
|
+
}
|
|
91
|
+
seenNativeIds.add(nativeId);
|
|
92
|
+
const matchingBindings = bindings.filter((binding) => binding.symbol_id === result.symbol_id &&
|
|
93
|
+
binding.target === result.target);
|
|
94
|
+
if (matchingBindings.length === 0) {
|
|
95
|
+
throw new Error(`Proof ingest failed: test ${testId} native_case result ${resultLabel} has no matching proof_binding`);
|
|
96
|
+
}
|
|
97
|
+
if (matchingBindings.length !== 1) {
|
|
98
|
+
throw new Error(`Proof ingest failed: test ${testId} native_case result ${resultLabel} has an ambiguous proof_binding`);
|
|
99
|
+
}
|
|
100
|
+
const binding = matchingBindings[0];
|
|
101
|
+
if (binding === undefined) {
|
|
102
|
+
throw new Error(`Proof ingest failed: test ${testId} native_case result ${resultLabel} has an ambiguous proof_binding`);
|
|
103
|
+
}
|
|
104
|
+
const boundNativeIds = [
|
|
105
|
+
binding.native_id,
|
|
106
|
+
...(binding.aliases ?? []),
|
|
107
|
+
].filter((value) => typeof value === "string" && value !== "");
|
|
108
|
+
if (!boundNativeIds.includes(nativeId)) {
|
|
109
|
+
throw new Error(`Proof ingest failed: test ${testId} native_case result ${resultLabel} native_id '${nativeId}' does not match its proof_binding native_id or aliases`);
|
|
110
|
+
}
|
|
111
|
+
const ambiguousOwners = bindings.filter((candidate) => [candidate.native_id, ...(candidate.aliases ?? [])].includes(nativeId));
|
|
112
|
+
if (ambiguousOwners.length !== 1) {
|
|
113
|
+
throw new Error(`Proof ingest failed: test ${testId} native_id '${nativeId}' has an ambiguous proof_binding`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function existingReceipts(test) {
|
|
118
|
+
return Array.isArray(test.proof_receipts)
|
|
119
|
+
? test.proof_receipts.filter(record).map((value) => ({ ...value }))
|
|
120
|
+
: [];
|
|
121
|
+
}
|
|
122
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
123
|
+
export async function executeIngestProof(args, context) {
|
|
124
|
+
if (!context.prolog)
|
|
125
|
+
throw new Error("Proof ingest requires a Prolog runtime");
|
|
126
|
+
const snapshot = requiredString(args.snapshot, "snapshot");
|
|
127
|
+
const artifactValue = record(args.artifact);
|
|
128
|
+
if (!artifactValue)
|
|
129
|
+
throw new Error("Proof ingest failed: artifact must be a kibi.proof-run.v1 object with version, producer, command_argv, code_snapshot, environment, run, and proof_results");
|
|
130
|
+
// One generic pipeline: validate, bind, fingerprint, evaluate, derive, apply.
|
|
131
|
+
const artifactErrors = proofRunArtifactErrors(artifactValue);
|
|
132
|
+
if (artifactErrors.length > 0)
|
|
133
|
+
throw new Error(`Proof ingest failed: ${artifactErrors.join("; ")}`);
|
|
134
|
+
const artifact = artifactValue;
|
|
135
|
+
const workspace = await readWorkspaceSnapshot(context);
|
|
136
|
+
if (!workspace.available)
|
|
137
|
+
throw new Error(`Proof ingest failed: ${workspace.error}`);
|
|
138
|
+
if (workspace.snapshot.hash !== snapshot)
|
|
139
|
+
throw new Error("Proof ingest failed: captured snapshot is not the live workspace snapshot");
|
|
140
|
+
if (artifact.code_snapshot !== snapshot)
|
|
141
|
+
throw new Error("Proof ingest failed: artifact code_snapshot does not match captured snapshot");
|
|
142
|
+
const requestedTestIds = args.testIds?.map((id) => requiredString(id, "testIds")) ?? [];
|
|
143
|
+
if (new Set(requestedTestIds).size !== requestedTestIds.length)
|
|
144
|
+
throw new Error("Proof ingest failed: testIds contains duplicates");
|
|
145
|
+
if (requestedTestIds.length === 0 && text(artifact.integration) === "")
|
|
146
|
+
throw new Error("Proof ingest failed: provide testIds, or set artifact.integration to select the contracted tests this artifact is evaluated against");
|
|
147
|
+
const integrationId = text(artifact.integration) || null;
|
|
148
|
+
const integrations = loadProofIntegrations(context.workspaceRoot);
|
|
149
|
+
if (!integrations.available)
|
|
150
|
+
throw new Error(`Proof ingest failed: ${integrations.error}`);
|
|
151
|
+
const tests = [];
|
|
152
|
+
if (requestedTestIds.length > 0) {
|
|
153
|
+
for (const testId of requestedTestIds) {
|
|
154
|
+
const found = await loadEntities(context.prolog, {
|
|
155
|
+
id: testId,
|
|
156
|
+
type: "test",
|
|
157
|
+
});
|
|
158
|
+
const test = found[0];
|
|
159
|
+
if (!test)
|
|
160
|
+
throw new Error(`Proof ingest failed: test ${testId} was not found`);
|
|
161
|
+
tests.push(test);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const all = await loadEntities(context.prolog, { type: "test" });
|
|
166
|
+
for (const test of all) {
|
|
167
|
+
const contract = record(test.proof_contract);
|
|
168
|
+
if (contract &&
|
|
169
|
+
contract.version === PROOF_CONTRACT_VERSION &&
|
|
170
|
+
text(contract.integration) === integrationId) {
|
|
171
|
+
tests.push(test);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (tests.length === 0)
|
|
175
|
+
throw new Error(`Proof ingest failed: no tests declare proof_contract.integration '${integrationId}'`);
|
|
176
|
+
}
|
|
177
|
+
const prepared = [];
|
|
178
|
+
for (const test of tests) {
|
|
179
|
+
const testId = String(test.id);
|
|
180
|
+
const contract = parseContract(test);
|
|
181
|
+
if (integrationId !== null && contract.integration !== integrationId)
|
|
182
|
+
throw new Error(`Proof ingest failed: test ${testId} binds integration '${contract.integration}' but the artifact was produced by '${integrationId}'`);
|
|
183
|
+
const effectiveIntegrationId = integrationId ?? contract.integration;
|
|
184
|
+
const integration = resolveIntegration(integrations.integrations, effectiveIntegrationId);
|
|
185
|
+
if (!integration)
|
|
186
|
+
throw new Error(`Proof ingest failed: integration '${effectiveIntegrationId}' is not configured in .kb/proof/integrations.json`);
|
|
187
|
+
if (jsonDigest(artifact.command_argv) !== jsonDigest([...integration.command]))
|
|
188
|
+
throw new Error(`Proof ingest failed: artifact command_argv does not match the configured command for integration '${effectiveIntegrationId}'`);
|
|
189
|
+
const bindings = parseBindings(test);
|
|
190
|
+
enforceNativeCaseBindings(testId, contract, bindings, artifact);
|
|
191
|
+
const { fingerprint, components } = effectiveProofFingerprint({
|
|
192
|
+
contract,
|
|
193
|
+
integration: toExecution(integration),
|
|
194
|
+
bindings,
|
|
195
|
+
});
|
|
196
|
+
const evaluation = evaluateContractAgainstRun(artifact, contract);
|
|
197
|
+
const environmentHash = canonicalEnvironmentHash(artifact.environment);
|
|
198
|
+
const artifactDigest = jsonDigest(artifact);
|
|
199
|
+
// Per-contract receipt binding (W2): hash the receipt-stripped authored
|
|
200
|
+
// document, the contract, and the bound symbols' source hashes so the
|
|
201
|
+
// receipt survives unrelated workspace changes and stales only when its
|
|
202
|
+
// own inputs (contract, document, production code scope) change.
|
|
203
|
+
let bindingHash;
|
|
204
|
+
const source = typeof test.source === "string" ? test.source : "";
|
|
205
|
+
if (context.fs && source !== "" && /\.(md|mdx)$/i.test(source)) {
|
|
206
|
+
try {
|
|
207
|
+
const absolute = resolveContainedSourcePath(context.workspaceRoot, source);
|
|
208
|
+
const authored = await context.fs.readFile(absolute);
|
|
209
|
+
const stripped = removeFrontmatterBlock(authored, "proof_receipts");
|
|
210
|
+
const codeScope = resolveBoundSymbolScope(join(context.workspaceRoot, ".kb", "symbols.yaml"), bindings.map((binding) => binding.symbol_id));
|
|
211
|
+
bindingHash = receiptBindingHash(contract, stripped ?? authored, codeScope);
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
bindingHash = undefined;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const receipt = {
|
|
218
|
+
version: PROOF_RECEIPT_VERSION,
|
|
219
|
+
receipt_id: `PR-${jsonDigest({
|
|
220
|
+
artifact_digest: artifactDigest,
|
|
221
|
+
test_id: testId,
|
|
222
|
+
fingerprint,
|
|
223
|
+
}).slice(0, 24)}`,
|
|
224
|
+
test_id: testId,
|
|
225
|
+
scope: (text(test.verification_scope) ||
|
|
226
|
+
"end_to_end"),
|
|
227
|
+
outcome: evaluation.outcome,
|
|
228
|
+
code_snapshot: snapshot,
|
|
229
|
+
environment_hash: environmentHash,
|
|
230
|
+
started_at: artifact.run.started_at,
|
|
231
|
+
finished_at: artifact.run.finished_at,
|
|
232
|
+
artifact_digest: artifactDigest,
|
|
233
|
+
contract_hash: proofContractHash(contract),
|
|
234
|
+
...(bindingHash !== undefined ? { binding_hash: bindingHash } : {}),
|
|
235
|
+
fingerprint,
|
|
236
|
+
fingerprint_components: components,
|
|
237
|
+
integration_id: effectiveIntegrationId,
|
|
238
|
+
producer: artifact.producer,
|
|
239
|
+
command_argv: [...artifact.command_argv],
|
|
240
|
+
run_outcome: artifact.run.outcome,
|
|
241
|
+
proof_results: evaluation.projectedResults.map((result) => ({
|
|
242
|
+
...result,
|
|
243
|
+
})),
|
|
244
|
+
...(evaluation.gaps.length > 0 ? { gaps: evaluation.gaps } : {}),
|
|
245
|
+
};
|
|
246
|
+
prepared.push({
|
|
247
|
+
testId,
|
|
248
|
+
test,
|
|
249
|
+
contract,
|
|
250
|
+
evaluation,
|
|
251
|
+
receipt,
|
|
252
|
+
existing: existingReceipts(test),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const results = [];
|
|
256
|
+
let passed = 0;
|
|
257
|
+
let failed = 0;
|
|
258
|
+
let unchanged = 0;
|
|
259
|
+
for (const entry of prepared) {
|
|
260
|
+
const { testId, test, contract, evaluation, receipt, existing } = entry;
|
|
261
|
+
// Idempotent re-ingestion: the same artifact against the same effective
|
|
262
|
+
// contract+fingerprint derives the same receipt id and must not re-append.
|
|
263
|
+
if (existing.some((row) => row.receipt_id === receipt.receipt_id)) {
|
|
264
|
+
unchanged += 1;
|
|
265
|
+
if (receipt.outcome === "passed")
|
|
266
|
+
passed += 1;
|
|
267
|
+
else
|
|
268
|
+
failed += 1;
|
|
269
|
+
results.push({
|
|
270
|
+
testId,
|
|
271
|
+
outcome: receipt.outcome,
|
|
272
|
+
receiptId: receipt.receipt_id,
|
|
273
|
+
applied: false,
|
|
274
|
+
duplicate: true,
|
|
275
|
+
receiptCount: existing.length,
|
|
276
|
+
gaps: evaluation.gaps,
|
|
277
|
+
});
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const nextReceipts = [
|
|
281
|
+
...existing,
|
|
282
|
+
receipt,
|
|
283
|
+
].slice(-MAX_PROOF_RECEIPTS);
|
|
284
|
+
const historyErrors = proofReceiptHistoryErrors(testId, test.verification_scope, nextReceipts);
|
|
285
|
+
const bindingErrors = proofReceiptCurrentBindingErrors(testId, test.verification_scope, receipt, contract, receipt.fingerprint);
|
|
286
|
+
const receiptErrors = [...historyErrors, ...bindingErrors];
|
|
287
|
+
if (receiptErrors.length > 0)
|
|
288
|
+
throw new Error(`Proof ingest failed for ${testId}: ${receiptErrors.join("; ")}`);
|
|
289
|
+
const properties = projectEntityProperties(test);
|
|
290
|
+
properties.proof_receipts = undefined;
|
|
291
|
+
// Surgical receipt append: splice only the proof_receipts block into the
|
|
292
|
+
// authored document so unrelated frontmatter keeps its authored form.
|
|
293
|
+
// Canonical re-rendering here would change non-receipt bytes, shift the
|
|
294
|
+
// workspace snapshot hash mid-campaign, and make later integrations in
|
|
295
|
+
// the same `kibi prove --all` refuse with "changed the tracked
|
|
296
|
+
// workspace". Falls back to the canonical render when the document is
|
|
297
|
+
// not a patchable markdown file.
|
|
298
|
+
let sourceDocumentOverride;
|
|
299
|
+
const source = typeof test.source === "string" ? test.source : "";
|
|
300
|
+
if (context.fs && source !== "" && /\.(md|mdx)$/i.test(source)) {
|
|
301
|
+
try {
|
|
302
|
+
const absolute = resolveContainedSourcePath(context.workspaceRoot, source);
|
|
303
|
+
const before = await context.fs.readFile(absolute);
|
|
304
|
+
sourceDocumentOverride =
|
|
305
|
+
patchReceiptsIntoDocument(before, nextReceipts) ?? undefined;
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
sourceDocumentOverride = undefined;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// exactOptionalPropertyTypes: only pass the override when one exists.
|
|
312
|
+
const upsertOptions = sourceDocumentOverride === undefined ? {} : { sourceDocumentOverride };
|
|
313
|
+
const upsert = await executeUpsert({
|
|
314
|
+
type: "test",
|
|
315
|
+
id: testId,
|
|
316
|
+
properties: { ...properties, proof_receipts: nextReceipts },
|
|
317
|
+
}, context, upsertOptions);
|
|
318
|
+
void upsert;
|
|
319
|
+
if (receipt.outcome === "passed")
|
|
320
|
+
passed += 1;
|
|
321
|
+
else
|
|
322
|
+
failed += 1;
|
|
323
|
+
results.push({
|
|
324
|
+
testId,
|
|
325
|
+
outcome: receipt.outcome,
|
|
326
|
+
receiptId: receipt.receipt_id,
|
|
327
|
+
applied: true,
|
|
328
|
+
duplicate: false,
|
|
329
|
+
receiptCount: nextReceipts.length,
|
|
330
|
+
gaps: evaluation.gaps,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
const summary = passed > 0
|
|
334
|
+
? `Proved ${passed} test(s)${failed > 0 ? `, ${failed} failed` : ""}${unchanged > 0 ? `, ${unchanged} unchanged` : ""}.`
|
|
335
|
+
: `No passing proof: ${failed} failed, ${unchanged} unchanged.`;
|
|
336
|
+
return {
|
|
337
|
+
content: [{ type: "text", text: `Ingested proof evidence. ${summary}` }],
|
|
338
|
+
structuredContent: {
|
|
339
|
+
artifactDigest: jsonDigest(artifact),
|
|
340
|
+
environmentHash: canonicalEnvironmentHash(artifact.environment),
|
|
341
|
+
integration: integrationId,
|
|
342
|
+
passed,
|
|
343
|
+
failed,
|
|
344
|
+
unchanged,
|
|
345
|
+
results,
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
|
+
export type MigrateLegacyReceiptsArgs = Readonly<{
|
|
3
|
+
/** Migrate a single test entity only. */
|
|
4
|
+
testId?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export type MigrateLegacyReceiptsResult = Readonly<{
|
|
7
|
+
migrated: number;
|
|
8
|
+
tests: readonly {
|
|
9
|
+
readonly testId: string;
|
|
10
|
+
}[];
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Drop legacy `verification_receipts` frontmatter blocks from test documents
|
|
14
|
+
* that already carry a `proof_contract`.
|
|
15
|
+
*
|
|
16
|
+
* The proof architecture replaced verification evidence with proof
|
|
17
|
+
* contracts/receipts, but hand-migrated workspaces kept the old blocks (with
|
|
18
|
+
* stale snapshot hashes) in ~dozens of test files, making live-receipt
|
|
19
|
+
* greps error-prone. This maintenance action strips the legacy block from
|
|
20
|
+
* the authored document and the compiled entity — one block splice, no
|
|
21
|
+
* canonical re-render.
|
|
22
|
+
*/
|
|
23
|
+
export declare function executeMigrateLegacyReceipts(args: MigrateLegacyReceiptsArgs, context: OperationContext): Promise<{
|
|
24
|
+
content: Array<{
|
|
25
|
+
type: "text";
|
|
26
|
+
text: string;
|
|
27
|
+
}>;
|
|
28
|
+
structuredContent: MigrateLegacyReceiptsResult;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=migrate-legacy-receipts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-legacy-receipts.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/migrate-legacy-receipts.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAOjF,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,yCAAyC;IAEzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAGH,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IAEjD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AAEH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,2BAA2B,CAAC;CAChD,CAAC,CAkFD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
19
|
+
import { projectEntityProperties } from "../mutation/entity-projection.js";
|
|
20
|
+
import { resolveContainedSourcePath } from "../mutation/source-authoring.js";
|
|
21
|
+
import { executeUpsert } from "../mutation/upsert.js";
|
|
22
|
+
import { removeFrontmatterBlock } from "./receipt-document.js";
|
|
23
|
+
/**
|
|
24
|
+
* Drop legacy `verification_receipts` frontmatter blocks from test documents
|
|
25
|
+
* that already carry a `proof_contract`.
|
|
26
|
+
*
|
|
27
|
+
* The proof architecture replaced verification evidence with proof
|
|
28
|
+
* contracts/receipts, but hand-migrated workspaces kept the old blocks (with
|
|
29
|
+
* stale snapshot hashes) in ~dozens of test files, making live-receipt
|
|
30
|
+
* greps error-prone. This maintenance action strips the legacy block from
|
|
31
|
+
* the authored document and the compiled entity — one block splice, no
|
|
32
|
+
* canonical re-render.
|
|
33
|
+
*/
|
|
34
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
35
|
+
export async function executeMigrateLegacyReceipts(args, context) {
|
|
36
|
+
if (!context.prolog)
|
|
37
|
+
throw new Error("Legacy receipt migration requires a Prolog runtime");
|
|
38
|
+
if (context.fs === undefined)
|
|
39
|
+
throw new Error("Legacy receipt migration failed: this maintenance action rewrites authored test documents and requires a filesystem-capable runtime");
|
|
40
|
+
const tests = await loadEntities(context.prolog, {
|
|
41
|
+
type: "test",
|
|
42
|
+
...(args.testId === undefined ? {} : { id: args.testId }),
|
|
43
|
+
});
|
|
44
|
+
if (args.testId !== undefined && tests.length === 0) {
|
|
45
|
+
throw new Error(`Legacy receipt migration failed: test ${args.testId} was not found`);
|
|
46
|
+
}
|
|
47
|
+
const migratedTests = [];
|
|
48
|
+
for (const test of tests) {
|
|
49
|
+
const testId = String(test.id);
|
|
50
|
+
// The compiled lane only survives in stores compiled by older versions:
|
|
51
|
+
// current sync does not extract verification_receipts, so the authored
|
|
52
|
+
// document is the durable carrier of the legacy block. Both signals must
|
|
53
|
+
// trigger the migration.
|
|
54
|
+
const hasCompiledLegacy = Array.isArray(test.verification_receipts);
|
|
55
|
+
const hasProofContract = test.proof_contract !== null && typeof test.proof_contract === "object";
|
|
56
|
+
if (!hasProofContract)
|
|
57
|
+
continue;
|
|
58
|
+
const source = typeof test.source === "string" ? test.source : "";
|
|
59
|
+
const patchableSource = source !== "" && /\.(md|mdx)$/i.test(source) && context.fs !== undefined;
|
|
60
|
+
if (!patchableSource) {
|
|
61
|
+
if (hasCompiledLegacy) {
|
|
62
|
+
throw new Error(`Legacy receipt migration failed for ${testId}: test source '${source || "unknown"}' is not an authored markdown document`);
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const absolute = resolveContainedSourcePath(context.workspaceRoot, source);
|
|
67
|
+
const before = await context.fs.readFile(absolute);
|
|
68
|
+
const patchedContent = removeFrontmatterBlock(before, "verification_receipts");
|
|
69
|
+
if (patchedContent === null) {
|
|
70
|
+
if (hasCompiledLegacy) {
|
|
71
|
+
throw new Error(`Legacy receipt migration failed for ${testId}: ${source} is not a patchable frontmatter document`);
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const properties = Object.fromEntries(Object.entries(projectEntityProperties(test)).filter(([key]) => key !== "verification_receipts"));
|
|
76
|
+
// Drop the legacy lane from the compiled entity; proof_receipts stay
|
|
77
|
+
// untouched so append-only validation keeps holding.
|
|
78
|
+
await executeUpsert({
|
|
79
|
+
type: "test",
|
|
80
|
+
id: testId,
|
|
81
|
+
properties: { ...properties },
|
|
82
|
+
}, context, { sourceDocumentOverride: patchedContent });
|
|
83
|
+
migratedTests.push({ testId });
|
|
84
|
+
}
|
|
85
|
+
const summary = migratedTests.length === 0
|
|
86
|
+
? "No test carries a legacy verification_receipts block alongside a proof_contract."
|
|
87
|
+
: `Removed legacy verification_receipts from ${migratedTests.length} test(s).`;
|
|
88
|
+
return {
|
|
89
|
+
content: [{ type: "text", text: `Legacy receipts migrated. ${summary}` }],
|
|
90
|
+
structuredContent: { migrated: migratedTests.length, tests: migratedTests },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
|
+
export type PruneReceiptsArgs = Readonly<{
|
|
3
|
+
/** Keep the newest N receipts per test (default 1). */
|
|
4
|
+
keep?: number;
|
|
5
|
+
/** Prune a single test entity only. */
|
|
6
|
+
testId?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export type PruneReceiptsTestResult = Readonly<{
|
|
9
|
+
testId: string;
|
|
10
|
+
before: number;
|
|
11
|
+
after: number;
|
|
12
|
+
pruned: number;
|
|
13
|
+
}>;
|
|
14
|
+
export type PruneReceiptsResult = Readonly<{
|
|
15
|
+
pruned: number;
|
|
16
|
+
tests: readonly PruneReceiptsTestResult[];
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Shrink each test's proof_receipts history to its newest entries.
|
|
20
|
+
*
|
|
21
|
+
* Re-proving the same snapshot appends duplicate passed receipts (one block
|
|
22
|
+
* per run), and consumers previously deduped them by hand. This is the one
|
|
23
|
+
* sanctioned history-shrinking mutation: pruned histories are still ordered,
|
|
24
|
+
* structurally valid evidence, and every shrink goes through the typed upsert
|
|
25
|
+
* with the prune carve-out (append-only validation is skipped for exactly
|
|
26
|
+
* this maintenance action).
|
|
27
|
+
*/
|
|
28
|
+
export declare function executePruneReceipts(args: PruneReceiptsArgs, context: OperationContext): Promise<{
|
|
29
|
+
content: Array<{
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}>;
|
|
33
|
+
structuredContent: PruneReceiptsResult;
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=prune-receipts.d.ts.map
|