kibi-cli 0.14.0 → 0.17.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/bin/kibi +3 -1
- package/dist/cli-command.d.ts +5 -0
- package/dist/cli-command.d.ts.map +1 -0
- package/dist/cli-command.js +9 -0
- package/dist/cli-errors.d.ts +13 -0
- package/dist/cli-errors.d.ts.map +1 -0
- package/dist/cli-errors.js +26 -0
- package/dist/cli-input.d.ts +6 -0
- package/dist/cli-input.d.ts.map +1 -0
- package/dist/cli-input.js +54 -0
- package/dist/cli-json-command.d.ts +14 -0
- package/dist/cli-json-command.d.ts.map +1 -0
- package/dist/cli-json-command.js +96 -0
- package/dist/cli-protocol.d.ts +12 -0
- package/dist/cli-protocol.d.ts.map +1 -0
- package/dist/cli-protocol.js +37 -0
- package/dist/cli-register-foundation.d.ts +3 -0
- package/dist/cli-register-foundation.d.ts.map +1 -0
- package/dist/cli-register-foundation.js +90 -0
- package/dist/cli-register-maintenance.d.ts +3 -0
- package/dist/cli-register-maintenance.d.ts.map +1 -0
- package/dist/cli-register-maintenance.js +36 -0
- package/dist/cli-register-reporting.d.ts +3 -0
- package/dist/cli-register-reporting.d.ts.map +1 -0
- package/dist/cli-register-reporting.js +101 -0
- package/dist/cli-register-skills.d.ts +3 -0
- package/dist/cli-register-skills.d.ts.map +1 -0
- package/dist/cli-register-skills.js +71 -0
- package/dist/cli-validate.d.ts +18 -0
- package/dist/cli-validate.d.ts.map +1 -0
- package/dist/cli-validate.js +45 -0
- package/dist/cli.d.ts +4 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +48 -211
- package/dist/commands/aggregated-checks.d.ts +1 -1
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +28 -34
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +53 -95
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +12 -17
- package/dist/commands/discovery-shared.d.ts +2 -1
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +6 -18
- package/dist/commands/gaps.d.ts.map +1 -1
- package/dist/commands/gaps.js +15 -19
- package/dist/commands/graph.d.ts.map +1 -1
- package/dist/commands/graph.js +15 -21
- package/dist/commands/query.d.ts +7 -7
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +98 -204
- package/dist/commands/search.d.ts +4 -4
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +14 -27
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +6 -7
- package/dist/commands/sync/manifest.d.ts +13 -2
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +31 -22
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +39 -1
- package/dist/extractors/markdown.d.ts +22 -2
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +50 -1
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +11 -1
- package/dist/logic/ir.d.ts +112 -0
- package/dist/logic/ir.d.ts.map +1 -0
- package/dist/logic/ir.js +729 -0
- package/dist/operations/autopilot/activation.d.ts +4 -0
- package/dist/operations/autopilot/activation.d.ts.map +1 -0
- package/dist/operations/autopilot/activation.js +130 -0
- package/dist/operations/autopilot/candidate-helpers.d.ts +13 -0
- package/dist/operations/autopilot/candidate-helpers.d.ts.map +1 -0
- package/dist/operations/autopilot/candidate-helpers.js +55 -0
- package/dist/operations/autopilot/candidates.d.ts +4 -0
- package/dist/operations/autopilot/candidates.d.ts.map +1 -0
- package/dist/operations/autopilot/candidates.js +114 -0
- package/dist/operations/autopilot/discovery-evidence.d.ts +10 -0
- package/dist/operations/autopilot/discovery-evidence.d.ts.map +1 -0
- package/dist/operations/autopilot/discovery-evidence.js +158 -0
- package/dist/operations/autopilot/discovery.d.ts +4 -0
- package/dist/operations/autopilot/discovery.d.ts.map +1 -0
- package/dist/operations/autopilot/discovery.js +100 -0
- package/dist/operations/autopilot/generate.d.ts +8 -0
- package/dist/operations/autopilot/generate.d.ts.map +1 -0
- package/dist/operations/autopilot/generate.js +112 -0
- package/dist/operations/autopilot/guidance-actions.d.ts +3 -0
- package/dist/operations/autopilot/guidance-actions.d.ts.map +1 -0
- package/dist/operations/autopilot/guidance-actions.js +79 -0
- package/dist/operations/autopilot/guidance.d.ts +14 -0
- package/dist/operations/autopilot/guidance.d.ts.map +1 -0
- package/dist/operations/autopilot/guidance.js +124 -0
- package/dist/operations/autopilot/markdown-candidates.d.ts +7 -0
- package/dist/operations/autopilot/markdown-candidates.d.ts.map +1 -0
- package/dist/operations/autopilot/markdown-candidates.js +134 -0
- package/dist/operations/autopilot/presentation.d.ts +13 -0
- package/dist/operations/autopilot/presentation.d.ts.map +1 -0
- package/dist/operations/autopilot/presentation.js +91 -0
- package/dist/operations/autopilot/requirement-claims.d.ts +3 -0
- package/dist/operations/autopilot/requirement-claims.d.ts.map +1 -0
- package/dist/operations/autopilot/requirement-claims.js +48 -0
- package/dist/operations/autopilot/types.d.ts +117 -0
- package/dist/operations/autopilot/types.d.ts.map +1 -0
- package/dist/operations/autopilot/types.js +8 -0
- package/dist/operations/modeling/logic-modeling.d.ts +22 -0
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -0
- package/dist/operations/modeling/logic-modeling.js +111 -0
- package/dist/operations/modeling/model-requirement.d.ts +10 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -0
- package/dist/operations/modeling/model-requirement.js +164 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts +6 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-applyplan.js +117 -0
- package/dist/operations/modeling/predicate-catalog-1.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-1.js +200 -0
- package/dist/operations/modeling/predicate-catalog-2.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-2.js +197 -0
- package/dist/operations/modeling/predicate-catalog-3.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-3.js +193 -0
- package/dist/operations/modeling/predicate-catalog-4.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-4.js +149 -0
- package/dist/operations/modeling/predicate-catalog.d.ts +5 -0
- package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog.js +29 -0
- package/dist/operations/modeling/predicate-inference-1.d.ts +16 -0
- package/dist/operations/modeling/predicate-inference-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference-1.js +161 -0
- package/dist/operations/modeling/predicate-inference-2.d.ts +19 -0
- package/dist/operations/modeling/predicate-inference-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference-2.js +169 -0
- package/dist/operations/modeling/predicate-inference-3.d.ts +15 -0
- package/dist/operations/modeling/predicate-inference-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference-3.js +163 -0
- package/dist/operations/modeling/predicate-inference.d.ts +5 -0
- package/dist/operations/modeling/predicate-inference.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference.js +163 -0
- package/dist/operations/modeling/predicate-loader.d.ts +10 -0
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-loader.js +94 -0
- package/dist/operations/modeling/predicate-ranker.d.ts +3 -0
- package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-ranker.js +62 -0
- package/dist/operations/modeling/predicate-score-1.d.ts +3 -0
- package/dist/operations/modeling/predicate-score-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-score-1.js +121 -0
- package/dist/operations/modeling/predicate-score-2.d.ts +3 -0
- package/dist/operations/modeling/predicate-score-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-score-2.js +122 -0
- package/dist/operations/modeling/predicate-score-3.d.ts +3 -0
- package/dist/operations/modeling/predicate-score-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-score-3.js +54 -0
- package/dist/operations/modeling/predicate-types.d.ts +64 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-types.js +1 -0
- package/dist/operations/modeling/predicate-usage-hints-1.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-1.js +211 -0
- package/dist/operations/modeling/predicate-usage-hints-2.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-2.js +209 -0
- package/dist/operations/modeling/predicate-usage-hints-3.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-3.js +45 -0
- package/dist/operations/modeling/predicate-utils.d.ts +23 -0
- package/dist/operations/modeling/predicate-utils.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-utils.js +187 -0
- package/dist/operations/modeling/requirement-applyplan.d.ts +4 -0
- package/dist/operations/modeling/requirement-applyplan.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-applyplan.js +44 -0
- package/dist/operations/modeling/requirement-heuristics.d.ts +4 -0
- package/dist/operations/modeling/requirement-heuristics.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-heuristics.js +114 -0
- package/dist/operations/modeling/requirement-modeler.d.ts +8 -0
- package/dist/operations/modeling/requirement-modeler.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-modeler.js +70 -0
- package/dist/operations/modeling/requirement-types.d.ts +61 -0
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-types.js +1 -0
- package/dist/operations/modeling/requirement-utils.d.ts +10 -0
- package/dist/operations/modeling/requirement-utils.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-utils.js +65 -0
- package/dist/operations/modeling/suggest-predicates.d.ts +6 -0
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -0
- package/dist/operations/modeling/suggest-predicates.js +64 -0
- package/dist/operations/mutation/audit.d.ts +6 -0
- package/dist/operations/mutation/audit.d.ts.map +1 -0
- package/dist/operations/mutation/audit.js +22 -0
- package/dist/operations/mutation/contradictions.d.ts +10 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -0
- package/dist/operations/mutation/contradictions.js +40 -0
- package/dist/operations/mutation/delete.d.ts +5 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -0
- package/dist/operations/mutation/delete.js +67 -0
- package/dist/operations/mutation/relationships.d.ts +17 -0
- package/dist/operations/mutation/relationships.d.ts.map +1 -0
- package/dist/operations/mutation/relationships.js +142 -0
- package/dist/operations/mutation/save.d.ts +4 -0
- package/dist/operations/mutation/save.d.ts.map +1 -0
- package/dist/operations/mutation/save.js +14 -0
- package/dist/operations/mutation/serialization.d.ts +5 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -0
- package/dist/operations/mutation/serialization.js +88 -0
- package/dist/operations/mutation/strict-fact.d.ts +4 -0
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -0
- package/dist/operations/mutation/strict-fact.js +132 -0
- package/dist/operations/mutation/symbol-granularity.d.ts +4 -0
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -0
- package/dist/operations/mutation/symbol-granularity.js +109 -0
- package/dist/operations/mutation/symbol-refresh.d.ts +10 -0
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -0
- package/dist/operations/mutation/symbol-refresh.js +105 -0
- package/dist/operations/mutation/types.d.ts +43 -0
- package/dist/operations/mutation/types.d.ts.map +1 -0
- package/dist/operations/mutation/types.js +1 -0
- package/dist/operations/mutation/upsert.d.ts +5 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -0
- package/dist/operations/mutation/upsert.js +103 -0
- package/dist/operations/mutation/validate-upsert.d.ts +5 -0
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -0
- package/dist/operations/mutation/validate-upsert.js +50 -0
- package/dist/operations/mutation/validation.d.ts +5 -0
- package/dist/operations/mutation/validation.d.ts.map +1 -0
- package/dist/operations/mutation/validation.js +107 -0
- package/dist/operations/mutation/warnings.d.ts +4 -0
- package/dist/operations/mutation/warnings.d.ts.map +1 -0
- package/dist/operations/mutation/warnings.js +17 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts +5 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/analysis-receipt.js +120 -0
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +5 -0
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/analyze-prose.js +693 -0
- package/dist/operations/semantic-advisor/clauses.d.ts +10 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/clauses.js +43 -0
- package/dist/operations/semantic-advisor/observation-plan.d.ts +3 -0
- package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/observation-plan.js +31 -0
- package/dist/operations/semantic-advisor/predicate-rule.d.ts +14 -0
- package/dist/operations/semantic-advisor/predicate-rule.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rule.js +22 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +79 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.js +140 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +83 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.js +150 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +48 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +102 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +71 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.js +133 -0
- package/dist/operations/semantic-advisor/prose-coverage-evaluator.d.ts +29 -0
- package/dist/operations/semantic-advisor/prose-coverage-evaluator.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/prose-coverage-evaluator.js +54 -0
- package/dist/operations/semantic-advisor/shared.d.ts +19 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/shared.js +209 -0
- package/dist/operations/semantic-advisor/strict-count-rules.d.ts +4 -0
- package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/strict-count-rules.js +62 -0
- package/dist/operations/semantic-advisor/strict-rules.d.ts +4 -0
- package/dist/operations/semantic-advisor/strict-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/strict-rules.js +106 -0
- package/dist/operations/semantic-advisor/types.d.ts +195 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/types.js +1 -0
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +20 -3
- package/dist/prolog.d.ts +5 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +89 -32
- package/dist/public/impact/diagnostics.d.ts.map +1 -1
- package/dist/public/impact/diagnostics.js +8 -4
- package/dist/public/impact/full-kb-quality.d.ts +1 -1
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +34 -1
- package/dist/public/impact/requirement-quality.d.ts.map +1 -1
- package/dist/public/impact/requirement-quality.js +6 -23
- package/dist/public/operations/catalog.d.ts +986 -0
- package/dist/public/operations/catalog.d.ts.map +1 -0
- package/dist/public/operations/catalog.js +42 -0
- package/dist/public/operations/check-executor.d.ts +21 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -0
- package/dist/public/operations/check-executor.js +111 -0
- package/dist/public/operations/check-format-shared.d.ts +36 -0
- package/dist/public/operations/check-format-shared.d.ts.map +1 -0
- package/dist/public/operations/check-format-shared.js +107 -0
- package/dist/public/operations/check-helpers.d.ts +10 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -0
- package/dist/public/operations/check-helpers.js +107 -0
- package/dist/public/operations/discovery-entities.d.ts +14 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -0
- package/dist/public/operations/discovery-entities.js +91 -0
- package/dist/public/operations/discovery-executors.d.ts +39 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -0
- package/dist/public/operations/discovery-executors.js +101 -0
- package/dist/public/operations/index.d.ts +21 -0
- package/dist/public/operations/index.d.ts.map +1 -0
- package/dist/public/operations/index.js +19 -0
- package/dist/public/operations/node-ports.d.ts +15 -0
- package/dist/public/operations/node-ports.d.ts.map +1 -0
- package/dist/public/operations/node-ports.js +57 -0
- package/dist/public/operations/prolog-json.d.ts +5 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -0
- package/dist/public/operations/prolog-json.js +44 -0
- package/dist/public/operations/runtime-types.d.ts +69 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -0
- package/dist/public/operations/runtime-types.js +17 -0
- package/dist/public/operations/specs/autopilot.d.ts +82 -0
- package/dist/public/operations/specs/autopilot.d.ts.map +1 -0
- package/dist/public/operations/specs/autopilot.js +72 -0
- package/dist/public/operations/specs/check.d.ts +51 -0
- package/dist/public/operations/specs/check.d.ts.map +1 -0
- package/dist/public/operations/specs/check.js +65 -0
- package/dist/public/operations/specs/discovery.d.ts +94 -0
- package/dist/public/operations/specs/discovery.d.ts.map +1 -0
- package/dist/public/operations/specs/discovery.js +98 -0
- package/dist/public/operations/specs/modeling.d.ts +142 -0
- package/dist/public/operations/specs/modeling.d.ts.map +1 -0
- package/dist/public/operations/specs/modeling.js +133 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts +268 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -0
- package/dist/public/operations/specs/mutation-schemas.js +294 -0
- package/dist/public/operations/specs/mutation.d.ts +56 -0
- package/dist/public/operations/specs/mutation.d.ts.map +1 -0
- package/dist/public/operations/specs/mutation.js +44 -0
- package/dist/public/operations/specs/reporting.d.ts +185 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -0
- package/dist/public/operations/specs/reporting.js +158 -0
- package/dist/public/operations/specs/semantic.d.ts +81 -0
- package/dist/public/operations/specs/semantic.d.ts.map +1 -0
- package/dist/public/operations/specs/semantic.js +137 -0
- package/dist/public/operations/specs/skills.d.ts +70 -0
- package/dist/public/operations/specs/skills.d.ts.map +1 -0
- package/dist/public/operations/specs/skills.js +107 -0
- package/dist/public/operations/specs/sparql.d.ts +39 -0
- package/dist/public/operations/specs/sparql.d.ts.map +1 -0
- package/dist/public/operations/specs/sparql.js +121 -0
- package/dist/public/operations/specs/upsert.d.ts +291 -0
- package/dist/public/operations/specs/upsert.d.ts.map +1 -0
- package/dist/public/operations/specs/upsert.js +27 -0
- package/dist/public/operations/types.d.ts +24 -0
- package/dist/public/operations/types.d.ts.map +1 -0
- package/dist/public/operations/types.js +1 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +317 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skill-system/errors.d.ts +19 -0
- package/dist/public/skill-system/errors.d.ts.map +1 -0
- package/dist/public/skill-system/errors.js +36 -0
- package/dist/public/skill-system/loader.d.ts +9 -0
- package/dist/public/skill-system/loader.d.ts.map +1 -0
- package/dist/public/skill-system/loader.js +76 -0
- package/dist/public/skill-system/paths.d.ts +6 -0
- package/dist/public/skill-system/paths.d.ts.map +1 -0
- package/dist/public/skill-system/paths.js +25 -0
- package/dist/public/skill-system/types.d.ts +15 -0
- package/dist/public/skill-system/types.d.ts.map +1 -0
- package/dist/public/skill-system/types.js +1 -0
- package/dist/public/skill-system/validation.d.ts +10 -0
- package/dist/public/skill-system/validation.d.ts.map +1 -0
- package/dist/public/skill-system/validation.js +119 -0
- package/dist/public/skills/init-kibi/SKILL.md +62 -0
- package/dist/public/skills/kibi-freshness/SKILL.md +44 -0
- package/dist/public/skills/kibi-traceability/SKILL.md +54 -0
- package/dist/public/skills/kibi-usage/SKILL.md +145 -99
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +112 -0
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/dist/public/skills/kibi-usage/resources/operation-access.md +44 -0
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +41 -3
- package/dist/public/skills.d.ts +4 -41
- package/dist/public/skills.d.ts.map +1 -1
- package/dist/public/skills.js +3 -270
- package/dist/public/symbol-granularity.d.ts +9 -0
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.js +16 -0
- package/dist/runtime/cli-runtime.d.ts +3 -0
- package/dist/runtime/cli-runtime.d.ts.map +1 -0
- package/dist/runtime/cli-runtime.js +96 -0
- package/dist/schemas/entity.schema.json +329 -3
- package/dist/traceability/staged-diagnostics.d.ts +2 -2
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-diagnostics.js +17 -10
- package/dist/traceability/staged-impact-contract.js +1 -1
- package/dist/traceability/staged-symbols-manifest.d.ts +1 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +53 -24
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +17 -1
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +47 -1
- package/dist/types/entities.d.ts +3 -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/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.js +24 -0
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.js +1 -1
- package/package.json +60 -2
- package/src/public/impact/diagnostics.ts +18 -11
- package/src/public/impact/full-kb-quality.ts +30 -3
- package/src/public/impact/requirement-quality.ts +6 -26
- package/src/public/operations/catalog.ts +60 -0
- package/src/public/operations/check-executor.ts +185 -0
- package/src/public/operations/check-format-shared.ts +178 -0
- package/src/public/operations/check-helpers.ts +141 -0
- package/src/public/operations/discovery-entities.ts +122 -0
- package/src/public/operations/discovery-executors.ts +176 -0
- package/src/public/operations/index.ts +20 -0
- package/src/public/operations/node-ports.ts +78 -0
- package/src/public/operations/prolog-json.ts +71 -0
- package/src/public/operations/runtime-types.ts +106 -0
- package/src/public/operations/specs/autopilot.ts +98 -0
- package/src/public/operations/specs/check.ts +75 -0
- package/src/public/operations/specs/discovery.ts +126 -0
- package/src/public/operations/specs/modeling.ts +174 -0
- package/src/public/operations/specs/mutation-schemas.ts +326 -0
- package/src/public/operations/specs/mutation.ts +58 -0
- package/src/public/operations/specs/reporting.ts +249 -0
- package/src/public/operations/specs/semantic.ts +174 -0
- package/src/public/operations/specs/skills.ts +142 -0
- package/src/public/operations/specs/sparql.ts +149 -0
- package/src/public/operations/specs/upsert.ts +40 -0
- package/src/public/operations/types.ts +57 -0
- package/src/public/schemas/entity.ts +324 -1
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skill-system/errors.ts +38 -0
- package/src/public/skill-system/loader.ts +108 -0
- package/src/public/skill-system/paths.ts +27 -0
- package/src/public/skill-system/types.ts +14 -0
- package/src/public/skill-system/validation.ts +175 -0
- package/src/public/skills/init-kibi/SKILL.md +62 -0
- package/src/public/skills/kibi-freshness/SKILL.md +44 -0
- package/src/public/skills/kibi-traceability/SKILL.md +54 -0
- package/src/public/skills/kibi-usage/SKILL.md +145 -99
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +112 -0
- package/src/public/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/src/public/skills/kibi-usage/resources/operation-access.md +44 -0
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +41 -3
- package/src/public/skills.ts +18 -427
- package/src/public/symbol-granularity.ts +25 -0
- package/src/schemas/entity.schema.json +329 -3
- package/src/schemas/relationship.schema.json +1 -0
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
import { utf8Span, validateLogicIr, } from "../../logic/ir.js";
|
|
2
|
+
import { logicRuleFactId } from "../modeling/logic-modeling.js";
|
|
3
|
+
import { buildAdvisorResult } from "./analysis-receipt.js";
|
|
4
|
+
import { extractSemanticClauses, semanticClaimKey, } from "./clauses.js";
|
|
5
|
+
import { observationPlan } from "./observation-plan.js";
|
|
6
|
+
import { detectPredicateRules } from "./predicate-rule.js";
|
|
7
|
+
import { CORE_PREDICATE_RULES } from "./predicate-rules-core.js";
|
|
8
|
+
import { POLICY_PREDICATE_RULES } from "./predicate-rules-policy.js";
|
|
9
|
+
import { PRODUCT_TAIL_PREDICATE_RULES } from "./predicate-rules-product-tail.js";
|
|
10
|
+
import { PRODUCT_PREDICATE_RULES } from "./predicate-rules-product.js";
|
|
11
|
+
import { isRecord, payloadHash, propertiesOf, relationship, sourceOf, statementOf, stringValue, } from "./shared.js";
|
|
12
|
+
import { detectStrictSuggestion } from "./strict-rules.js";
|
|
13
|
+
export const SEMANTIC_ADVISOR_VERSION = "semantic-advisor-v2";
|
|
14
|
+
export { semanticClaimKey } from "./clauses.js";
|
|
15
|
+
const SIGNAL_PATTERNS = [
|
|
16
|
+
{
|
|
17
|
+
kind: "numeric_cardinality",
|
|
18
|
+
candidateLane: "strict_property",
|
|
19
|
+
confidence: 0.92,
|
|
20
|
+
pattern: /\b(?:(?:at\s+most|at\s+least|exactly|no\s+more\s+than|up\s+to|cap(?:ped)?\s+at)\s+)?(?:\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten)\b/i,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
kind: "numeric_threshold",
|
|
24
|
+
candidateLane: "strict_property",
|
|
25
|
+
confidence: 0.86,
|
|
26
|
+
pattern: /\b(?:maximum|minimum|under|within|below|above|expires?|retained\s+for)\s+(?:\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten)\b/i,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
kind: "conditional",
|
|
30
|
+
candidateLane: "predicate",
|
|
31
|
+
confidence: 0.82,
|
|
32
|
+
pattern: /\b(?:if|when|unless|except|only\s+if|provided\s+that)\b/i,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
kind: "permission",
|
|
36
|
+
candidateLane: "predicate",
|
|
37
|
+
confidence: 0.8,
|
|
38
|
+
pattern: /\b(?:only|may|can|allowed|denied|forbidden|must\s+not|cannot|can't)\b/i,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
kind: "state_or_default",
|
|
42
|
+
candidateLane: "predicate",
|
|
43
|
+
confidence: 0.74,
|
|
44
|
+
pattern: /\b(?:state|mode|defaults?\s+to|ready|disabled|enabled|terminal)\b/i,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
kind: "normative_modal",
|
|
48
|
+
candidateLane: "observation_review",
|
|
49
|
+
confidence: 0.65,
|
|
50
|
+
pattern: /\b(?:must|shall|should|may|must\s+not|cannot|can't)\b/i,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
function proseOf(payload) {
|
|
54
|
+
const properties = propertiesOf(payload);
|
|
55
|
+
return [properties.title, properties.text_ref, properties.description]
|
|
56
|
+
.map(stringValue)
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join("\n");
|
|
59
|
+
}
|
|
60
|
+
function isRequirement(payload) {
|
|
61
|
+
return stringValue(payload.type) === "req";
|
|
62
|
+
}
|
|
63
|
+
// implements REQ-kibi-logical-requirement-coverage
|
|
64
|
+
// implements REQ-skillopt-logical-evidence-fidelity
|
|
65
|
+
function logicalGroundingSlots(payload) {
|
|
66
|
+
const relationships = Array.isArray(payload.relationships)
|
|
67
|
+
? payload.relationships
|
|
68
|
+
: [];
|
|
69
|
+
return relationships.filter((relationship) => isRecord(relationship) &&
|
|
70
|
+
["requires_property", "requires_predicate", "requires_rule"].includes(stringValue(relationship.type))).length;
|
|
71
|
+
}
|
|
72
|
+
function isModeled(payload, expectedClaimCount) {
|
|
73
|
+
if (expectedClaimCount === 0)
|
|
74
|
+
return false;
|
|
75
|
+
const relationships = Array.isArray(payload.relationships)
|
|
76
|
+
? payload.relationships
|
|
77
|
+
: [];
|
|
78
|
+
const types = new Set(relationships
|
|
79
|
+
.filter(isRecord)
|
|
80
|
+
.map((relationship) => stringValue(relationship.type))
|
|
81
|
+
.filter(Boolean));
|
|
82
|
+
return (logicalGroundingSlots(payload) >= expectedClaimCount &&
|
|
83
|
+
((types.has("constrains") && types.has("requires_property")) ||
|
|
84
|
+
types.has("requires_predicate") ||
|
|
85
|
+
types.has("requires_rule")));
|
|
86
|
+
}
|
|
87
|
+
function detectSignals(prose) {
|
|
88
|
+
const seen = new Set();
|
|
89
|
+
return SIGNAL_PATTERNS.flatMap((candidate) => {
|
|
90
|
+
const evidence = prose.match(candidate.pattern)?.[0];
|
|
91
|
+
if (!evidence || seen.has(candidate.kind))
|
|
92
|
+
return [];
|
|
93
|
+
seen.add(candidate.kind);
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
kind: candidate.kind,
|
|
97
|
+
evidence,
|
|
98
|
+
candidate_lane: candidate.candidateLane,
|
|
99
|
+
confidence: candidate.confidence,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function ambiguitySuggestion(payload, statement) {
|
|
105
|
+
const match = statement.match(/\b(?<value>\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten)\s+(?<resource>active\s+sessions?|sessions?)\b/i);
|
|
106
|
+
if (!match?.groups?.value ||
|
|
107
|
+
!match.groups.resource ||
|
|
108
|
+
/at\s+most|at\s+least|exactly|no\s+more\s+than|up\s+to/i.test(statement))
|
|
109
|
+
return null;
|
|
110
|
+
return {
|
|
111
|
+
kind: "ambiguity_observation",
|
|
112
|
+
claim_key: "",
|
|
113
|
+
claim_text: statement,
|
|
114
|
+
confidence: 0.78,
|
|
115
|
+
evidence: `${match.groups.value} ${match.groups.resource}`,
|
|
116
|
+
rationale: "Cardinality without an explicit operator is ambiguous and should be clarified before strict modeling.",
|
|
117
|
+
ambiguity: ["exactly", "at_most", "at_least", "illustrative_example"],
|
|
118
|
+
suggested_next_tool: "kb_model_requirement",
|
|
119
|
+
applyPlan: observationPlan(payload, "Ambiguous cardinality requirement", [
|
|
120
|
+
"semantic-advisor-suggestion",
|
|
121
|
+
"review:ambiguity",
|
|
122
|
+
]),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function ontologyGapSuggestion(payload, statement) {
|
|
126
|
+
const match = statement.match(/\brate\s+limited\s+to\s+(?<count>\d+)\s+(?<action>[a-z][a-z\s_-]*?)\s+per\s+(?<window>[a-z]+)\b/i);
|
|
127
|
+
if (!match?.groups)
|
|
128
|
+
return null;
|
|
129
|
+
return {
|
|
130
|
+
kind: "ontology_gap",
|
|
131
|
+
claim_key: "",
|
|
132
|
+
claim_text: statement,
|
|
133
|
+
confidence: 0.82,
|
|
134
|
+
evidence: match[0],
|
|
135
|
+
rationale: "Rate limiting is logical and machine-checkable, but the current built-in predicate set needs a dedicated schema before grounding it safely.",
|
|
136
|
+
suggested_next_tool: "kb_suggest_predicates",
|
|
137
|
+
recommendedPredicateSchema: {
|
|
138
|
+
predicate_name: "rate_limit",
|
|
139
|
+
argument_names: ["subject", "action", "window", "count"],
|
|
140
|
+
argument_types: ["entity", "action", "duration", "number"],
|
|
141
|
+
},
|
|
142
|
+
applyPlan: observationPlan(payload, "Ontology gap: rate_limit", [
|
|
143
|
+
"semantic-advisor-suggestion",
|
|
144
|
+
"review:ontology-gap",
|
|
145
|
+
"needs_schema_extension",
|
|
146
|
+
]),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function predicateSuggestion(payload, statement) {
|
|
150
|
+
return (detectPredicateRules(payload, statement, CORE_PREDICATE_RULES) ??
|
|
151
|
+
detectPredicateRules(payload, statement, POLICY_PREDICATE_RULES) ??
|
|
152
|
+
detectPredicateRules(payload, statement, PRODUCT_PREDICATE_RULES) ??
|
|
153
|
+
detectPredicateRules(payload, statement, PRODUCT_TAIL_PREDICATE_RULES));
|
|
154
|
+
}
|
|
155
|
+
function ruleSuggestion(payload, candidate) {
|
|
156
|
+
const validation = validateLogicIr(candidate.ir);
|
|
157
|
+
if (!validation.valid ||
|
|
158
|
+
!validation.normalized ||
|
|
159
|
+
!validation.semanticKey ||
|
|
160
|
+
!validation.renderedProlog)
|
|
161
|
+
return null;
|
|
162
|
+
const reqId = stringValue(payload.id);
|
|
163
|
+
const semanticKey = validation.semanticKey;
|
|
164
|
+
const schemaId = candidate.ir.ruleSchemaId ?? "FACT-RULE-SCHEMA-LOGIC-V1";
|
|
165
|
+
const factId = logicRuleFactId(semanticKey);
|
|
166
|
+
const schemaPlan = candidate.ir.ruleSchemaId
|
|
167
|
+
? []
|
|
168
|
+
: [
|
|
169
|
+
{
|
|
170
|
+
type: "fact",
|
|
171
|
+
id: schemaId,
|
|
172
|
+
properties: {
|
|
173
|
+
title: "kibi.logic.v1 rule schema",
|
|
174
|
+
status: "active",
|
|
175
|
+
source: sourceOf(payload),
|
|
176
|
+
fact_kind: "rule_schema",
|
|
177
|
+
rule_name: "kibi.logic.v1",
|
|
178
|
+
argument_names: ["rule_ir"],
|
|
179
|
+
argument_types: ["logic_ir"],
|
|
180
|
+
aliases: ["conditional rule", "constraint", "policy rule"],
|
|
181
|
+
examples: [validation.renderedProlog],
|
|
182
|
+
},
|
|
183
|
+
relationships: [],
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
return {
|
|
187
|
+
kind: "rule",
|
|
188
|
+
claim_key: candidate.claim_key,
|
|
189
|
+
claim_text: candidate.claim_text,
|
|
190
|
+
confidence: candidate.confidence ?? 0.75,
|
|
191
|
+
evidence: candidate.claim_text,
|
|
192
|
+
rationale: "The host supplied a typed kibi.logic.v1 interpretation. Kibi validated its safety, canonicalized it, and will persist it as data-backed rule evidence.",
|
|
193
|
+
suggested_next_tool: "kb_model_requirement",
|
|
194
|
+
rule: validation.normalized,
|
|
195
|
+
semantic_key: semanticKey,
|
|
196
|
+
rendered_prolog: validation.renderedProlog,
|
|
197
|
+
rejected_alternatives: ["raw_prolog", "observation_review"],
|
|
198
|
+
applyPlan: [
|
|
199
|
+
...schemaPlan,
|
|
200
|
+
{
|
|
201
|
+
type: "fact",
|
|
202
|
+
id: factId,
|
|
203
|
+
properties: {
|
|
204
|
+
title: `${candidate.ir.kind} rule ${semanticKey}`,
|
|
205
|
+
status: "active",
|
|
206
|
+
source: sourceOf(payload),
|
|
207
|
+
fact_kind: "rule",
|
|
208
|
+
rule_ir: validation.normalized,
|
|
209
|
+
rule_hash: validation.ruleHash,
|
|
210
|
+
semantic_key: semanticKey,
|
|
211
|
+
rule_schema_id: schemaId,
|
|
212
|
+
rule_name: validation.normalized.ruleSchemaId ?? "kibi.logic.v1",
|
|
213
|
+
canonical_key: semanticKey,
|
|
214
|
+
tags: ["lane:logic", "semantic-advisor-suggestion"],
|
|
215
|
+
},
|
|
216
|
+
relationships: [],
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
relationshipPlan: reqId
|
|
220
|
+
? {
|
|
221
|
+
applyAfter: factId,
|
|
222
|
+
requiresExistingReq: reqId,
|
|
223
|
+
relationship: relationship(reqId, factId, "requires_rule"),
|
|
224
|
+
}
|
|
225
|
+
: null,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function modelingSuggestions(payload, modeled, clauses, interpretations) {
|
|
229
|
+
if (!isRequirement(payload) || modeled)
|
|
230
|
+
return [];
|
|
231
|
+
const suggestions = [];
|
|
232
|
+
const seen = new Set();
|
|
233
|
+
const expectedClaimKeys = clauses
|
|
234
|
+
.filter((clause) => clause.normative)
|
|
235
|
+
.map((clause) => clause.claim_key);
|
|
236
|
+
const rawDeclaredClaimKeys = propertiesOf(payload).logic_claims;
|
|
237
|
+
const declaredClaimKeys = Array.isArray(rawDeclaredClaimKeys)
|
|
238
|
+
? rawDeclaredClaimKeys.filter((value) => typeof value === "string")
|
|
239
|
+
: [];
|
|
240
|
+
const mergedClaimKeys = Array.from(new Set([...declaredClaimKeys, ...expectedClaimKeys]));
|
|
241
|
+
for (const clause of clauses) {
|
|
242
|
+
const candidate = clause.text;
|
|
243
|
+
const rawSuggestion = predicateSuggestion(payload, candidate) ??
|
|
244
|
+
ontologyGapSuggestion(payload, candidate) ??
|
|
245
|
+
ambiguitySuggestion(payload, candidate) ??
|
|
246
|
+
detectStrictSuggestion(payload, candidate);
|
|
247
|
+
const suggestion = rawSuggestion
|
|
248
|
+
? withClauseProvenance(rawSuggestion, clause, mergedClaimKeys, statementOf(payload))
|
|
249
|
+
: clause.normative
|
|
250
|
+
? unmatchedClauseSuggestion(payload, clause, mergedClaimKeys)
|
|
251
|
+
: null;
|
|
252
|
+
if (!suggestion)
|
|
253
|
+
continue;
|
|
254
|
+
const key = `${suggestion.claim_key}:${suggestion.kind}:${suggestion.evidence}:${suggestion.suggested_next_tool}`;
|
|
255
|
+
if (!seen.has(key)) {
|
|
256
|
+
seen.add(key);
|
|
257
|
+
suggestions.push(suggestion);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (const interpretation of interpretations ?? []) {
|
|
261
|
+
const clause = clauses.find((entry) => entry.claim_key === interpretation.claim_key);
|
|
262
|
+
if (!clause)
|
|
263
|
+
continue;
|
|
264
|
+
const suggestion = ruleSuggestion(payload, interpretation);
|
|
265
|
+
if (!suggestion)
|
|
266
|
+
continue;
|
|
267
|
+
const withProvenance = withClauseProvenance(suggestion, clause, mergedClaimKeys, statementOf(payload));
|
|
268
|
+
const key = withProvenance.kind === "rule"
|
|
269
|
+
? `${withProvenance.claim_key}:rule:${withProvenance.semantic_key}`
|
|
270
|
+
: `${withProvenance.claim_key}:${withProvenance.kind}`;
|
|
271
|
+
if (!seen.has(key)) {
|
|
272
|
+
seen.add(key);
|
|
273
|
+
suggestions.push(withProvenance);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return suggestions;
|
|
277
|
+
}
|
|
278
|
+
function withClauseProvenance(suggestion, clause, expectedClaimKeys, statement) {
|
|
279
|
+
const clauseOffset = statement.indexOf(clause.text);
|
|
280
|
+
const clauseSpan = utf8Span(statement || clause.text, clauseOffset >= 0 ? clauseOffset : 0, clauseOffset >= 0 ? clauseOffset + clause.text.length : clause.text.length);
|
|
281
|
+
const applyPlan = suggestion.applyPlan.map((step) => {
|
|
282
|
+
if (!isRecord(step))
|
|
283
|
+
return step;
|
|
284
|
+
const properties = isRecord(step.properties) ? step.properties : null;
|
|
285
|
+
if (properties === null)
|
|
286
|
+
return step;
|
|
287
|
+
if (step.type === "req") {
|
|
288
|
+
const existing = Array.isArray(properties.logic_claims)
|
|
289
|
+
? properties.logic_claims.filter((value) => typeof value === "string")
|
|
290
|
+
: [];
|
|
291
|
+
const inventory = Array.isArray(properties.semantic_inventory)
|
|
292
|
+
? properties.semantic_inventory.filter(isRecord)
|
|
293
|
+
: [];
|
|
294
|
+
const status = suggestion.kind === "ambiguity_observation"
|
|
295
|
+
? "ambiguous"
|
|
296
|
+
: suggestion.kind === "ontology_gap"
|
|
297
|
+
? "ontology_gap"
|
|
298
|
+
: "modeled";
|
|
299
|
+
return {
|
|
300
|
+
...step,
|
|
301
|
+
properties: {
|
|
302
|
+
...properties,
|
|
303
|
+
logic_claims: Array.from(new Set([...existing, ...expectedClaimKeys])),
|
|
304
|
+
semantic_inventory: [
|
|
305
|
+
...inventory.filter((entry) => entry.claim_key !== clause.claim_key),
|
|
306
|
+
{
|
|
307
|
+
claim_key: clause.claim_key,
|
|
308
|
+
claim_text: clause.text,
|
|
309
|
+
role: clause.normative ? "normative" : "descriptive",
|
|
310
|
+
status,
|
|
311
|
+
span: clauseSpan,
|
|
312
|
+
reason: status === "modeled"
|
|
313
|
+
? "Draft apply plan contains a typed grounding for this proposition."
|
|
314
|
+
: suggestion.rationale,
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
if (step.type !== "fact")
|
|
321
|
+
return step;
|
|
322
|
+
return {
|
|
323
|
+
...step,
|
|
324
|
+
properties: {
|
|
325
|
+
...properties,
|
|
326
|
+
claim_key: clause.claim_key,
|
|
327
|
+
claim_text: clause.text,
|
|
328
|
+
claim_span_start: clauseSpan.start,
|
|
329
|
+
claim_span_end: clauseSpan.end,
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
return {
|
|
334
|
+
...suggestion,
|
|
335
|
+
claim_key: clause.claim_key,
|
|
336
|
+
claim_text: clause.text,
|
|
337
|
+
applyPlan,
|
|
338
|
+
...(suggestion.kind === "predicate" && suggestion.relationshipPlan !== null
|
|
339
|
+
? {
|
|
340
|
+
relationshipPlan: {
|
|
341
|
+
...suggestion.relationshipPlan,
|
|
342
|
+
claimKey: clause.claim_key,
|
|
343
|
+
claimText: clause.text,
|
|
344
|
+
logicClaims: expectedClaimKeys,
|
|
345
|
+
semanticInventory: [
|
|
346
|
+
{
|
|
347
|
+
claim_key: clause.claim_key,
|
|
348
|
+
claim_text: clause.text,
|
|
349
|
+
role: clause.normative ? "normative" : "descriptive",
|
|
350
|
+
status: "modeled",
|
|
351
|
+
span: clauseSpan,
|
|
352
|
+
reason: "The returned typed fact grounds this proposition.",
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
instructions: "Create the predicate fact, merge the returned logicClaims into the requirement logic_claims manifest, then add requires_predicate without overwriting other requirement metadata.",
|
|
356
|
+
},
|
|
357
|
+
}
|
|
358
|
+
: {}),
|
|
359
|
+
...(suggestion.kind === "rule" && suggestion.relationshipPlan !== null
|
|
360
|
+
? {
|
|
361
|
+
relationshipPlan: {
|
|
362
|
+
...suggestion.relationshipPlan,
|
|
363
|
+
claimKey: clause.claim_key,
|
|
364
|
+
claimText: clause.text,
|
|
365
|
+
logicClaims: expectedClaimKeys,
|
|
366
|
+
semanticInventory: [
|
|
367
|
+
{
|
|
368
|
+
claim_key: clause.claim_key,
|
|
369
|
+
claim_text: clause.text,
|
|
370
|
+
role: clause.normative ? "normative" : "descriptive",
|
|
371
|
+
status: "modeled",
|
|
372
|
+
span: clauseSpan,
|
|
373
|
+
reason: "The returned typed rule grounds this proposition.",
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
instructions: "Create the rule_schema and rule facts, merge the returned logicClaims into the requirement logic_claims manifest, then add requires_rule without overwriting other requirement metadata.",
|
|
377
|
+
},
|
|
378
|
+
}
|
|
379
|
+
: {}),
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function unmatchedClauseSuggestion(payload, clause, expectedClaimKeys) {
|
|
383
|
+
return withClauseProvenance({
|
|
384
|
+
kind: "ontology_gap",
|
|
385
|
+
claim_key: clause.claim_key,
|
|
386
|
+
claim_text: clause.text,
|
|
387
|
+
confidence: 0.6,
|
|
388
|
+
evidence: clause.text,
|
|
389
|
+
rationale: "This normative clause has no deterministic strict-property or declared predicate grounding. Define its domain terms and predicate signature explicitly before grounding it; keep it unresolved instead of treating prose as logic-complete.",
|
|
390
|
+
suggested_next_tool: "kb_suggest_predicates",
|
|
391
|
+
recommendedPredicateSchema: null,
|
|
392
|
+
applyPlan: observationPlan(payload, "Ontology gap: ungrounded clause", [
|
|
393
|
+
"semantic-advisor-suggestion",
|
|
394
|
+
"review:ontology-gap",
|
|
395
|
+
"needs_schema_extension",
|
|
396
|
+
]),
|
|
397
|
+
}, clause, expectedClaimKeys, statementOf(payload));
|
|
398
|
+
}
|
|
399
|
+
function propositionRole(statement, normative) {
|
|
400
|
+
if (/\b(?:for example|e\.g\.|such as|illustrative)\b/i.test(statement))
|
|
401
|
+
return "example";
|
|
402
|
+
if (/\b(?:because|so that|in order to| rationale|therefore)\b/i.test(statement))
|
|
403
|
+
return "rationale";
|
|
404
|
+
if (/\b(?:feel|comfortable|looks complete|seems complete|subjective|prefer)\b/i.test(statement))
|
|
405
|
+
return "subjective";
|
|
406
|
+
if (/\b(?:means|defined as|refers to|is called)\b/i.test(statement))
|
|
407
|
+
return "definition";
|
|
408
|
+
if (/^\s*(?:if|when|whenever|provided that|only if)\b/i.test(statement))
|
|
409
|
+
return "condition";
|
|
410
|
+
if (/\b(?:unless|except|exempt|apart from)\b/i.test(statement))
|
|
411
|
+
return "exception";
|
|
412
|
+
if (normative)
|
|
413
|
+
return "normative";
|
|
414
|
+
return "descriptive";
|
|
415
|
+
}
|
|
416
|
+
function shadowAnalysis(text, interpretations) {
|
|
417
|
+
const valid = interpretations.filter((interpretation) => interpretation.valid);
|
|
418
|
+
const models = valid.flatMap(({ normalized_ir: ir }) => (ir ? [ir] : []));
|
|
419
|
+
const containsExpressionKind = (kind) => {
|
|
420
|
+
const visit = (value) => {
|
|
421
|
+
if (!isRecord(value))
|
|
422
|
+
return false;
|
|
423
|
+
if (value.kind === kind)
|
|
424
|
+
return true;
|
|
425
|
+
return Object.values(value).some((child) => Array.isArray(child) ? child.some(visit) : visit(child));
|
|
426
|
+
};
|
|
427
|
+
return models.some((model) => visit(model));
|
|
428
|
+
};
|
|
429
|
+
const hasModality = (modalities) => models.some((model) => modalities.includes(model.modality));
|
|
430
|
+
const hasNegativeAtom = (() => {
|
|
431
|
+
const visit = (value) => {
|
|
432
|
+
if (!isRecord(value))
|
|
433
|
+
return false;
|
|
434
|
+
if (value.kind === "not" || value.polarity === "negative")
|
|
435
|
+
return true;
|
|
436
|
+
return Object.values(value).some((child) => Array.isArray(child) ? child.some(visit) : visit(child));
|
|
437
|
+
};
|
|
438
|
+
return models.some((model) => visit(model));
|
|
439
|
+
})();
|
|
440
|
+
const cues = [
|
|
441
|
+
{
|
|
442
|
+
kind: "modal",
|
|
443
|
+
pattern: /\b(?:must|shall|should|may|can)\b/i,
|
|
444
|
+
evidence: "deontic modal",
|
|
445
|
+
represented: models.length > 0,
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
kind: "polarity",
|
|
449
|
+
pattern: /\b(?:assert|deny|forbid|allowed|permitted|prohibited)\b/i,
|
|
450
|
+
evidence: "polarity cue",
|
|
451
|
+
represented: hasModality(["deny", "forbid", "permit"]) || hasNegativeAtom,
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
kind: "passive_voice",
|
|
455
|
+
pattern: /\b(?:is|are|be|was|were)\s+[a-z]+ed\b/i,
|
|
456
|
+
evidence: "passive construction",
|
|
457
|
+
represented: false,
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
kind: "nominalization",
|
|
461
|
+
pattern: /\b[a-z]+(?:tion|ment|ity|ance|ence)\b/i,
|
|
462
|
+
evidence: "nominalized domain term",
|
|
463
|
+
represented: false,
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
kind: "conditional",
|
|
467
|
+
pattern: /\b(?:if|when|whenever|provided that)\b/i,
|
|
468
|
+
evidence: "conditional",
|
|
469
|
+
represented: models.some(({ kind, body }) => kind === "rule" && body !== undefined),
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
kind: "causal",
|
|
473
|
+
pattern: /\b(?:because|so that|therefore|as a result)\b/i,
|
|
474
|
+
evidence: "causal relation",
|
|
475
|
+
represented: false,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
kind: "prerequisite",
|
|
479
|
+
pattern: /\b(?:before|only after|requires?\s+.+?\s+before)\b/i,
|
|
480
|
+
evidence: "prerequisite/order relation",
|
|
481
|
+
represented: containsExpressionKind("temporal"),
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
kind: "exception",
|
|
485
|
+
pattern: /\b(?:unless|except|exempt|apart from)\b/i,
|
|
486
|
+
evidence: "exception",
|
|
487
|
+
represented: models.some(({ exceptions }) => (exceptions?.length ?? 0) > 0) ||
|
|
488
|
+
containsExpressionKind("not"),
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
kind: "temporal",
|
|
492
|
+
pattern: /\b(?:before|after|during|until|within|expires?|retained for)\b/i,
|
|
493
|
+
evidence: "temporal qualifier",
|
|
494
|
+
represented: containsExpressionKind("temporal") ||
|
|
495
|
+
models.some(({ validFrom, validTo }) => validFrom !== undefined || validTo !== undefined) ||
|
|
496
|
+
containsExpressionKind("duration"),
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
kind: "quantifier",
|
|
500
|
+
pattern: /\b(?:each|every|all|any|some|only|at least|at most|exactly|no more than)\b/i,
|
|
501
|
+
evidence: "quantifier/cardinality",
|
|
502
|
+
represented: models.some(({ variables }) => (variables?.length ?? 0) > 0) ||
|
|
503
|
+
containsExpressionKind("count") ||
|
|
504
|
+
containsExpressionKind("compare") ||
|
|
505
|
+
containsExpressionKind("all") ||
|
|
506
|
+
containsExpressionKind("any"),
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
kind: "numeric",
|
|
510
|
+
pattern: /\b\d+(?:\.\d+)?\b|\b(?:zero|one|two|three|four|five|six|seven|eight|nine|ten)\b/i,
|
|
511
|
+
evidence: "numeric or cardinality value",
|
|
512
|
+
represented: containsExpressionKind("number") ||
|
|
513
|
+
containsExpressionKind("count") ||
|
|
514
|
+
containsExpressionKind("compare"),
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
kind: "negation_scope",
|
|
518
|
+
pattern: /\b(?:not|never|no|without|cannot|can't|must not)\b/i,
|
|
519
|
+
evidence: "negation scope",
|
|
520
|
+
represented: hasModality(["deny", "forbid"]) || hasNegativeAtom,
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
kind: "directionality",
|
|
524
|
+
pattern: /\b(?:only if|if and only if|unless|when)\b/i,
|
|
525
|
+
evidence: "condition direction",
|
|
526
|
+
represented: models.some(({ kind, body }) => kind === "rule" && body !== undefined),
|
|
527
|
+
},
|
|
528
|
+
];
|
|
529
|
+
return cues
|
|
530
|
+
.filter((cue) => cue.pattern.test(text))
|
|
531
|
+
.map(({ kind, evidence, represented }) => ({
|
|
532
|
+
kind,
|
|
533
|
+
evidence,
|
|
534
|
+
represented,
|
|
535
|
+
}));
|
|
536
|
+
}
|
|
537
|
+
function propositionSpan(text, clause, cursor) {
|
|
538
|
+
const exact = text.indexOf(clause.text, cursor);
|
|
539
|
+
const start = exact >= 0 ? exact : cursor;
|
|
540
|
+
const end = exact >= 0
|
|
541
|
+
? exact + clause.text.length
|
|
542
|
+
: Math.min(text.length, start + clause.text.length);
|
|
543
|
+
return { span: utf8Span(text, start, end), next: Math.max(cursor, end) };
|
|
544
|
+
}
|
|
545
|
+
function interpretationResults(interpretations, clauses, statement) {
|
|
546
|
+
if (interpretations === undefined)
|
|
547
|
+
return { results: [], warnings: [] };
|
|
548
|
+
const known = new Set(clauses.map((clause) => clause.claim_key));
|
|
549
|
+
const semanticKeys = new Map();
|
|
550
|
+
const warnings = [];
|
|
551
|
+
const results = interpretations.slice(0, 3).map((candidate) => {
|
|
552
|
+
const confidence = Math.max(0, Math.min(1, candidate.confidence ?? 0.5));
|
|
553
|
+
const validation = validateLogicIr(candidate.ir);
|
|
554
|
+
const errors = [...validation.errors];
|
|
555
|
+
const clause = clauses.find((entry) => entry.claim_key === candidate.claim_key);
|
|
556
|
+
if (!known.has(candidate.claim_key))
|
|
557
|
+
errors.push(`claim_key ${candidate.claim_key} is not present in the advisor proposition inventory`);
|
|
558
|
+
if (clause &&
|
|
559
|
+
candidate.claim_text !== clause.text &&
|
|
560
|
+
semanticClaimKey(candidate.claim_text) !== clause.claim_key)
|
|
561
|
+
errors.push(`claim_text for ${candidate.claim_key} must match the proposition text (apart from normalized punctuation)`);
|
|
562
|
+
if (candidate.span &&
|
|
563
|
+
(candidate.span.start < 0 || candidate.span.end < candidate.span.start))
|
|
564
|
+
errors.push("interpretation span is invalid");
|
|
565
|
+
if (clause && candidate.span) {
|
|
566
|
+
const candidateStart = statement.indexOf(candidate.claim_text);
|
|
567
|
+
const clauseStart = statement.indexOf(clause.text);
|
|
568
|
+
const sourceStart = candidateStart >= 0 ? candidateStart : clauseStart;
|
|
569
|
+
const sourceEnd = sourceStart >= 0
|
|
570
|
+
? sourceStart +
|
|
571
|
+
(candidateStart >= 0
|
|
572
|
+
? candidate.claim_text.length
|
|
573
|
+
: clause.text.length)
|
|
574
|
+
: 0;
|
|
575
|
+
const expectedSpan = utf8Span(statement, Math.max(0, sourceStart), Math.max(0, sourceEnd));
|
|
576
|
+
if (candidate.span.start !== expectedSpan.start ||
|
|
577
|
+
candidate.span.end !== expectedSpan.end)
|
|
578
|
+
errors.push(`interpretation span for ${candidate.claim_key} does not match the exact UTF-8 proposition span`);
|
|
579
|
+
}
|
|
580
|
+
const semanticKey = validation.semanticKey;
|
|
581
|
+
if (semanticKey !== undefined) {
|
|
582
|
+
const prior = semanticKeys.get(candidate.claim_key);
|
|
583
|
+
if (prior !== undefined && prior !== semanticKey)
|
|
584
|
+
warnings.push(`Claim ${candidate.claim_key} has materially different interpretations; it remains unresolved until one is selected.`);
|
|
585
|
+
semanticKeys.set(candidate.claim_key, semanticKey);
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
claim_key: candidate.claim_key,
|
|
589
|
+
...(semanticKey ? { semantic_key: semanticKey } : {}),
|
|
590
|
+
...(validation.normalized
|
|
591
|
+
? { normalized_ir: validation.normalized }
|
|
592
|
+
: {}),
|
|
593
|
+
valid: errors.length === 0 && validation.valid,
|
|
594
|
+
confidence,
|
|
595
|
+
errors,
|
|
596
|
+
warnings: validation.warnings,
|
|
597
|
+
...(validation.renderedProlog
|
|
598
|
+
? { rendered_prolog: validation.renderedProlog }
|
|
599
|
+
: {}),
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
if (interpretations.length > 3)
|
|
603
|
+
warnings.push("Only the first three interpretations are considered; submit materially distinct alternatives explicitly and resolve them before writing.");
|
|
604
|
+
return { results, warnings };
|
|
605
|
+
}
|
|
606
|
+
function propositionInventory(statement, clauses, suggestions, interpretations, inputPayloadHash) {
|
|
607
|
+
const interpretationKeys = new Map();
|
|
608
|
+
for (const interpretation of interpretations) {
|
|
609
|
+
if (!interpretation.valid || !interpretation.semantic_key)
|
|
610
|
+
continue;
|
|
611
|
+
const keys = interpretationKeys.get(interpretation.claim_key) ?? new Set();
|
|
612
|
+
keys.add(interpretation.semantic_key);
|
|
613
|
+
interpretationKeys.set(interpretation.claim_key, keys);
|
|
614
|
+
}
|
|
615
|
+
let cursor = 0;
|
|
616
|
+
return clauses.map((clause) => {
|
|
617
|
+
const located = propositionSpan(statement, clause, cursor);
|
|
618
|
+
cursor = located.next;
|
|
619
|
+
const role = propositionRole(clause.text, clause.normative);
|
|
620
|
+
const suggestion = suggestions.find((candidate) => candidate.claim_key === clause.claim_key);
|
|
621
|
+
let status;
|
|
622
|
+
let reason;
|
|
623
|
+
const keys = interpretationKeys.get(clause.claim_key);
|
|
624
|
+
const semanticKey = keys?.size === 1 ? [...keys][0] : undefined;
|
|
625
|
+
if (keys && keys.size > 1) {
|
|
626
|
+
status = "ambiguous";
|
|
627
|
+
reason =
|
|
628
|
+
"Materially different valid interpretations were submitted; confidence cannot choose between them.";
|
|
629
|
+
}
|
|
630
|
+
else if (semanticKey) {
|
|
631
|
+
status = "modeled";
|
|
632
|
+
}
|
|
633
|
+
else if (role === "rationale" ||
|
|
634
|
+
role === "example" ||
|
|
635
|
+
role === "subjective") {
|
|
636
|
+
status = "nonlogical";
|
|
637
|
+
reason =
|
|
638
|
+
"Prose is retained for human context but does not assert a verifiable domain proposition.";
|
|
639
|
+
}
|
|
640
|
+
else if (suggestion?.kind === "ambiguity_observation") {
|
|
641
|
+
status = "ambiguous";
|
|
642
|
+
reason = suggestion.rationale;
|
|
643
|
+
}
|
|
644
|
+
else if (suggestion?.kind === "ontology_gap") {
|
|
645
|
+
status = "ontology_gap";
|
|
646
|
+
reason = suggestion.rationale;
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
status = "missing";
|
|
650
|
+
reason =
|
|
651
|
+
"No accepted typed interpretation grounds this assertive proposition.";
|
|
652
|
+
}
|
|
653
|
+
return {
|
|
654
|
+
claim_key: clause.claim_key,
|
|
655
|
+
claim_text: clause.text,
|
|
656
|
+
role,
|
|
657
|
+
status,
|
|
658
|
+
span: located.span,
|
|
659
|
+
payload_hash: inputPayloadHash,
|
|
660
|
+
...(semanticKey ? { semantic_key: semanticKey } : {}),
|
|
661
|
+
...(reason ? { reason } : {}),
|
|
662
|
+
};
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
export function analyzeSemanticAdvisorInput(input) {
|
|
666
|
+
const payload = input.payload;
|
|
667
|
+
const requirement = isRequirement(payload);
|
|
668
|
+
const statement = statementOf(payload) || proseOf(payload);
|
|
669
|
+
const signals = requirement ? detectSignals(proseOf(payload)) : [];
|
|
670
|
+
const clauses = statement
|
|
671
|
+
? extractSemanticClauses(statement, input.clauses)
|
|
672
|
+
: [];
|
|
673
|
+
const rawDeclaredClaims = propertiesOf(payload).logic_claims;
|
|
674
|
+
const declaredClaims = Array.isArray(rawDeclaredClaims)
|
|
675
|
+
? rawDeclaredClaims.filter((value) => typeof value === "string")
|
|
676
|
+
: [];
|
|
677
|
+
const expectedClaims = clauses
|
|
678
|
+
.filter((clause) => clause.normative)
|
|
679
|
+
.map((clause) => clause.claim_key);
|
|
680
|
+
const modeled = requirement &&
|
|
681
|
+
isModeled(payload, expectedClaims.length) &&
|
|
682
|
+
expectedClaims.length > 0 &&
|
|
683
|
+
expectedClaims.every((claimKey) => declaredClaims.includes(claimKey));
|
|
684
|
+
const suggestions = modelingSuggestions(payload, modeled, clauses, input.interpretations);
|
|
685
|
+
const interpreted = interpretationResults(input.interpretations, clauses, statement);
|
|
686
|
+
const propositions = propositionInventory(statement, clauses, suggestions, interpreted.results, payloadHash(payload));
|
|
687
|
+
const shadow = shadowAnalysis(statement, interpreted.results);
|
|
688
|
+
const result = buildAdvisorResult(payload, signals, modeled, suggestions, clauses, propositions, interpreted.results, shadow);
|
|
689
|
+
return {
|
|
690
|
+
receipt: result.receipt,
|
|
691
|
+
warnings: [...result.warnings, ...interpreted.warnings],
|
|
692
|
+
};
|
|
693
|
+
}
|