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
|
@@ -1,11 +1,167 @@
|
|
|
1
|
-
import { buildStrictWriteSet } from "../../public/check-types.js";
|
|
1
|
+
import { buildStrictWriteSet, } from "../../public/check-types.js";
|
|
2
2
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
3
|
+
import { isConventionalSubjectKey, normalizeSubjectKey, } from "../../utils/strict-modeling.js";
|
|
3
4
|
import { normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
|
|
4
5
|
import { semanticSourceHash } from "../semantic-advisor/shared.js";
|
|
5
6
|
import { buildLogicApplyPlan } from "./logic-modeling.js";
|
|
6
7
|
import { strictWriteSetToApplyPlan, writeSetPrimaryEntityId, } from "./requirement-applyplan.js";
|
|
7
8
|
import { estimateNormativeSignalConfidence, extractRequirementClaim, } from "./requirement-modeler.js";
|
|
8
9
|
import { normalizeOptionalString, normalizeSourceFiles, } from "./requirement-utils.js";
|
|
10
|
+
import { alignRequirementVocabulary, } from "./vocabulary-alignment.js";
|
|
11
|
+
const NEW_SUBJECT_REVIEW_SCORE = 0.3;
|
|
12
|
+
function reuseExistingSubject(writeSet, existingFactId) {
|
|
13
|
+
if (!writeSet.isStrict)
|
|
14
|
+
return { writeSet, replacedSubjectId: null };
|
|
15
|
+
const replacedSubjectId = writeSet.subjectFact.id;
|
|
16
|
+
return {
|
|
17
|
+
replacedSubjectId,
|
|
18
|
+
writeSet: {
|
|
19
|
+
...writeSet,
|
|
20
|
+
subjectFact: {
|
|
21
|
+
...writeSet.subjectFact,
|
|
22
|
+
id: existingFactId,
|
|
23
|
+
properties: { ...writeSet.subjectFact.properties, id: existingFactId },
|
|
24
|
+
},
|
|
25
|
+
relationships: writeSet.relationships.map((relationship) => relationship.type === "constrains"
|
|
26
|
+
? { ...relationship, to: existingFactId }
|
|
27
|
+
: relationship),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function possibleDuplicateObservation(claimKey, statement, source, candidates) {
|
|
32
|
+
const id = `FACT-OBS-POSSIBLE-DUPLICATE-${claimKey.replace(/^CLAIM-/, "")}`;
|
|
33
|
+
return {
|
|
34
|
+
type: "fact",
|
|
35
|
+
id,
|
|
36
|
+
properties: {
|
|
37
|
+
id,
|
|
38
|
+
title: `Possible duplicate: ${statement}`,
|
|
39
|
+
status: "active",
|
|
40
|
+
source,
|
|
41
|
+
fact_kind: "observation",
|
|
42
|
+
tags: ["review:possible-duplicate", "vocabulary-alignment"],
|
|
43
|
+
},
|
|
44
|
+
relationships: candidates.map((candidate) => ({
|
|
45
|
+
type: "relates_to",
|
|
46
|
+
from: id,
|
|
47
|
+
to: candidate.factId,
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the clause subject against the existing KB vocabulary. A heuristic
|
|
53
|
+
* subject converges onto the chosen existing subject; an explicitly provided
|
|
54
|
+
* subject is kept (the caller owns it) but reuses the existing subject fact
|
|
55
|
+
* when the keys match. Otherwise the plan explicitly declares a new subject.
|
|
56
|
+
*/
|
|
57
|
+
// implements REQ-kibi-subject-vocabulary
|
|
58
|
+
async function applyVocabularyAlignment(context, extracted, claimKey) {
|
|
59
|
+
const initial = buildStrictWriteSet({
|
|
60
|
+
claim: extracted.claim,
|
|
61
|
+
statement: extracted.statement,
|
|
62
|
+
});
|
|
63
|
+
const unchanged = {
|
|
64
|
+
writeSet: initial,
|
|
65
|
+
outcome: null,
|
|
66
|
+
warnings: [],
|
|
67
|
+
reviewPlan: [],
|
|
68
|
+
adjustPlan: (plan) => plan,
|
|
69
|
+
};
|
|
70
|
+
if (!context?.prolog || !initial.isStrict)
|
|
71
|
+
return unchanged;
|
|
72
|
+
const proposedSubjectKey = normalizeSubjectKey(extracted.claim.subjectKey);
|
|
73
|
+
const outcome = await alignRequirementVocabulary(context, {
|
|
74
|
+
claimKey,
|
|
75
|
+
statement: extracted.statement,
|
|
76
|
+
proposedSubjectKey,
|
|
77
|
+
});
|
|
78
|
+
if (outcome === null)
|
|
79
|
+
return unchanged;
|
|
80
|
+
const warnings = [];
|
|
81
|
+
let writeSet = initial;
|
|
82
|
+
let replacedSubjectId = null;
|
|
83
|
+
const subject = outcome.subject;
|
|
84
|
+
if (subject.decision === "reuse_existing" && subject.existingFactId) {
|
|
85
|
+
const followsVocabulary = extracted.extractionMode !== "provided" ||
|
|
86
|
+
proposedSubjectKey === subject.subjectKey;
|
|
87
|
+
if (followsVocabulary) {
|
|
88
|
+
const rebuilt = buildStrictWriteSet({
|
|
89
|
+
claim: { ...extracted.claim, subjectKey: subject.subjectKey },
|
|
90
|
+
statement: extracted.statement,
|
|
91
|
+
});
|
|
92
|
+
({ writeSet, replacedSubjectId } = reuseExistingSubject(rebuilt, subject.existingFactId));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
warnings.push({
|
|
96
|
+
kind: "subject_reuse_review",
|
|
97
|
+
message: `Provided subjectKey ${proposedSubjectKey} is new, but existing subject ${subject.subjectKey} (${subject.existingFactId}) matches this clause.`,
|
|
98
|
+
nextAction: `Reuse subjectKey ${subject.subjectKey} so this requirement can be compared with the others on that subject, or keep ${proposedSubjectKey} if it is genuinely a different component.`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (!isConventionalSubjectKey(subject.subjectKey)) {
|
|
104
|
+
warnings.push({
|
|
105
|
+
kind: "subject_key_shape_review",
|
|
106
|
+
message: `New subject key ${subject.subjectKey} does not follow the component.aspect[.sub] convention checked by subject-key-shape.`,
|
|
107
|
+
nextAction: "Pass subjectKey as a dotted key with lowercase snake segments (for example kibi.cli.gc) so later requirements about the same component can reuse it.",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const nearest = subject.candidates[0];
|
|
111
|
+
if (nearest && nearest.score >= NEW_SUBJECT_REVIEW_SCORE) {
|
|
112
|
+
warnings.push({
|
|
113
|
+
kind: "new_subject_declared",
|
|
114
|
+
message: `Declaring new subject ${subject.subjectKey}; nearest existing subject is ${nearest.subjectKey} (score ${nearest.score}).`,
|
|
115
|
+
nextAction: "Confirm the new subject is a different component, or pass subjectKey set to the existing subject to reuse it.",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const reviewPlan = outcome.redundancyCandidates.length > 0
|
|
120
|
+
? [
|
|
121
|
+
possibleDuplicateObservation(claimKey, extracted.statement, extracted.source, outcome.redundancyCandidates),
|
|
122
|
+
]
|
|
123
|
+
: [];
|
|
124
|
+
if (outcome.redundancyCandidates.length > 0) {
|
|
125
|
+
warnings.push({
|
|
126
|
+
kind: "possible_duplicate",
|
|
127
|
+
message: `This clause may restate existing claim(s) ${outcome.redundancyCandidates
|
|
128
|
+
.map((candidate) => candidate.factId)
|
|
129
|
+
.join(", ")} on ${subject.subjectKey}.`,
|
|
130
|
+
nextAction: "Review the candidates: reuse the existing fact, supersede or restate the existing requirement, or record the returned review:possible-duplicate observation. This is advice, not a check verdict.",
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const declaredNew = subject.decision === "declare_new";
|
|
134
|
+
return {
|
|
135
|
+
writeSet,
|
|
136
|
+
outcome,
|
|
137
|
+
warnings,
|
|
138
|
+
reviewPlan,
|
|
139
|
+
adjustPlan: (plan) => plan
|
|
140
|
+
.filter((step) => !(replacedSubjectId !== null &&
|
|
141
|
+
writeSet.isStrict &&
|
|
142
|
+
step.id === writeSet.subjectFact.id &&
|
|
143
|
+
step.type === "fact" &&
|
|
144
|
+
step.properties
|
|
145
|
+
?.fact_kind === "subject"))
|
|
146
|
+
.map((step) => {
|
|
147
|
+
if (!declaredNew ||
|
|
148
|
+
step.type !== "fact" ||
|
|
149
|
+
step.properties
|
|
150
|
+
?.fact_kind !== "subject") {
|
|
151
|
+
return step;
|
|
152
|
+
}
|
|
153
|
+
const properties = step.properties;
|
|
154
|
+
const tags = Array.isArray(properties.tags) ? properties.tags : [];
|
|
155
|
+
return {
|
|
156
|
+
...step,
|
|
157
|
+
properties: {
|
|
158
|
+
...properties,
|
|
159
|
+
tags: [...tags, "vocabulary:new-subject"],
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
9
165
|
export { estimateNormativeSignalConfidence, extractRequirementClaim, strictWriteSetToApplyPlan, writeSetPrimaryEntityId, };
|
|
10
166
|
// implements REQ-kibi-logical-requirement-coverage
|
|
11
167
|
// covered_by TEST-kibi-logical-requirement-coverage
|
|
@@ -61,7 +217,7 @@ export async function getWorkspaceMigrationWarning(workspaceRoot) {
|
|
|
61
217
|
return null;
|
|
62
218
|
return status.warning;
|
|
63
219
|
}
|
|
64
|
-
export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
|
|
220
|
+
export async function handleKbModelRequirement(_prolog, args, workspaceRoot, context) {
|
|
65
221
|
const extracted = extractRequirementClaim({
|
|
66
222
|
...args,
|
|
67
223
|
source: normalizeOptionalString(args.source) ??
|
|
@@ -123,20 +279,20 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
|
|
|
123
279
|
migrationWarning,
|
|
124
280
|
};
|
|
125
281
|
}
|
|
126
|
-
const writeSet = buildStrictWriteSet({
|
|
127
|
-
claim: extracted.claim,
|
|
128
|
-
statement: extracted.statement,
|
|
129
|
-
});
|
|
130
282
|
const claimKey = semanticClaimKey(extracted.statement);
|
|
283
|
+
const aligned = await applyVocabularyAlignment(context, extracted, claimKey);
|
|
284
|
+
const writeSet = aligned.writeSet;
|
|
131
285
|
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
132
|
-
const applyPlan =
|
|
286
|
+
const applyPlan = aligned
|
|
287
|
+
.adjustPlan(strictWriteSetToApplyPlan(writeSet))
|
|
288
|
+
.map((step) => annotateModelRequirementStep(step, {
|
|
133
289
|
claimKey,
|
|
134
290
|
statement: extracted.statement,
|
|
135
291
|
logicClaims,
|
|
136
292
|
}));
|
|
137
293
|
const migrationWarning = await getWorkspaceMigrationWarning(workspaceRoot);
|
|
138
294
|
const warnings = writeSet.isStrict
|
|
139
|
-
? []
|
|
295
|
+
? [...aligned.warnings]
|
|
140
296
|
: [
|
|
141
297
|
{
|
|
142
298
|
kind: "low_confidence_observation_downgrade",
|
|
@@ -162,6 +318,14 @@ export async function handleKbModelRequirement(_prolog, args, workspaceRoot) {
|
|
|
162
318
|
extractionWarnings: extracted.extractionWarnings,
|
|
163
319
|
warnings,
|
|
164
320
|
migrationWarning,
|
|
321
|
+
...(aligned.outcome !== null
|
|
322
|
+
? {
|
|
323
|
+
vocabularyAlignment: {
|
|
324
|
+
...aligned.outcome,
|
|
325
|
+
reviewPlan: aligned.reviewPlan,
|
|
326
|
+
},
|
|
327
|
+
}
|
|
328
|
+
: {}),
|
|
165
329
|
};
|
|
166
330
|
return {
|
|
167
331
|
content: [
|
|
@@ -182,6 +346,8 @@ export async function executeModelRequirement(args, context) {
|
|
|
182
346
|
// kb_model_requirement is intentionally off the external semantic-classifier
|
|
183
347
|
// allowlist: classification after modeling only produced provenance warnings
|
|
184
348
|
// and is not worth a metered provider call. Use kb_semantic_advisor when
|
|
185
|
-
// classifier routing is needed.
|
|
186
|
-
|
|
349
|
+
// classifier routing is needed. It is on the vocabulary-alignment allowlist:
|
|
350
|
+
// choosing an existing subject is exactly the modeling-time decision that
|
|
351
|
+
// provider is for, and it only runs when explicitly activated.
|
|
352
|
+
return handleKbModelRequirement(context.prolog, args, context.workspaceRoot, context);
|
|
187
353
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAQ9B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,EACvD,YAAY,CAAC,EAAE,QAAQ,GAAG,MAAM,EAChC,WAAW,CAAC,EAAE;IACZ,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACtC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GACA,mBAAmB,CA8FrB;AAGD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqChC;AAGD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAwBhC;AAGD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+BhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,0BAA0B,CAoE5B"}
|
|
@@ -4,16 +4,27 @@ import { aggregateBindingProvenance, bindingCanBeApplied, classifyBinding, isGen
|
|
|
4
4
|
import { inferArgs } from "./predicate-inference.js";
|
|
5
5
|
import { schemaForCandidate } from "./predicate-loader.js";
|
|
6
6
|
import { hashId } from "./predicate-utils.js";
|
|
7
|
+
import { applyArgumentRewrites, predicateArgumentConformance, } from "./predicate-vocabulary.js";
|
|
7
8
|
// implements REQ-mcp-suggest-predicates
|
|
8
9
|
export function buildSuggestion(schema, text, subject, score, argumentBindings = {}, polarityHint, diagnostics) {
|
|
9
10
|
const inferredArgs = inferArgs(schema, text, subject);
|
|
10
11
|
const canonicalLauncherArgs = exactLauncherPredicateArgs(schema.predicate_name, text);
|
|
11
|
-
const
|
|
12
|
+
const boundArgs = schema.argument_names.map((name, index) => {
|
|
12
13
|
const exactBinding = argumentBindings[name];
|
|
13
14
|
return typeof exactBinding === "string" && exactBinding.trim().length > 0
|
|
14
15
|
? exactBinding.trim()
|
|
15
16
|
: (inferredArgs[index] ?? "unknown");
|
|
16
17
|
});
|
|
18
|
+
// A schema with closed argument vocabularies only accepts its declared
|
|
19
|
+
// constants: aliases converge onto the constant, anything else stays
|
|
20
|
+
// unbound so the plan asks for a declared value instead of minting an atom.
|
|
21
|
+
const vocabulary = {
|
|
22
|
+
constants: schema.argument_constants ?? {},
|
|
23
|
+
aliases: schema.argument_aliases ?? {},
|
|
24
|
+
};
|
|
25
|
+
const conformance = predicateArgumentConformance(schema.argument_names, boundArgs, vocabulary);
|
|
26
|
+
const predicateArgs = applyArgumentRewrites(boundArgs, conformance.rewrites);
|
|
27
|
+
const undeclaredArguments = new Set(conformance.undeclared.map((value) => value.argumentName));
|
|
17
28
|
const bindingProvenanceByArgument = Object.fromEntries(schema.argument_names.map((name, index) => [
|
|
18
29
|
name,
|
|
19
30
|
classifyBinding(predicateArgs[index] ?? "unknown", text, (typeof argumentBindings[name] === "string" &&
|
|
@@ -25,7 +36,8 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
25
36
|
typeof argumentBindings[name] !== "string")),
|
|
26
37
|
]));
|
|
27
38
|
const bindingProvenance = aggregateBindingProvenance(Object.values(bindingProvenanceByArgument));
|
|
28
|
-
const unboundArguments = schema.argument_names.filter((name) =>
|
|
39
|
+
const unboundArguments = schema.argument_names.filter((name) => undeclaredArguments.has(name) ||
|
|
40
|
+
!bindingCanBeApplied(bindingProvenanceByArgument[name] ?? "placeholder"));
|
|
29
41
|
const canonicalKey = `${schema.predicate_name}(${predicateArgs.join(",")})`;
|
|
30
42
|
// Permission-style inference carries the deontic decision as its final
|
|
31
43
|
// argument. Preserve that polarity in the typed suggestion instead of
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizePredicateToken, normalizeSubjectKey, singularize, slug, } from "./predicate-utils.js";
|
|
2
2
|
// implements REQ-mcp-suggest-predicates
|
|
3
3
|
export function inferPermissionRuleArgs(text) {
|
|
4
|
-
const prohibition = text.match(/^(?<actor>[a-z][a-z\s_-]*?)\s+(?:must\s+not|cannot|can't|is\s+forbidden\s+to)\s+(?<action>[a-z][a-z_-]*)\s+(?<resource>.+?)\.?$/i);
|
|
4
|
+
const prohibition = text.match(/^(?<actor>[a-z][a-z\s_-]*?)\s+(?:must\s+not|must\s+never|never|cannot|can't|is\s+forbidden\s+to)\s+(?<action>[a-z][a-z_-]*)\s+(?<resource>.+?)\.?$/i);
|
|
5
5
|
if (prohibition?.groups) {
|
|
6
6
|
return [
|
|
7
7
|
singularize(slug(prohibition.groups.actor ?? "actor")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-loader.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAK3E,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-loader.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAK3E,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAI9B,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAExE;AAGD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CACxE,wBAAwB,EACxB,UAAU,CACX,GAAG;IACF,WAAW,EAAE,mBAAmB,CAAC;CAClC,CA4BA;AAGD,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,sBAAsB,EAAE,OAAO,EAC/B,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAwBrC;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,wBAAwB,EAAE,CAwD5B;AAGD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,mBAAmB,GAAG,SAAS,CAOjC;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAQpD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseEntityFromList, parseListOfLists } from "../../prolog/codec.js";
|
|
2
2
|
import { DEFAULT_USAGE_HINTS, USAGE_HINTS_BY_PREDICATE, } from "./predicate-catalog.js";
|
|
3
3
|
import { hashId, normalizeOptionalString } from "./predicate-utils.js";
|
|
4
|
+
import { predicateVocabularyFromEntity } from "./predicate-vocabulary.js";
|
|
4
5
|
export function optionalPredicateName(value) {
|
|
5
6
|
return typeof value === "string" ? value : undefined;
|
|
6
7
|
}
|
|
@@ -16,6 +17,12 @@ export function schemaForCandidate(schema) {
|
|
|
16
17
|
...(schema.argument_descriptions
|
|
17
18
|
? { argument_descriptions: schema.argument_descriptions }
|
|
18
19
|
: {}),
|
|
20
|
+
...(schema.argument_constants
|
|
21
|
+
? { argument_constants: schema.argument_constants }
|
|
22
|
+
: {}),
|
|
23
|
+
...(schema.argument_aliases
|
|
24
|
+
? { argument_aliases: schema.argument_aliases }
|
|
25
|
+
: {}),
|
|
19
26
|
...(schema.aliases ? { aliases: schema.aliases } : {}),
|
|
20
27
|
...(schema.paraphrase_templates
|
|
21
28
|
? { paraphrase_templates: schema.paraphrase_templates }
|
|
@@ -57,6 +64,7 @@ export function predicateSchemaFromEntity(entity) {
|
|
|
57
64
|
return [];
|
|
58
65
|
const usageHints = usageHintsFromEntity(entity);
|
|
59
66
|
const argumentDescriptions = stringArray(entity.argument_descriptions);
|
|
67
|
+
const vocabulary = predicateVocabularyFromEntity(entity);
|
|
60
68
|
return [
|
|
61
69
|
{
|
|
62
70
|
id: String(entity.id ?? hashId("FACT-SCHEMA", [predicateName])),
|
|
@@ -69,6 +77,22 @@ export function predicateSchemaFromEntity(entity) {
|
|
|
69
77
|
...(argumentDescriptions.length > 0
|
|
70
78
|
? { argument_descriptions: argumentDescriptions }
|
|
71
79
|
: {}),
|
|
80
|
+
...(Object.keys(vocabulary.constants).length > 0
|
|
81
|
+
? {
|
|
82
|
+
argument_constants: Object.fromEntries(Object.entries(vocabulary.constants).map(([name, values]) => [
|
|
83
|
+
name,
|
|
84
|
+
[...values],
|
|
85
|
+
])),
|
|
86
|
+
}
|
|
87
|
+
: {}),
|
|
88
|
+
...(Object.keys(vocabulary.aliases).length > 0
|
|
89
|
+
? {
|
|
90
|
+
argument_aliases: Object.fromEntries(Object.entries(vocabulary.aliases).map(([name, mapping]) => [
|
|
91
|
+
name,
|
|
92
|
+
{ ...mapping },
|
|
93
|
+
])),
|
|
94
|
+
}
|
|
95
|
+
: {}),
|
|
72
96
|
keywords: [
|
|
73
97
|
predicateName,
|
|
74
98
|
...stringArray(entity.aliases),
|
|
@@ -12,6 +12,10 @@ export interface PredicateSchemaCandidate {
|
|
|
12
12
|
argument_types: string[];
|
|
13
13
|
/** Optional human-readable descriptions aligned with argument_names. */
|
|
14
14
|
argument_descriptions?: string[];
|
|
15
|
+
/** Closed vocabularies: allowed constants keyed by argument name. */
|
|
16
|
+
argument_constants?: Record<string, string[]>;
|
|
17
|
+
/** Legacy spellings keyed by argument name, each mapped to a constant. */
|
|
18
|
+
argument_aliases?: Record<string, Record<string, string>>;
|
|
15
19
|
keywords: string[];
|
|
16
20
|
/** Human-language aliases and controlled paraphrase templates used for deterministic retrieval. */
|
|
17
21
|
aliases?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-types.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,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U,EAAE,mBAAmB,EAAE,CAAC;QAClC,iBAAiB,EACb,0BAA0B,GAC1B,2BAA2B,GAC3B,0BAA0B,GAC1B,qBAAqB,GACrB,mBAAmB,CAAC;QACxB,0BAA0B,EAAE,0BAA0B,GAAG,IAAI,CAAC;QAC9D,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACjD,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closed argument vocabularies for predicate schemas.
|
|
3
|
+
*
|
|
4
|
+
* A `predicate_schema` may declare, per argument name, the constants that
|
|
5
|
+
* argument accepts (`argument_constants`) and legacy spellings that map onto
|
|
6
|
+
* one of them (`argument_aliases`). Arguments without an entry stay open.
|
|
7
|
+
* Declaring constants is what makes paraphrased claims converge: two facts
|
|
8
|
+
* can only share a ground term when they use the same atoms.
|
|
9
|
+
*/
|
|
10
|
+
export type PredicateVocabulary = Readonly<{
|
|
11
|
+
constants: Readonly<Record<string, readonly string[]>>;
|
|
12
|
+
aliases: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
13
|
+
}>;
|
|
14
|
+
export type ArgumentRewrite = Readonly<{
|
|
15
|
+
index: number;
|
|
16
|
+
argumentName: string;
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
}>;
|
|
20
|
+
export type UndeclaredArgument = Readonly<{
|
|
21
|
+
index: number;
|
|
22
|
+
argumentName: string;
|
|
23
|
+
value: string;
|
|
24
|
+
allowed: readonly string[];
|
|
25
|
+
}>;
|
|
26
|
+
export type ArgumentConformance = Readonly<{
|
|
27
|
+
/** Alias spellings with their declared canonical constant. */
|
|
28
|
+
rewrites: readonly ArgumentRewrite[];
|
|
29
|
+
/** Values that are neither a declared constant nor an alias. */
|
|
30
|
+
undeclared: readonly UndeclaredArgument[];
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Read a schema's vocabulary. Malformed entries are ignored here; use
|
|
34
|
+
* {@link predicateVocabularyErrors} to report them.
|
|
35
|
+
*/
|
|
36
|
+
export declare function predicateVocabularyFromEntity(entity: Readonly<Record<string, unknown>>): PredicateVocabulary;
|
|
37
|
+
export declare function hasPredicateVocabulary(vocabulary: PredicateVocabulary): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Cross-field errors in a predicate schema's vocabulary: every key must be an
|
|
40
|
+
* argument name, aliases need declared constants for their argument, alias
|
|
41
|
+
* targets must be declared, and an alias may not shadow a constant.
|
|
42
|
+
*/
|
|
43
|
+
export declare function predicateVocabularyErrors(entity: Readonly<Record<string, unknown>>): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Compare predicate arguments with a schema vocabulary. Open arguments always
|
|
46
|
+
* conform; an alias is reported as a rewrite, anything else not declared is
|
|
47
|
+
* reported as undeclared.
|
|
48
|
+
*/
|
|
49
|
+
export declare function predicateArgumentConformance(argumentNames: readonly string[], args: readonly string[], vocabulary: PredicateVocabulary): ArgumentConformance;
|
|
50
|
+
/** Arguments with every alias replaced by its declared constant. */
|
|
51
|
+
export declare function applyArgumentRewrites(args: readonly string[], rewrites: readonly ArgumentRewrite[]): string[];
|
|
52
|
+
/** Canonical key convention shared with predicate apply plans. */
|
|
53
|
+
export declare function predicateCanonicalKey(predicateName: string, args: readonly string[]): string;
|
|
54
|
+
//# sourceMappingURL=predicate-vocabulary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicate-vocabulary.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-vocabulary.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AAGH,MAAM,MAAM,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EAAE,EAChC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,UAAU,EAAE,mBAAmB,GAC9B,mBAAmB,CAgBrB;AAED,oEAAoE;AAEpE,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,QAAQ,EAAE,SAAS,eAAe,EAAE,GACnC,MAAM,EAAE,CAIV;AAED,kEAAkE;AAElE,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,CAER"}
|
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
function isRecord(value) {
|
|
19
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
/** Structured fields arrive as objects from Markdown or as JSON strings from Prolog. */
|
|
22
|
+
function structuredField(value) {
|
|
23
|
+
if (typeof value !== "string")
|
|
24
|
+
return value;
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(value);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read a schema's vocabulary. Malformed entries are ignored here; use
|
|
34
|
+
* {@link predicateVocabularyErrors} to report them.
|
|
35
|
+
*/
|
|
36
|
+
// implements REQ-kibi-predicate-argument-constants
|
|
37
|
+
export function predicateVocabularyFromEntity(entity) {
|
|
38
|
+
const rawConstants = structuredField(entity.argument_constants);
|
|
39
|
+
const rawAliases = structuredField(entity.argument_aliases);
|
|
40
|
+
const constants = {};
|
|
41
|
+
if (isRecord(rawConstants)) {
|
|
42
|
+
for (const [name, values] of Object.entries(rawConstants)) {
|
|
43
|
+
if (!Array.isArray(values))
|
|
44
|
+
continue;
|
|
45
|
+
const strings = values.filter((value) => typeof value === "string" && value.length > 0);
|
|
46
|
+
if (strings.length > 0)
|
|
47
|
+
constants[name] = [...new Set(strings)];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const aliases = {};
|
|
51
|
+
if (isRecord(rawAliases)) {
|
|
52
|
+
for (const [name, mapping] of Object.entries(rawAliases)) {
|
|
53
|
+
if (!isRecord(mapping))
|
|
54
|
+
continue;
|
|
55
|
+
const entries = Object.entries(mapping).filter((entry) => typeof entry[1] === "string" && entry[1].length > 0);
|
|
56
|
+
if (entries.length > 0)
|
|
57
|
+
aliases[name] = Object.fromEntries(entries);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { constants, aliases };
|
|
61
|
+
}
|
|
62
|
+
// implements REQ-kibi-predicate-argument-constants
|
|
63
|
+
export function hasPredicateVocabulary(vocabulary) {
|
|
64
|
+
return (Object.keys(vocabulary.constants).length > 0 ||
|
|
65
|
+
Object.keys(vocabulary.aliases).length > 0);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Cross-field errors in a predicate schema's vocabulary: every key must be an
|
|
69
|
+
* argument name, aliases need declared constants for their argument, alias
|
|
70
|
+
* targets must be declared, and an alias may not shadow a constant.
|
|
71
|
+
*/
|
|
72
|
+
// implements REQ-kibi-predicate-argument-constants
|
|
73
|
+
export function predicateVocabularyErrors(entity) {
|
|
74
|
+
const errors = [];
|
|
75
|
+
const rawConstants = structuredField(entity.argument_constants);
|
|
76
|
+
const rawAliases = structuredField(entity.argument_aliases);
|
|
77
|
+
if (rawConstants === undefined && rawAliases === undefined)
|
|
78
|
+
return errors;
|
|
79
|
+
if (entity.fact_kind !== "predicate_schema") {
|
|
80
|
+
errors.push("argument_constants and argument_aliases are only valid on fact_kind predicate_schema");
|
|
81
|
+
return errors;
|
|
82
|
+
}
|
|
83
|
+
const argumentNames = Array.isArray(entity.argument_names)
|
|
84
|
+
? entity.argument_names.filter((name) => typeof name === "string")
|
|
85
|
+
: [];
|
|
86
|
+
if (rawConstants !== undefined && !isRecord(rawConstants)) {
|
|
87
|
+
errors.push("argument_constants must map argument names to constant lists");
|
|
88
|
+
}
|
|
89
|
+
if (rawAliases !== undefined && !isRecord(rawAliases)) {
|
|
90
|
+
errors.push("argument_aliases must map argument names to alias-to-constant objects");
|
|
91
|
+
}
|
|
92
|
+
const vocabulary = predicateVocabularyFromEntity(entity);
|
|
93
|
+
if (isRecord(rawConstants)) {
|
|
94
|
+
for (const [name, values] of Object.entries(rawConstants)) {
|
|
95
|
+
if (!argumentNames.includes(name)) {
|
|
96
|
+
errors.push(`argument_constants.${name} is not one of argument_names (${argumentNames.join(", ")})`);
|
|
97
|
+
}
|
|
98
|
+
if (!Array.isArray(values) ||
|
|
99
|
+
values.length === 0 ||
|
|
100
|
+
values.some((value) => typeof value !== "string" || value === "")) {
|
|
101
|
+
errors.push(`argument_constants.${name} must be a non-empty list of non-empty strings`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (isRecord(rawAliases)) {
|
|
106
|
+
for (const [name, mapping] of Object.entries(rawAliases)) {
|
|
107
|
+
if (!argumentNames.includes(name)) {
|
|
108
|
+
errors.push(`argument_aliases.${name} is not one of argument_names (${argumentNames.join(", ")})`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const declared = vocabulary.constants[name];
|
|
112
|
+
if (declared === undefined) {
|
|
113
|
+
errors.push(`argument_aliases.${name} requires argument_constants.${name} to declare the canonical constants`);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (!isRecord(mapping)) {
|
|
117
|
+
errors.push(`argument_aliases.${name} must map alias spellings to constants`);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
for (const [alias, target] of Object.entries(mapping)) {
|
|
121
|
+
if (typeof target !== "string" || !declared.includes(target)) {
|
|
122
|
+
errors.push(`argument_aliases.${name}.${alias} must name a declared constant of ${name}`);
|
|
123
|
+
}
|
|
124
|
+
if (declared.includes(alias)) {
|
|
125
|
+
errors.push(`argument_aliases.${name}.${alias} shadows a declared constant; remove the alias`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return errors;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Compare predicate arguments with a schema vocabulary. Open arguments always
|
|
134
|
+
* conform; an alias is reported as a rewrite, anything else not declared is
|
|
135
|
+
* reported as undeclared.
|
|
136
|
+
*/
|
|
137
|
+
// implements REQ-kibi-predicate-argument-constants
|
|
138
|
+
export function predicateArgumentConformance(argumentNames, args, vocabulary) {
|
|
139
|
+
const rewrites = [];
|
|
140
|
+
const undeclared = [];
|
|
141
|
+
args.forEach((value, index) => {
|
|
142
|
+
const argumentName = argumentNames[index];
|
|
143
|
+
if (argumentName === undefined)
|
|
144
|
+
return;
|
|
145
|
+
const allowed = vocabulary.constants[argumentName];
|
|
146
|
+
if (allowed === undefined || allowed.includes(value))
|
|
147
|
+
return;
|
|
148
|
+
const canonical = vocabulary.aliases[argumentName]?.[value];
|
|
149
|
+
if (canonical !== undefined && allowed.includes(canonical)) {
|
|
150
|
+
rewrites.push({ index, argumentName, from: value, to: canonical });
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
undeclared.push({ index, argumentName, value, allowed });
|
|
154
|
+
});
|
|
155
|
+
return { rewrites, undeclared };
|
|
156
|
+
}
|
|
157
|
+
/** Arguments with every alias replaced by its declared constant. */
|
|
158
|
+
// implements REQ-kibi-predicate-argument-constants
|
|
159
|
+
export function applyArgumentRewrites(args, rewrites) {
|
|
160
|
+
const next = [...args];
|
|
161
|
+
for (const rewrite of rewrites)
|
|
162
|
+
next[rewrite.index] = rewrite.to;
|
|
163
|
+
return next;
|
|
164
|
+
}
|
|
165
|
+
/** Canonical key convention shared with predicate apply plans. */
|
|
166
|
+
// implements REQ-kibi-predicate-argument-constants
|
|
167
|
+
export function predicateCanonicalKey(predicateName, args) {
|
|
168
|
+
return `${predicateName}(${args.join(",")})`;
|
|
169
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LogicRuleIR } from "../../logic/ir.js";
|
|
2
2
|
import type { SemanticClaim, StrictWriteSet } from "../../public/check-types.js";
|
|
3
|
+
import type { VocabularyAlignmentOutcome } from "./vocabulary-alignment.js";
|
|
3
4
|
export type ModelRequirementArgs = Readonly<Record<string, unknown>> & {
|
|
4
5
|
readonly text: string;
|
|
5
6
|
readonly source?: string;
|
|
@@ -46,6 +47,10 @@ export interface ModelRequirementResult {
|
|
|
46
47
|
nextAction: string;
|
|
47
48
|
}>;
|
|
48
49
|
migrationWarning: string | null;
|
|
50
|
+
/** Subject reuse decision and possible-duplicate review candidates. */
|
|
51
|
+
vocabularyAlignment?: VocabularyAlignmentOutcome & {
|
|
52
|
+
readonly reviewPlan: Array<Record<string, unknown>>;
|
|
53
|
+
};
|
|
49
54
|
logic?: {
|
|
50
55
|
readonly semanticKey: string;
|
|
51
56
|
readonly claimKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requirement-types.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/requirement-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa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