kibi-cli 2.1.0 → 2.3.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-operation-loader.d.ts.map +1 -1
- package/dist/cli-operation-loader.js +3 -0
- package/dist/cli-operation-metadata.d.ts +4 -0
- package/dist/cli-operation-metadata.d.ts.map +1 -1
- package/dist/cli-operation-metadata.js +5 -0
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +3 -2
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +4 -0
- package/dist/commands/aggregated-checks.d.ts +7 -0
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +25 -1
- package/dist/commands/check-diff.d.ts +5 -0
- package/dist/commands/check-diff.d.ts.map +1 -0
- package/dist/commands/check-diff.js +62 -0
- package/dist/commands/check-generated.d.ts.map +1 -1
- package/dist/commands/check-generated.js +41 -18
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +231 -86
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +168 -53
- package/dist/commands/github-init.d.ts +1 -1
- package/dist/commands/github-init.d.ts.map +1 -1
- package/dist/commands/github-init.js +10 -3
- package/dist/commands/init-helpers.d.ts +17 -2
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +123 -23
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +110 -15
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +10 -18
- package/dist/commands/sync/cache.d.ts +20 -1
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +51 -2
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +1 -1
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +3 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -3
- package/dist/engine.d.ts +41 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +377 -80
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +66 -28
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +14 -3
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +1 -0
- package/dist/extractors/symbols-coordinator.d.ts +7 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +75 -39
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +68 -29
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +4 -3
- package/dist/operations/modeling/model-requirement.d.ts +1 -1
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +176 -10
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +14 -2
- package/dist/operations/modeling/predicate-inference-1.js +1 -1
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +24 -0
- package/dist/operations/modeling/predicate-types.d.ts +4 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
- package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-vocabulary.js +169 -0
- package/dist/operations/modeling/requirement-types.d.ts +5 -0
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
- package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
- package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
- package/dist/operations/modeling/vocabulary-alignment.js +178 -0
- package/dist/operations/mutation/contradictions.d.ts +3 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +29 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +33 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
- package/dist/operations/mutation/relationships.d.ts +1 -1
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +1 -0
- package/dist/operations/mutation/saga.d.ts +5 -0
- package/dist/operations/mutation/saga.d.ts.map +1 -1
- package/dist/operations/mutation/saga.js +10 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +2 -0
- package/dist/operations/mutation/source-authoring.d.ts +6 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +213 -52
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +5 -0
- package/dist/operations/mutation/types.d.ts +17 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +6 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +77 -11
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +24 -1
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +16 -3
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +66 -26
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +3 -1
- package/dist/operations/proof/code-scope.d.ts +17 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -0
- package/dist/operations/proof/code-scope.js +60 -0
- package/dist/operations/proof/ingest-proof.d.ts +4 -2
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +208 -74
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
- package/dist/operations/proof/migrate-legacy-receipts.js +7 -5
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +7 -5
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +26 -4
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +7 -1
- package/dist/performance-trace.d.ts +17 -0
- package/dist/performance-trace.d.ts.map +1 -0
- package/dist/performance-trace.js +134 -0
- package/dist/plugins/approved-source-analyzers.d.ts +13 -0
- package/dist/plugins/approved-source-analyzers.d.ts.map +1 -0
- package/dist/plugins/approved-source-analyzers.generated.d.ts +71 -0
- package/dist/plugins/approved-source-analyzers.generated.d.ts.map +1 -0
- package/dist/plugins/approved-source-analyzers.generated.js +77 -0
- package/dist/plugins/approved-source-analyzers.js +3 -0
- package/dist/plugins/compose-semantic-classifier.d.ts +6 -1
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -1
- package/dist/plugins/compose-semantic-classifier.js +8 -3
- package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
- package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
- package/dist/plugins/compose-vocabulary-alignment.js +141 -0
- package/dist/plugins/external-allowlist.d.ts +7 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -1
- package/dist/plugins/external-allowlist.js +13 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/maintenance-source-analysis.d.ts +14 -0
- package/dist/plugins/maintenance-source-analysis.d.ts.map +1 -0
- package/dist/plugins/maintenance-source-analysis.js +191 -0
- package/dist/plugins/registry.d.ts +3 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +27 -1
- package/dist/plugins/source-analysis-service.d.ts +36 -1
- package/dist/plugins/source-analysis-service.d.ts.map +1 -1
- package/dist/plugins/source-analysis-service.js +184 -27
- package/dist/plugins/source-change-analysis.d.ts +15 -0
- package/dist/plugins/source-change-analysis.d.ts.map +1 -0
- package/dist/plugins/source-change-analysis.js +54 -0
- package/dist/plugins/source-classification.d.ts +41 -0
- package/dist/plugins/source-classification.d.ts.map +1 -0
- package/dist/plugins/source-classification.js +490 -0
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -0
- package/dist/prolog/swipl-resolver.d.ts +88 -0
- package/dist/prolog/swipl-resolver.d.ts.map +1 -0
- package/dist/prolog/swipl-resolver.js +446 -0
- package/dist/prolog.d.ts +51 -1
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +145 -15
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +7 -25
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +56 -5
- package/dist/public/impact/diagnostics.d.ts.map +1 -1
- package/dist/public/impact/diagnostics.js +3 -1
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +4 -12
- package/dist/public/impact/manifest.d.ts.map +1 -1
- package/dist/public/impact/manifest.js +15 -1
- package/dist/public/impact/source-changes.d.ts.map +1 -1
- package/dist/public/impact/source-changes.js +35 -27
- package/dist/public/impact/types.d.ts +2 -0
- package/dist/public/impact/types.d.ts.map +1 -1
- package/dist/public/operations/catalog.d.ts +80 -7
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/catalog.js +2 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +10 -2
- package/dist/public/operations/check-helpers.d.ts +6 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +21 -1
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +325 -8
- package/dist/public/operations/discovery-entities.d.ts +42 -2
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +195 -22
- package/dist/public/operations/discovery-executors.d.ts +1 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +75 -46
- package/dist/public/operations/impact-review-preparation.d.ts +14 -0
- package/dist/public/operations/impact-review-preparation.d.ts.map +1 -0
- package/dist/public/operations/impact-review-preparation.js +379 -0
- package/dist/public/operations/index.d.ts +2 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +2 -0
- package/dist/public/operations/migration-plan.d.ts +2 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +50 -0
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +1 -35
- package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
- package/dist/public/operations/predicate-schema-conformance.js +242 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +9 -3
- package/dist/public/operations/proof-receipt-projection.d.ts +5 -0
- package/dist/public/operations/proof-receipt-projection.d.ts.map +1 -0
- package/dist/public/operations/proof-receipt-projection.js +36 -0
- package/dist/public/operations/result-envelope.d.ts +34 -1
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +78 -2
- package/dist/public/operations/runtime-types.d.ts +1 -1
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- 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 +8 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +7 -1
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +7 -1
- package/dist/public/operations/specs/impact-review-preparation.d.ts +47 -0
- package/dist/public/operations/specs/impact-review-preparation.d.ts.map +1 -0
- package/dist/public/operations/specs/impact-review-preparation.js +43 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +21 -3
- package/dist/public/operations/specs/reporting.d.ts +8 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +46 -15
- package/dist/public/operations/specs/upsert.d.ts +28 -5
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +1 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +8 -3
- package/dist/public/operations/types.d.ts +1 -1
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +22 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skills/kibi-usage/SKILL.md +7 -3
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -0
- package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +21 -5
- package/dist/relationships/shards.d.ts +6 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +26 -19
- package/dist/schemas/entity.schema.json +32 -0
- package/dist/traceability/analysis-gate.d.ts +39 -0
- package/dist/traceability/analysis-gate.d.ts.map +1 -0
- package/dist/traceability/analysis-gate.js +51 -0
- package/dist/traceability/git-change-snapshot.d.ts +27 -0
- package/dist/traceability/git-change-snapshot.d.ts.map +1 -0
- package/dist/traceability/git-change-snapshot.js +411 -0
- package/dist/traceability/git-staged.d.ts +5 -1
- package/dist/traceability/git-staged.d.ts.map +1 -1
- package/dist/traceability/git-staged.js +16 -11
- package/dist/traceability/impact-evaluator.d.ts +54 -0
- package/dist/traceability/impact-evaluator.d.ts.map +1 -0
- package/dist/traceability/impact-evaluator.js +270 -0
- package/dist/traceability/impact-git-tree.d.ts +12 -0
- package/dist/traceability/impact-git-tree.d.ts.map +1 -0
- package/dist/traceability/impact-git-tree.js +46 -0
- package/dist/traceability/impact-knowledge.d.ts +16 -0
- package/dist/traceability/impact-knowledge.d.ts.map +1 -0
- package/dist/traceability/impact-knowledge.js +165 -0
- package/dist/traceability/impact-policy.d.ts +15 -0
- package/dist/traceability/impact-policy.d.ts.map +1 -0
- package/dist/traceability/impact-policy.js +48 -0
- package/dist/traceability/impact-policy.v1.schema.json +48 -0
- package/dist/traceability/impact-pr-diff.d.ts +5 -0
- package/dist/traceability/impact-pr-diff.d.ts.map +1 -0
- package/dist/traceability/impact-pr-diff.js +83 -0
- package/dist/traceability/impact-record-validation.d.ts +9 -0
- package/dist/traceability/impact-record-validation.d.ts.map +1 -0
- package/dist/traceability/impact-record-validation.js +113 -0
- package/dist/traceability/impact-review.d.ts +148 -0
- package/dist/traceability/impact-review.d.ts.map +1 -0
- package/dist/traceability/impact-review.js +494 -0
- package/dist/traceability/impact-review.schema.json +365 -0
- package/dist/traceability/impact-side-evidence.d.ts +13 -0
- package/dist/traceability/impact-side-evidence.d.ts.map +1 -0
- package/dist/traceability/impact-side-evidence.js +240 -0
- package/dist/traceability/reviewed-coordinate-refresh.d.ts +10 -0
- package/dist/traceability/reviewed-coordinate-refresh.d.ts.map +1 -0
- package/dist/traceability/reviewed-coordinate-refresh.js +49 -0
- package/dist/traceability/snapshot-knowledge.d.ts +4 -0
- package/dist/traceability/snapshot-knowledge.d.ts.map +1 -0
- package/dist/traceability/snapshot-knowledge.js +98 -0
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-entity-id-style.d.ts +12 -0
- package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
- package/dist/traceability/staged-entity-id-style.js +68 -0
- package/dist/traceability/staged-file-coverage.d.ts +23 -0
- package/dist/traceability/staged-file-coverage.d.ts.map +1 -1
- package/dist/traceability/staged-impact-contract.d.ts.map +1 -1
- package/dist/traceability/staged-impact-contract.js +2 -16
- package/dist/traceability/staged-symbols-manifest.d.ts +4 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +17 -6
- package/dist/traceability/symbol-extract.d.ts +3 -5
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +49 -34
- package/dist/traceability/temp-kb.d.ts +1 -1
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +57 -13
- package/dist/traceability/trusted-pr-event.d.ts +13 -0
- package/dist/traceability/trusted-pr-event.d.ts.map +1 -0
- package/dist/traceability/trusted-pr-event.js +105 -0
- package/dist/traceability/validate.js +1 -1
- package/dist/types/entities.d.ts +2 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/canonical-path.d.ts +3 -0
- package/dist/utils/canonical-path.d.ts.map +1 -0
- package/dist/utils/canonical-path.js +33 -0
- package/dist/utils/entity-id-style.d.ts +27 -0
- package/dist/utils/entity-id-style.d.ts.map +1 -0
- package/dist/utils/entity-id-style.js +81 -0
- package/dist/utils/git-repository-context.d.ts +50 -0
- package/dist/utils/git-repository-context.d.ts.map +1 -0
- package/dist/utils/git-repository-context.js +259 -0
- package/dist/utils/rule-registry.d.ts +5 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.d.ts +37 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +44 -0
- package/dist/utils/strict-modeling.d.ts +7 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +11 -0
- package/package.json +14 -5
- package/schema/entities.pl +60 -1
- package/schema/relationships.pl +17 -4
- package/schema/validation.pl +118 -20
- package/src/public/diagnostic-usage.ts +16 -24
- package/src/public/impact/analyzer.ts +88 -5
- package/src/public/impact/diagnostics.ts +7 -5
- package/src/public/impact/full-kb-quality.ts +4 -16
- package/src/public/impact/manifest.ts +14 -1
- package/src/public/impact/source-changes.ts +39 -34
- package/src/public/impact/types.ts +5 -0
- package/src/public/operations/catalog.ts +2 -0
- package/src/public/operations/check-executor.ts +12 -1
- package/src/public/operations/check-helpers.ts +27 -1
- package/src/public/operations/contracts.ts +404 -9
- package/src/public/operations/discovery-entities.ts +292 -23
- package/src/public/operations/discovery-executors.ts +91 -55
- package/src/public/operations/impact-review-preparation.ts +548 -0
- package/src/public/operations/index.ts +2 -0
- package/src/public/operations/migration-plan.ts +57 -0
- package/src/public/operations/node-ports.ts +1 -39
- package/src/public/operations/predicate-schema-conformance.ts +362 -0
- package/src/public/operations/prolog-json.ts +9 -3
- package/src/public/operations/proof-receipt-projection.ts +39 -0
- package/src/public/operations/result-envelope.ts +114 -2
- package/src/public/operations/runtime-types.ts +1 -1
- package/src/public/operations/specs/check-rules.generated.ts +8 -1
- package/src/public/operations/specs/discovery.ts +8 -1
- package/src/public/operations/specs/impact-review-preparation.ts +46 -0
- package/src/public/operations/specs/mutation-schemas.ts +23 -3
- package/src/public/operations/specs/reporting.ts +69 -22
- package/src/public/operations/specs/upsert.ts +1 -1
- package/src/public/operations/symbol-repair-plan.ts +13 -3
- package/src/public/operations/types.ts +1 -0
- package/src/public/schemas/entity.ts +22 -0
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skills/kibi-usage/SKILL.md +7 -3
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/src/public/skills/kibi-usage/resources/operation-access.md +1 -0
- package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/src/public/telemetry-acceptance.ts +37 -6
- package/src/schemas/entity.schema.json +32 -0
- package/src/schemas/relationship.schema.json +1 -0
- package/src/traceability/impact-policy.v1.schema.json +48 -0
- package/src/traceability/impact-review.schema.json +365 -0
- package/templates/github/kibi-badge.yml +0 -4
- package/templates/github/kibi-report.yml +0 -4
package/dist/prolog.js
CHANGED
|
@@ -19,11 +19,14 @@ import { spawn } from "node:child_process";
|
|
|
19
19
|
import { existsSync } from "node:fs";
|
|
20
20
|
import { createRequire } from "node:module";
|
|
21
21
|
import path from "node:path";
|
|
22
|
+
import { performance } from "node:perf_hooks";
|
|
22
23
|
import { fileURLToPath } from "node:url";
|
|
23
24
|
import { getKbPlPathOverride, isPrologDebugEnabled } from "./env.js";
|
|
25
|
+
import { writePerformanceTraceEvent } from "./performance-trace.js";
|
|
24
26
|
import { extractPrologErrorRecord, } from "./prolog/error-terms.js";
|
|
27
|
+
import { resolveSwipl, swiplChildEnv, } from "./prolog/swipl-resolver.js";
|
|
25
28
|
const importMetaDir = path.dirname(fileURLToPath(import.meta.url));
|
|
26
|
-
const
|
|
29
|
+
const DEFAULT_PROLOG_OUTPUT_MAX_BUFFER_BYTES = 8 * 1024 * 1024;
|
|
27
30
|
const PROLOG_OUTPUT_OVERFLOW_ERROR = "Query exceeded bounded Prolog output capacity (ENOBUFS); narrow the operation or reduce stored entity size";
|
|
28
31
|
const INTERACTIVE_QUERY_FRAME_END = "__KIBI_QUERY_FRAME_END__";
|
|
29
32
|
const require = createRequire(import.meta.url);
|
|
@@ -79,6 +82,22 @@ export function resolveKbPlPath() {
|
|
|
79
82
|
throw new Error("Unable to resolve kb.pl. Expected kibi-core to be installed (node_modules) " +
|
|
80
83
|
"or to be running inside the monorepo checkout.");
|
|
81
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Raised when a query reaches an interactive process that was started and
|
|
87
|
+
* later terminated (output overflow, timeout, crash, or explicit terminate).
|
|
88
|
+
* Such a port must be restarted by its owner (the engine daemon recycles it);
|
|
89
|
+
* it never degrades into isolated one-shot SWI processes, which would lose
|
|
90
|
+
* the attached KB and every module loaded into the interactive session.
|
|
91
|
+
*/
|
|
92
|
+
export class PrologProcessTerminatedError extends Error {
|
|
93
|
+
code = "prolog_process_terminated";
|
|
94
|
+
reason;
|
|
95
|
+
constructor(reason) {
|
|
96
|
+
super(`Kibi Prolog process is no longer running (${reason}); the interactive session and its attached KB were lost. The owning engine must restart it before serving more queries — run 'kibi engine stop' and retry if this persists.`);
|
|
97
|
+
this.name = "PrologProcessTerminatedError";
|
|
98
|
+
this.reason = reason;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
82
101
|
// implements REQ-core-prolog-process-management
|
|
83
102
|
export function registerProcessExitOnce(current, handler, on = (event, listener) => process.on(event, listener)) {
|
|
84
103
|
if (current)
|
|
@@ -94,7 +113,8 @@ export function bindProcessExitHandler(current, terminate, on = (event, listener
|
|
|
94
113
|
}
|
|
95
114
|
export class PrologProcess {
|
|
96
115
|
process = null;
|
|
97
|
-
|
|
116
|
+
explicitSwiplPath;
|
|
117
|
+
swiplResolver;
|
|
98
118
|
timeout;
|
|
99
119
|
outputBuffer = "";
|
|
100
120
|
outputBufferBytes = 0;
|
|
@@ -108,9 +128,24 @@ export class PrologProcess {
|
|
|
108
128
|
useOneShotMode;
|
|
109
129
|
attachedKbPath = null;
|
|
110
130
|
onProcessExit = null;
|
|
131
|
+
maxOutputBytes;
|
|
132
|
+
/**
|
|
133
|
+
* Set once start() spawned an interactive process. From then on the
|
|
134
|
+
* isolated one-shot fallback is unreachable: a lost interactive process
|
|
135
|
+
* must fail loudly instead of silently changing execution semantics.
|
|
136
|
+
*/
|
|
137
|
+
interactiveStarted = false;
|
|
138
|
+
terminationReason = null;
|
|
111
139
|
constructor(options = {}) {
|
|
112
|
-
this.
|
|
140
|
+
this.explicitSwiplPath = options.swiplPath || undefined;
|
|
141
|
+
this.swiplResolver = options.swiplResolver ?? (() => resolveSwipl());
|
|
113
142
|
this.timeout = options.timeout || 30000;
|
|
143
|
+
this.maxOutputBytes =
|
|
144
|
+
options.maxOutputBytes !== undefined &&
|
|
145
|
+
Number.isInteger(options.maxOutputBytes) &&
|
|
146
|
+
options.maxOutputBytes > 0
|
|
147
|
+
? options.maxOutputBytes
|
|
148
|
+
: DEFAULT_PROLOG_OUTPUT_MAX_BUFFER_BYTES;
|
|
114
149
|
this.useOneShotMode =
|
|
115
150
|
options.oneShot ??
|
|
116
151
|
(process.env.NODE_ENV === "test" &&
|
|
@@ -120,12 +155,45 @@ export class PrologProcess {
|
|
|
120
155
|
attachProcessExitHandler(on = (event, listener) => process.on(event, listener)) {
|
|
121
156
|
this.onProcessExit = bindProcessExitHandler(this.onProcessExit, () => this.terminate(), on);
|
|
122
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* True when every query runs in its own isolated SWI process, so callers
|
|
160
|
+
* must not rely on state (loaded modules) carried between queries.
|
|
161
|
+
*/
|
|
162
|
+
get oneShotMode() {
|
|
163
|
+
return this.useOneShotMode || !this.interactiveStarted;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* True once a started interactive process has been lost. The owner must
|
|
167
|
+
* restart it (and re-establish its session state) before querying again.
|
|
168
|
+
*/
|
|
169
|
+
needsRestart() {
|
|
170
|
+
return this.interactiveStarted && !this.isProcessUsable();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The executable and SWI home to launch. An explicit `swiplPath` is used
|
|
174
|
+
* verbatim; otherwise the per-process resolver decides, so a missing or
|
|
175
|
+
* damaged runtime fails with its complete remediation text.
|
|
176
|
+
*/
|
|
177
|
+
launchTarget() {
|
|
178
|
+
const explicit = this.explicitSwiplPath;
|
|
179
|
+
if (explicit !== undefined)
|
|
180
|
+
return { bin: explicit, env: {} };
|
|
181
|
+
const resolved = this.swiplResolver();
|
|
182
|
+
return { bin: resolved.bin, env: swiplChildEnv(resolved) };
|
|
183
|
+
}
|
|
123
184
|
async start() {
|
|
124
|
-
|
|
125
|
-
|
|
185
|
+
const explicit = this.explicitSwiplPath;
|
|
186
|
+
if (explicit !== undefined &&
|
|
187
|
+
!existsSync(explicit) &&
|
|
188
|
+
explicit !== "swipl") {
|
|
189
|
+
throw new Error(`SWI-Prolog not found at ${explicit}. Please install SWI-Prolog or check your PATH.`);
|
|
126
190
|
}
|
|
191
|
+
const launch = this.launchTarget();
|
|
127
192
|
const kbPath = resolveKbPlPath();
|
|
128
|
-
this.
|
|
193
|
+
this.interactiveStarted = true;
|
|
194
|
+
this.terminationReason = null;
|
|
195
|
+
this.invalidateCache();
|
|
196
|
+
this.process = spawn(launch.bin, [
|
|
129
197
|
"-g",
|
|
130
198
|
`use_module('${kbPath}'), use_module(library(semweb/rdf_db)), set_prolog_flag(answer_write_options, [max_depth(0), quoted(true)])`,
|
|
131
199
|
"--quiet",
|
|
@@ -133,6 +201,7 @@ export class PrologProcess {
|
|
|
133
201
|
detached: process.platform !== "win32",
|
|
134
202
|
env: {
|
|
135
203
|
...process.env,
|
|
204
|
+
...launch.env,
|
|
136
205
|
KIBI_RUNTIME_NAME: process.versions.bun !== undefined ? "bun" : "node",
|
|
137
206
|
KIBI_RUNTIME_VERSION: process.versions.bun ?? process.versions.node ?? "unknown",
|
|
138
207
|
KIBI_PACKAGE_VERSIONS: process.env.KIBI_PACKAGE_VERSIONS ?? KIBI_PACKAGE_VERSIONS,
|
|
@@ -148,6 +217,16 @@ export class PrologProcess {
|
|
|
148
217
|
this.process.stderr.on("data", (chunk) => {
|
|
149
218
|
this.appendErrorChunk(chunk);
|
|
150
219
|
});
|
|
220
|
+
// A write racing the child's death (native crash, external kill) fails
|
|
221
|
+
// asynchronously with EPIPE. Unhandled, that error event crashes the
|
|
222
|
+
// whole host (the engine daemon); record the loss instead so the owner
|
|
223
|
+
// sees needsRestart() and the in-flight query reports the termination.
|
|
224
|
+
const child = this.process;
|
|
225
|
+
child.stdin?.on("error", (error) => {
|
|
226
|
+
if (this.process === child) {
|
|
227
|
+
this.terminationReason ??= `stdin ${error.code ?? "error"}`;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
151
230
|
this.process.stdin.write("true.\n");
|
|
152
231
|
this.attachProcessExitHandler();
|
|
153
232
|
await this.waitForReady();
|
|
@@ -186,12 +265,23 @@ export class PrologProcess {
|
|
|
186
265
|
}
|
|
187
266
|
// implements REQ-core-prolog-process-management
|
|
188
267
|
async query(goal) {
|
|
268
|
+
// A lost interactive session must fail before any cached answer is served.
|
|
269
|
+
if (!this.useOneShotMode && this.needsRestart()) {
|
|
270
|
+
throw this.lostProcessError();
|
|
271
|
+
}
|
|
189
272
|
const isSingleGoal = typeof goal === "string";
|
|
190
273
|
const goalKey = isSingleGoal ? goal : null;
|
|
191
274
|
const cacheable = goalKey !== null && this.isCacheableGoal(goalKey);
|
|
192
275
|
if (cacheable) {
|
|
276
|
+
const cacheLookupStartedAt = process.env.KIBI_PERF_TIMINGS === "1" ? performance.now() : null;
|
|
193
277
|
const cachedResult = this.cache.get(goalKey);
|
|
194
278
|
if (cachedResult) {
|
|
279
|
+
if (cacheLookupStartedAt !== null) {
|
|
280
|
+
writePerformanceTraceEvent({
|
|
281
|
+
kind: "prolog-process-cache-hit",
|
|
282
|
+
durationMs: performance.now() - cacheLookupStartedAt,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
195
285
|
return cachedResult;
|
|
196
286
|
}
|
|
197
287
|
}
|
|
@@ -223,10 +313,10 @@ export class PrologProcess {
|
|
|
223
313
|
// runtimes provide an EngineClient, while explicitly attached callers
|
|
224
314
|
// call start() and stay interactive; this fallback never participates
|
|
225
315
|
// in the engine-backed workflow.
|
|
226
|
-
if (this.process === null) {
|
|
316
|
+
if (this.process === null && !this.interactiveStarted) {
|
|
227
317
|
return this.execOneShot(goal, this.attachedKbPath);
|
|
228
318
|
}
|
|
229
|
-
throw
|
|
319
|
+
throw this.lostProcessError();
|
|
230
320
|
}
|
|
231
321
|
const runInteractiveQuery = async () => {
|
|
232
322
|
this.clearQueryBuffers();
|
|
@@ -264,6 +354,7 @@ export class PrologProcess {
|
|
|
264
354
|
console.error(`[prolog debug] runtime=${runtime ?? "unknown"} packages=${process.env.KIBI_PACKAGE_VERSIONS ?? KIBI_PACKAGE_VERSIONS}`);
|
|
265
355
|
}
|
|
266
356
|
settled = true;
|
|
357
|
+
this.terminationReason = `query timeout: ${goalLabel}`;
|
|
267
358
|
void this.terminate().finally(() => {
|
|
268
359
|
reject(new Error(msg));
|
|
269
360
|
});
|
|
@@ -275,6 +366,7 @@ export class PrologProcess {
|
|
|
275
366
|
if (this.outputOverflowed) {
|
|
276
367
|
clearTimeout(timeoutId);
|
|
277
368
|
settled = true;
|
|
369
|
+
this.terminationReason = `output overflow (ENOBUFS): ${goalLabel}`;
|
|
278
370
|
void this.terminate().finally(() => {
|
|
279
371
|
resolve({
|
|
280
372
|
success: false,
|
|
@@ -287,6 +379,7 @@ export class PrologProcess {
|
|
|
287
379
|
if (!this.isProcessUsable()) {
|
|
288
380
|
clearTimeout(timeoutId);
|
|
289
381
|
settled = true;
|
|
382
|
+
this.terminationReason ??= `process exited during query: ${goalLabel}`;
|
|
290
383
|
resolve({
|
|
291
384
|
success: false,
|
|
292
385
|
bindings: {},
|
|
@@ -356,13 +449,23 @@ export class PrologProcess {
|
|
|
356
449
|
releaseQuery = resolve;
|
|
357
450
|
});
|
|
358
451
|
await previousQuery;
|
|
452
|
+
const tracingEnabled = process.env.KIBI_PERF_TIMINGS === "1";
|
|
453
|
+
let roundTripStartedAt = null;
|
|
359
454
|
try {
|
|
360
455
|
if (!this.isProcessUsable()) {
|
|
361
|
-
throw
|
|
456
|
+
throw this.lostProcessError();
|
|
362
457
|
}
|
|
458
|
+
if (tracingEnabled)
|
|
459
|
+
roundTripStartedAt = performance.now();
|
|
363
460
|
return await runInteractiveQuery();
|
|
364
461
|
}
|
|
365
462
|
finally {
|
|
463
|
+
if (roundTripStartedAt !== null) {
|
|
464
|
+
writePerformanceTraceEvent({
|
|
465
|
+
kind: "prolog-round-trip",
|
|
466
|
+
durationMs: performance.now() - roundTripStartedAt,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
366
469
|
releaseQuery();
|
|
367
470
|
}
|
|
368
471
|
}
|
|
@@ -474,10 +577,12 @@ export class PrologProcess {
|
|
|
474
577
|
const packageVersions = process.env.KIBI_PACKAGE_VERSIONS ?? KIBI_PACKAGE_VERSIONS;
|
|
475
578
|
let child;
|
|
476
579
|
try {
|
|
477
|
-
|
|
580
|
+
const launch = this.launchTarget();
|
|
581
|
+
child = spawn(launch.bin, ["-q", "-g", prologGoal, "-t", "halt"], {
|
|
478
582
|
detached: process.platform !== "win32",
|
|
479
583
|
env: {
|
|
480
584
|
...process.env,
|
|
585
|
+
...launch.env,
|
|
481
586
|
KIBI_GOAL: combinedGoal,
|
|
482
587
|
KIBI_RUNTIME_NAME: runtimeName,
|
|
483
588
|
KIBI_RUNTIME_VERSION: runtimeVersion,
|
|
@@ -508,7 +613,7 @@ export class PrologProcess {
|
|
|
508
613
|
if (outputOverflowed)
|
|
509
614
|
return;
|
|
510
615
|
const bytes = target === "stdout" ? outputBytes : errorBytes;
|
|
511
|
-
const remaining =
|
|
616
|
+
const remaining = this.maxOutputBytes - bytes;
|
|
512
617
|
if (chunk.byteLength > remaining) {
|
|
513
618
|
const clipped = chunk.subarray(0, Math.max(0, remaining)).toString();
|
|
514
619
|
if (target === "stdout")
|
|
@@ -624,10 +729,10 @@ export class PrologProcess {
|
|
|
624
729
|
appendOutputChunk(chunk) {
|
|
625
730
|
if (this.outputOverflowed)
|
|
626
731
|
return;
|
|
627
|
-
const remaining =
|
|
732
|
+
const remaining = this.maxOutputBytes - this.outputBufferBytes;
|
|
628
733
|
if (chunk.byteLength > remaining) {
|
|
629
734
|
this.outputBuffer += chunk.subarray(0, remaining).toString();
|
|
630
|
-
this.outputBufferBytes =
|
|
735
|
+
this.outputBufferBytes = this.maxOutputBytes;
|
|
631
736
|
this.outputOverflowed = true;
|
|
632
737
|
return;
|
|
633
738
|
}
|
|
@@ -637,10 +742,10 @@ export class PrologProcess {
|
|
|
637
742
|
appendErrorChunk(chunk) {
|
|
638
743
|
if (this.outputOverflowed)
|
|
639
744
|
return;
|
|
640
|
-
const remaining =
|
|
745
|
+
const remaining = this.maxOutputBytes - this.errorBufferBytes;
|
|
641
746
|
if (chunk.byteLength > remaining) {
|
|
642
747
|
this.errorBuffer += chunk.subarray(0, remaining).toString();
|
|
643
|
-
this.errorBufferBytes =
|
|
748
|
+
this.errorBufferBytes = this.maxOutputBytes;
|
|
644
749
|
this.outputOverflowed = true;
|
|
645
750
|
return;
|
|
646
751
|
}
|
|
@@ -760,6 +865,20 @@ export class PrologProcess {
|
|
|
760
865
|
// Diagnostic markers intentionally contain words such as `lock` and the
|
|
761
866
|
// audit path. Remove them before classifying the actual Prolog error so a
|
|
762
867
|
// contradiction at the check stage is not mistaken for an audit lock.
|
|
868
|
+
// Preserve only bounded identifiers from the formal existence error. Its
|
|
869
|
+
// context can contain authored dictionaries or query data and is never shown.
|
|
870
|
+
const existence = errorText.match(/^__KIBI_ERROR__:error\(existence_error\((key|procedure),([^,()\r\n]+)(?:,|\),)/m);
|
|
871
|
+
const identifier = existence?.[2]?.trim().replace(/^'([^']+)'$/, "$1");
|
|
872
|
+
if (existence?.[1] === "key" && identifier !== undefined) {
|
|
873
|
+
if (/^[A-Za-z][A-Za-z0-9_-]{0,95}$/.test(identifier)) {
|
|
874
|
+
return `Predicate or file not found (missing dictionary key: ${identifier})`;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (existence?.[1] === "procedure" && identifier !== undefined) {
|
|
878
|
+
if (/^(?:[A-Za-z][A-Za-z0-9_]{0,95}:)?[A-Za-z][A-Za-z0-9_]{0,95}\/[0-9]{1,3}$/.test(identifier)) {
|
|
879
|
+
return `Predicate or file not found (missing procedure: ${identifier})`;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
763
882
|
const cleanError = errorText.replace(/^__KIBI_(?:STAGE|RUNTIME|ERROR)__:[^\r\n]*\r?\n?/gm, "");
|
|
764
883
|
if (cleanError.includes("stale_snapshot")) {
|
|
765
884
|
return "KB snapshot is stale; reattach or refresh the runtime before retrying (stale_snapshot)";
|
|
@@ -801,6 +920,8 @@ export class PrologProcess {
|
|
|
801
920
|
cleanError.includes("Unknown procedure")) {
|
|
802
921
|
return "Predicate or file not found";
|
|
803
922
|
}
|
|
923
|
+
if (existence !== null)
|
|
924
|
+
return "Predicate or file not found";
|
|
804
925
|
if (cleanError.includes("permission_error")) {
|
|
805
926
|
return "Access denied or KB locked";
|
|
806
927
|
}
|
|
@@ -827,7 +948,16 @@ export class PrologProcess {
|
|
|
827
948
|
getPid() {
|
|
828
949
|
return this.process?.pid || 0;
|
|
829
950
|
}
|
|
951
|
+
lostProcessError() {
|
|
952
|
+
if (!this.interactiveStarted) {
|
|
953
|
+
return new Error("Prolog process not started");
|
|
954
|
+
}
|
|
955
|
+
return new PrologProcessTerminatedError(this.terminationReason ?? "process exited");
|
|
956
|
+
}
|
|
830
957
|
async terminate() {
|
|
958
|
+
if (this.interactiveStarted) {
|
|
959
|
+
this.terminationReason ??= "terminated";
|
|
960
|
+
}
|
|
831
961
|
if (this.terminationPromise) {
|
|
832
962
|
await this.terminationPromise;
|
|
833
963
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-usage.d.ts","sourceRoot":"","sources":["../../src/public/diagnostic-usage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnostic-usage.d.ts","sourceRoot":"","sources":["../../src/public/diagnostic-usage.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAuBD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtC,MAAM,CAIR;AAkHD,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,EACnD,MAAM,EAAE,OAAO,GACd,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwEzB;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAgC1E"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { appendPayloadCountField, normalizeResultPayload, } from "./operations/result-envelope.js";
|
|
4
5
|
function isRecord(value) {
|
|
5
6
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6
7
|
}
|
|
7
|
-
function resultRecord(result) {
|
|
8
|
-
if (!isRecord(result))
|
|
9
|
-
return undefined;
|
|
10
|
-
if (isRecord(result.structuredContent))
|
|
11
|
-
return result.structuredContent;
|
|
12
|
-
// CLI JSON operations return the same versioned KibiResult envelope as MCP
|
|
13
|
-
// structuredContent. Unwrap its data before deriving operation-specific
|
|
14
|
-
// telemetry fields (coverage/proof fields in particular).
|
|
15
|
-
if (result.kibiProtocol === 1 && isRecord(result.data))
|
|
16
|
-
return result.data;
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
8
|
function stringArray(value) {
|
|
20
9
|
return Array.isArray(value)
|
|
21
10
|
? value.filter((item) => typeof item === "string")
|
|
@@ -141,10 +130,7 @@ export function deriveDiagnosticUsageFields(tool, args, telemetry, result) {
|
|
|
141
130
|
fields.actor_id = telemetry.actor_id;
|
|
142
131
|
}
|
|
143
132
|
}
|
|
144
|
-
const structured =
|
|
145
|
-
const envelope = isRecord(structured) && structured.kibiProtocol === 1
|
|
146
|
-
? structured
|
|
147
|
-
: undefined;
|
|
133
|
+
const { envelope, data: structured } = normalizeResultPayload(result);
|
|
148
134
|
if (envelope) {
|
|
149
135
|
fields.protocol_version = envelope.kibiProtocol;
|
|
150
136
|
fields.result_version =
|
|
@@ -162,18 +148,14 @@ export function deriveDiagnosticUsageFields(tool, args, telemetry, result) {
|
|
|
162
148
|
fields.unsafe_original_retry = telemetry?.unsafe_original_retry === true;
|
|
163
149
|
}
|
|
164
150
|
if (tool === "kb_query" || tool === "kb_search") {
|
|
165
|
-
|
|
166
|
-
fields.result_count
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
resultCount === 0 ? "0 results" : `${resultCount} results`;
|
|
151
|
+
appendPayloadCountField(fields, "result_count", "results", structured);
|
|
152
|
+
if (typeof fields.result_count === "number") {
|
|
153
|
+
fields.zero_results = fields.result_count === 0;
|
|
154
|
+
}
|
|
170
155
|
}
|
|
171
156
|
if (tool === "kb_check") {
|
|
172
|
-
|
|
173
|
-
fields.violation_count = count;
|
|
157
|
+
appendPayloadCountField(fields, "violation_count", "violations", structured);
|
|
174
158
|
fields.requested_rules = Array.isArray(args.rules) ? args.rules : [];
|
|
175
|
-
fields.result_summary =
|
|
176
|
-
count === 0 ? "0 violations" : `${count} violations`;
|
|
177
159
|
}
|
|
178
160
|
if (tool === "kb_coverage" && structured) {
|
|
179
161
|
appendCoverageFields(fields, args, structured);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA2IlC"}
|
|
@@ -1,27 +1,76 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
+
import { createMaintenanceSourceAnalysisService, readSnapshotSourceConfig, } from "../../plugins/maintenance-source-analysis.js";
|
|
3
|
+
import { analyzeSourceChanges, assertSourceAnalysisGate, } from "../../plugins/source-change-analysis.js";
|
|
4
|
+
import { captureStagedSnapshot } from "../../traceability/git-change-snapshot.js";
|
|
5
|
+
import { readSnapshotKnowledge } from "../../traceability/snapshot-knowledge.js";
|
|
2
6
|
import { extractSymbolsFromStagedFileAsync } from "../../traceability/symbol-extract.js";
|
|
3
7
|
import { createSemanticReviewDiagnostics, createSymbolGranularityDiagnostics, } from "./diagnostics.js";
|
|
4
8
|
import { createImpactManifestLookup, readImpactManifestResults, } from "./manifest.js";
|
|
9
|
+
import { normalizeSourceFile } from "./source-changes.js";
|
|
5
10
|
import { collectSourceChanges, uniqueSorted } from "./source-changes.js";
|
|
6
11
|
import { buildNextActions, collectLinkedEntities, formatExtractedSymbols, } from "./summaries.js";
|
|
7
12
|
import { createSymbolQualityDiagnostics } from "./symbol-quality.js";
|
|
8
13
|
export async function analyzeChangedFileImpact(options) {
|
|
9
14
|
const workspaceRoot = path.resolve(options.workspaceRoot);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
const snapshot = options.staged
|
|
16
|
+
? captureStagedSnapshot(workspaceRoot)
|
|
17
|
+
: undefined;
|
|
18
|
+
const filter = new Set((options.sourceFiles ?? []).map((file) => normalizeSourceFile(workspaceRoot, file)));
|
|
19
|
+
const snapshotAnalysisInventory = snapshot
|
|
20
|
+
? snapshot.inventory.filter((file) => filter.size === 0 || filter.has(file.path))
|
|
21
|
+
: undefined;
|
|
22
|
+
const snapshotSourceInventory = snapshot
|
|
23
|
+
? snapshot.inventory.filter((file) => file.analysisDepth !== "metadata" &&
|
|
24
|
+
!file.skipReason &&
|
|
25
|
+
file.content !== undefined &&
|
|
26
|
+
(filter.size === 0 || filter.has(file.path)))
|
|
27
|
+
: undefined;
|
|
28
|
+
const sourceChanges = snapshot
|
|
29
|
+
? (snapshotSourceInventory ?? []).map((file) => ({
|
|
30
|
+
file: file.path,
|
|
31
|
+
status: file.status,
|
|
32
|
+
hunkRanges: file.hunkRanges,
|
|
33
|
+
content: file.content ?? "",
|
|
34
|
+
}))
|
|
35
|
+
: collectSourceChanges({ ...options, workspaceRoot });
|
|
36
|
+
const service = createMaintenanceSourceAnalysisService(workspaceRoot, snapshot ? readSnapshotSourceConfig(snapshot) : undefined);
|
|
37
|
+
const analyses = snapshot
|
|
38
|
+
? await analyzeSourceChanges(snapshotAnalysisInventory ?? [], service)
|
|
39
|
+
: undefined;
|
|
40
|
+
if (analyses)
|
|
41
|
+
assertSourceAnalysisGate(snapshotAnalysisInventory ?? [], analyses);
|
|
42
|
+
const sourceFiles = uniqueSorted(snapshot
|
|
43
|
+
? snapshot.inventory
|
|
44
|
+
.filter((file) => file.analysisDepth !== "metadata" &&
|
|
45
|
+
(filter.size === 0 || filter.has(file.path)))
|
|
46
|
+
.map((file) => file.path)
|
|
47
|
+
: sourceChanges.map((change) => change.file));
|
|
48
|
+
const manifestResults = snapshot
|
|
49
|
+
? readSnapshotKnowledge(snapshot.readGit, snapshot.headTree, snapshot.readBlobs).filter((result) => result.entity.type === "symbol")
|
|
50
|
+
: readImpactManifestResults(workspaceRoot);
|
|
13
51
|
const manifestLookup = createImpactManifestLookup(manifestResults);
|
|
14
52
|
const symbolsByFile = new Map();
|
|
15
53
|
const sourceContentByFile = new Map();
|
|
54
|
+
const sourceSymbolsByFile = new Map();
|
|
16
55
|
for (const change of sourceChanges) {
|
|
17
56
|
sourceContentByFile.set(change.file, change.content);
|
|
18
|
-
|
|
57
|
+
const analysis = analyses?.get(change.file)?.after ??
|
|
58
|
+
(await service.analyzeTextV2(change.file, change.content));
|
|
19
59
|
const extracted = await extractSymbolsFromStagedFileAsync({
|
|
20
60
|
path: change.file,
|
|
21
61
|
status: change.status,
|
|
22
62
|
hunkRanges: [...change.hunkRanges],
|
|
23
63
|
content: change.content,
|
|
24
|
-
}, manifestLookup, {});
|
|
64
|
+
}, manifestLookup, { analyzeText: async () => analysis });
|
|
65
|
+
const allSymbols = await extractSymbolsFromStagedFileAsync({
|
|
66
|
+
path: change.file,
|
|
67
|
+
status: change.status,
|
|
68
|
+
content: change.content,
|
|
69
|
+
hunkRanges: [
|
|
70
|
+
{ start: 1, end: Math.max(1, change.content.split("\n").length) },
|
|
71
|
+
],
|
|
72
|
+
}, manifestLookup, { analyzeText: async () => analysis });
|
|
73
|
+
sourceSymbolsByFile.set(change.file, allSymbols);
|
|
25
74
|
symbolsByFile.set(change.file, extracted.filter((symbol) => symbol.hunkRanges.length > 0));
|
|
26
75
|
}
|
|
27
76
|
const activeSourceFiles = new Set(sourceFiles);
|
|
@@ -34,6 +83,7 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
34
83
|
manifestResults: activeManifestResults,
|
|
35
84
|
symbolsByFile,
|
|
36
85
|
sourceContentByFile,
|
|
86
|
+
sourceSymbolsByFile,
|
|
37
87
|
workspaceRoot,
|
|
38
88
|
}),
|
|
39
89
|
...createSymbolQualityDiagnostics({
|
|
@@ -46,6 +96,7 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
46
96
|
const cappedDiagnostics = maxDiagnostics !== undefined && maxDiagnostics >= 0
|
|
47
97
|
? impactDiagnostics.slice(0, maxDiagnostics)
|
|
48
98
|
: impactDiagnostics;
|
|
99
|
+
snapshot?.assertUnchanged();
|
|
49
100
|
return {
|
|
50
101
|
impactDiagnostics: cappedDiagnostics,
|
|
51
102
|
sourceFiles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAYrF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAYrF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;AA6FpB,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,EAAE,CA+CxB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,oBAAoB,EAAE,CAsBxB;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAIT"}
|
|
@@ -38,7 +38,9 @@ function readSourceSymbols(sourceFile, sourceContentByFile, workspaceRoot) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
function getGranularSymbolsForSourceFile(sourceFile, options) {
|
|
41
|
-
const sourceSymbols =
|
|
41
|
+
const sourceSymbols = options.sourceSymbolsByFile
|
|
42
|
+
? (options.sourceSymbolsByFile.get(sourceFile) ?? [])
|
|
43
|
+
: readSourceSymbols(sourceFile, options.sourceContentByFile, options.workspaceRoot ?? process.cwd());
|
|
42
44
|
const changedSymbols = options.symbolsByFile.get(sourceFile);
|
|
43
45
|
return {
|
|
44
46
|
candidateSymbols: changedSymbols ?? sourceSymbols,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAatC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAWjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AASpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC;IAC7D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAmgBF,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,GAClD,OAAO,CAAC,gBAAgB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAatC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAWjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AASpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC;IAC7D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAmgBF,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,GAClD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA8C7B;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,OAAO,GAClB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAM/C;AA2ID,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAkCvC"}
|
|
@@ -404,18 +404,10 @@ export async function loadKbExtractionResults(prolog) {
|
|
|
404
404
|
entities = await loadIndexedEntityProjection(prolog.queryEntities.bind(prolog));
|
|
405
405
|
}
|
|
406
406
|
else {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
: [];
|
|
412
|
-
}
|
|
413
|
-
else if (isOutputCapacityError(entityResult.error)) {
|
|
414
|
-
entities = await loadBoundedEntityProjection(prolog);
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
throw new Error(`Full KB entity projection query failed: ${entityResult.error ?? "Unknown error"}`);
|
|
418
|
-
}
|
|
407
|
+
// Never probe with an unbounded all-entities findall: receipt histories
|
|
408
|
+
// make that answer grow without limit, and an overflow terminates the
|
|
409
|
+
// interactive Prolog process that serves every later query.
|
|
410
|
+
entities = await loadBoundedEntityProjection(prolog);
|
|
419
411
|
}
|
|
420
412
|
const relationships = new Map();
|
|
421
413
|
for (const relationshipType of RELATIONSHIP_TYPES) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/public/impact/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/public/impact/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAc3E,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,GACpB,SAAS,gBAAgB,EAAE,CAkB7B;AAED,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,SAAS,gBAAgB,EAAE,GAC3C,cAAc,CAwBhB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { extractFromManifest } from "../../extractors/manifest.js";
|
|
4
|
+
import { createManifestLookupSentinelKey } from "../../traceability/symbol-extract.js";
|
|
4
5
|
import { CANONICAL_ENTITY_PATHS } from "../../utils/kb-paths.js";
|
|
5
6
|
import { isTraceabilityRelationshipType } from "../symbol-granularity.js";
|
|
6
7
|
import { normalizeSourceFile } from "./source-changes.js";
|
|
@@ -29,9 +30,22 @@ export function readImpactManifestResults(workspaceRoot) {
|
|
|
29
30
|
}
|
|
30
31
|
export function createImpactManifestLookup(manifestResults) {
|
|
31
32
|
const manifestLookup = new Map();
|
|
33
|
+
manifestLookup.set(createManifestLookupSentinelKey(".kb/symbols.yaml"), {
|
|
34
|
+
id: "__captured_manifest__",
|
|
35
|
+
relationships: [],
|
|
36
|
+
});
|
|
37
|
+
const ambiguous = new Set();
|
|
32
38
|
for (const result of manifestResults) {
|
|
33
39
|
const sourceFile = result.sourceFile ?? result.entity.source;
|
|
34
|
-
|
|
40
|
+
const key = `${sourceFile}:${result.entity.title}`;
|
|
41
|
+
if (ambiguous.has(key))
|
|
42
|
+
continue;
|
|
43
|
+
if (manifestLookup.has(key)) {
|
|
44
|
+
manifestLookup.delete(key);
|
|
45
|
+
ambiguous.add(key);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
manifestLookup.set(key, {
|
|
35
49
|
id: result.entity.id,
|
|
36
50
|
relationships: toTraceabilityRelationships(result.relationships),
|
|
37
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-changes.d.ts","sourceRoot":"","sources":["../../../src/public/impact/source-changes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-changes.d.ts","sourceRoot":"","sources":["../../../src/public/impact/source-changes.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAMzE,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAE/D;AA4ID,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,wBAAwB,GAChC,YAAY,EAAE,CAchB"}
|