kibi-cli 2.0.0 → 2.2.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-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +3 -2
- package/dist/cli-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +25 -1
- package/dist/cli-register-reporting.d.ts.map +1 -1
- package/dist/cli-register-reporting.js +6 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -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-generated.d.ts +7 -0
- package/dist/commands/check-generated.d.ts.map +1 -0
- package/dist/commands/check-generated.js +192 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +24 -15
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +227 -25
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +3 -1
- 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 +1 -1
- 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 +136 -30
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +110 -15
- package/dist/commands/proof-explain.d.ts +10 -0
- package/dist/commands/proof-explain.d.ts.map +1 -0
- package/dist/commands/proof-explain.js +45 -0
- package/dist/commands/proof-impact.d.ts +7 -0
- package/dist/commands/proof-impact.d.ts.map +1 -0
- package/dist/commands/proof-impact.js +39 -0
- package/dist/commands/proof-migrate-legacy.js +1 -1
- package/dist/commands/proof-prune.js +1 -1
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +14 -22
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +17 -2
- 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 +1 -0
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +18 -16
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +14 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -3
- package/dist/engine.d.ts +29 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +259 -89
- package/dist/env/bootstrap.d.ts +84 -0
- package/dist/env/bootstrap.d.ts.map +1 -0
- package/dist/env/bootstrap.js +310 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +67 -29
- package/dist/extractors/markdown.d.ts +4 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +33 -3
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +1 -0
- package/dist/extractors/symbols-coordinator.d.ts +8 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +40 -0
- package/dist/extractors/symbols-ts.d.ts +8 -19
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +33 -503
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +68 -30
- 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 +179 -9
- 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-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/suggest-predicates.d.ts +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +30 -3
- 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 +65 -26
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +5 -0
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +9 -87
- 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 +72 -4
- 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 +61 -17
- package/dist/operations/planning/compile-intent.d.ts +49 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +66 -4
- package/dist/operations/proof/baseline-diff.d.ts +41 -0
- package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
- package/dist/operations/proof/baseline-diff.js +153 -0
- package/dist/operations/proof/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/explain.d.ts +75 -0
- package/dist/operations/proof/explain.d.ts.map +1 -0
- package/dist/operations/proof/explain.js +294 -0
- package/dist/operations/proof/impact.d.ts +45 -0
- package/dist/operations/proof/impact.d.ts.map +1 -0
- package/dist/operations/proof/impact.js +118 -0
- package/dist/operations/proof/ingest-proof.d.ts +4 -2
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +251 -77
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
- package/dist/operations/proof/migrate-legacy-receipts.js +28 -22
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +8 -6
- package/dist/operations/proof/receipt-document.js +2 -2
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +18 -67
- package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
- package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
- package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
- package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
- package/dist/operations/semantic-advisor/types.d.ts +1 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
- package/dist/plugins/compose-ontology-packs.d.ts +51 -0
- package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
- package/dist/plugins/compose-ontology-packs.js +257 -0
- package/dist/plugins/compose-semantic-classifier.d.ts +47 -0
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
- package/dist/plugins/compose-semantic-classifier.js +216 -0
- 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 +17 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -0
- package/dist/plugins/external-allowlist.js +29 -0
- package/dist/plugins/index.d.ts +11 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +37 -0
- package/dist/plugins/load-plugin.d.ts +19 -0
- package/dist/plugins/load-plugin.d.ts.map +1 -0
- package/dist/plugins/load-plugin.js +59 -0
- package/dist/plugins/project-config.d.ts +28 -0
- package/dist/plugins/project-config.d.ts.map +1 -0
- package/dist/plugins/project-config.js +90 -0
- package/dist/plugins/registry.d.ts +94 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +359 -0
- package/dist/plugins/resolve-package.d.ts +47 -0
- package/dist/plugins/resolve-package.d.ts.map +1 -0
- package/dist/plugins/resolve-package.js +262 -0
- package/dist/plugins/source-analysis-service.d.ts +44 -0
- package/dist/plugins/source-analysis-service.d.ts.map +1 -0
- package/dist/plugins/source-analysis-service.js +232 -0
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -0
- package/dist/prolog/janitor.d.ts.map +1 -1
- package/dist/prolog/janitor.js +1 -1
- package/dist/prolog/store-lock.d.ts +1 -1
- package/dist/prolog/store-lock.d.ts.map +1 -1
- package/dist/prolog.d.ts +36 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +78 -9
- package/dist/proof/inspect.js +1 -1
- package/dist/proof/producers/playwright-case-id.js +2 -2
- package/dist/proof/producers/playwright-reporter.js +4 -4
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +7 -25
- package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
- package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/public/extractors/symbols-coordinator.js +1 -1
- package/dist/public/impact/analyzer.d.ts +1 -1
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +6 -4
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +4 -12
- package/dist/public/operations/catalog.d.ts +39 -7
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +11 -3
- package/dist/public/operations/check-helpers.d.ts +7 -1
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +22 -2
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +51 -12
- package/dist/public/operations/discovery-entities.d.ts +53 -1
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +219 -12
- 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 +93 -59
- 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/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 +1 -1
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +16 -10
- 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 +17 -2
- 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 +9 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +10 -1
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +10 -1
- 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/proof.js +1 -1
- package/dist/public/operations/specs/reporting.d.ts +9 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +48 -17
- package/dist/public/operations/specs/semantic.d.ts +1 -1
- package/dist/public/operations/specs/semantic.d.ts.map +1 -1
- package/dist/public/operations/specs/semantic.js +54 -4
- package/dist/public/operations/specs/upsert.d.ts +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 +11 -4
- package/dist/public/operations/types.d.ts +5 -0
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/proof-protocol.js +4 -4
- 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 +10 -3
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/dist/public/skills/kibi-usage/resources/proof.md +45 -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/symbol-granularity.d.ts +1 -1
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.generated.d.ts.map +1 -1
- package/dist/public/symbol-granularity.generated.js +38 -5
- 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/report/html-report.css +1239 -281
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +18 -0
- package/dist/schemas/entity.schema.json +32 -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/symbol-extract.d.ts +24 -7
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +64 -208
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +8 -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/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 +42 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +50 -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 -11
- 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/extractors/symbols-coordinator.ts +1 -0
- package/src/public/impact/analyzer.ts +15 -12
- package/src/public/impact/full-kb-quality.ts +4 -16
- package/src/public/operations/check-executor.ts +13 -2
- package/src/public/operations/check-helpers.ts +29 -3
- package/src/public/operations/contracts.ts +59 -12
- package/src/public/operations/discovery-entities.ts +327 -12
- package/src/public/operations/discovery-executors.ts +110 -61
- package/src/public/operations/migration-plan.ts +57 -0
- package/src/public/operations/predicate-schema-conformance.ts +362 -0
- package/src/public/operations/prolog-json.ts +22 -8
- package/src/public/operations/result-envelope.ts +114 -2
- package/src/public/operations/runtime-types.ts +22 -3
- package/src/public/operations/specs/check-rules.generated.ts +9 -1
- package/src/public/operations/specs/discovery.ts +11 -1
- package/src/public/operations/specs/mutation-schemas.ts +23 -3
- package/src/public/operations/specs/proof.ts +1 -1
- package/src/public/operations/specs/reporting.ts +71 -24
- package/src/public/operations/specs/semantic.ts +79 -17
- package/src/public/operations/specs/upsert.ts +1 -1
- package/src/public/operations/symbol-repair-plan.ts +16 -7
- package/src/public/operations/types.ts +5 -0
- package/src/public/proof-fingerprint.ts +1 -1
- package/src/public/proof-protocol-types.d.ts +1 -1
- package/src/public/proof-protocol.ts +4 -4
- package/src/public/schemas/entity.ts +22 -0
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skills/kibi-usage/SKILL.md +10 -3
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/src/public/skills/kibi-usage/resources/proof.md +45 -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/symbol-granularity.generated.ts +45 -12
- package/src/public/symbol-granularity.ts +3 -3
- package/src/public/telemetry-acceptance.ts +37 -6
- package/src/schemas/entity.schema.json +32 -0
- package/src/schemas/relationship.schema.json +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PrologPort } from "./runtime-types.js";
|
|
1
|
+
import type { PrologEntityQueryInput, PrologEntityQueryResult, PrologPort } from "./runtime-types.js";
|
|
2
2
|
export type EntityQueryInput = {
|
|
3
3
|
readonly type?: string;
|
|
4
4
|
readonly id?: string;
|
|
@@ -7,11 +7,63 @@ export type EntityQueryInput = {
|
|
|
7
7
|
/** Page size for index-backed queries; bounds each query's output. */
|
|
8
8
|
readonly limit?: number;
|
|
9
9
|
readonly offset?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Proof selection only needs the contract. Omit receipt histories so a
|
|
12
|
+
* campaign does not page every full test entity.
|
|
13
|
+
*/
|
|
14
|
+
readonly projection?: "proof_contract";
|
|
10
15
|
};
|
|
11
16
|
export declare const VALID_ENTITY_TYPES: readonly ["req", "scenario", "test", "adr", "flag", "event", "symbol", "fact"];
|
|
12
17
|
export declare function validateEntityType(type?: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Proof campaign selection must not materialize every contracted test in a
|
|
20
|
+
* single Prolog result. The specialized projection excludes receipt histories
|
|
21
|
+
* and returns one bounded page at a time.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PROOF_CONTRACT_PAGE_SIZE = 100;
|
|
13
24
|
export declare function buildEntityGoal(input: EntityQueryInput): string;
|
|
25
|
+
export declare function loadEntitiesPaged(prolog: Pick<PrologPort, "query">, type: (typeof VALID_ENTITY_TYPES)[number], pageSize?: number): Promise<Record<string, unknown>[]>;
|
|
14
26
|
export declare function loadEntities(prolog: Pick<PrologPort, "query">, input: EntityQueryInput): Promise<Record<string, unknown>[]>;
|
|
15
27
|
export declare function paginateResults<T>(results: readonly T[], limit?: number, offset?: number): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Page size for index-backed search candidate fetches. Each page is one
|
|
30
|
+
* Prolog query, so a fixed page size substantially bounds each response and
|
|
31
|
+
* fixes the observed large-KB output overflow; it is a practical bound, not
|
|
32
|
+
* a byte-size guarantee for arbitrarily large individual entity payloads.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SEARCH_CANDIDATE_PAGE_SIZE = 500;
|
|
35
|
+
export declare function loadSearchCandidates(prolog: Pick<PrologPort, "searchEntities"> & Partial<Pick<PrologPort, "query">>, input: {
|
|
36
|
+
readonly query: string;
|
|
37
|
+
readonly type?: string;
|
|
38
|
+
readonly maxCandidates?: number;
|
|
39
|
+
}, signal?: AbortSignal): Promise<Record<string, unknown>[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Projected candidate rows for every entity (optionally of one type), in id
|
|
42
|
+
* order, bounded by `maxCandidates`. For semantic discovery that has no
|
|
43
|
+
* lexical token to pre-filter candidates.
|
|
44
|
+
*/
|
|
45
|
+
export declare function listSearchCandidates(prolog: Pick<PrologPort, "query">, input: {
|
|
46
|
+
readonly type?: string;
|
|
47
|
+
readonly maxCandidates: number;
|
|
48
|
+
}, signal?: AbortSignal): Promise<Record<string, unknown>[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Rows per `kb_query_entities` request. Full entities carry receipt
|
|
51
|
+
* histories, so a caller-sized page (up to 100k rows) is split into bounded
|
|
52
|
+
* requests and concatenated; the reported count is the total match count.
|
|
53
|
+
*/
|
|
54
|
+
export declare const ENTITY_QUERY_CHUNK_SIZE = 25;
|
|
55
|
+
export declare function queryEntityChunks(readChunk: (input: PrologEntityQueryInput) => Promise<PrologEntityQueryResult>, input: PrologEntityQueryInput): Promise<PrologEntityQueryResult>;
|
|
56
|
+
/** Bounded `kb_query_entities` paging for ports without the engine method. */
|
|
57
|
+
export declare function queryEntitiesViaQuery(prolog: Pick<PrologPort, "query">, input: PrologEntityQueryInput, signal?: AbortSignal): Promise<PrologEntityQueryResult>;
|
|
58
|
+
/** Every entity id, without materializing entity properties. */
|
|
59
|
+
export declare function loadEntityIds(prolog: Pick<PrologPort, "query">): Promise<string[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Replace projected search candidates with complete entities, one bounded
|
|
62
|
+
* query per entity. Used only for the final result page when a caller asks
|
|
63
|
+
* for full entity bodies.
|
|
64
|
+
*/
|
|
65
|
+
export declare function reloadFullEntities<TMatch extends {
|
|
66
|
+
readonly entity: Record<string, unknown>;
|
|
67
|
+
}>(prolog: Pick<PrologPort, "query">, matches: readonly TMatch[]): Promise<TMatch[]>;
|
|
16
68
|
export declare function dedupeEntities(entities: readonly Record<string, unknown>[]): Record<string, unknown>[];
|
|
17
69
|
//# sourceMappingURL=discovery-entities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-entities.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-entities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discovery-entities.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-entities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EAGX,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,kBAAkB,gFASrB,CAAC;AAGX,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAMtD;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAG5C,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CA0C/D;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EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAYpC;AA8ED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAG1C,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,CACT,KAAK,EAAE,sBAAsB,KAC1B,OAAO,CAAC,uBAAuB,CAAC,EACrC,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CAoBlC;AAED,8EAA8E;AAE9E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EACjC,KAAK,EAAE,sBAAsB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,uBAAuB,CAAC,CAclC;AAED,gEAAgE;AAEhE,wBAAsB,aAAa,CACjC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED;;;;GAIG;AAEH,wBAAsB,kBAAkB,CACtC,MAAM,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAE3D,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,OAAO,CAAC,MAAM,EAAE,CAAC,CAcnB;AAGD,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAC3C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAQ3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { escapeAtomContent, parseEntityFromBinding, parseEntityFromList, parseListOfLists, } from "../../prolog/codec.js";
|
|
1
|
+
import { escapeAtomContent, normalizeEntityId, parseAtomList, parseEntityFromBinding, parseEntityFromList, parseListOfLists, } from "../../prolog/codec.js";
|
|
2
2
|
export const VALID_ENTITY_TYPES = [
|
|
3
3
|
"req",
|
|
4
4
|
"scenario",
|
|
@@ -15,9 +15,21 @@ export function validateEntityType(type) {
|
|
|
15
15
|
throw new Error(`Invalid type '${type}'. Valid types: ${VALID_ENTITY_TYPES.join(", ")}. Use a single type value, or omit this parameter to query all entities.`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Proof campaign selection must not materialize every contracted test in a
|
|
20
|
+
* single Prolog result. The specialized projection excludes receipt histories
|
|
21
|
+
* and returns one bounded page at a time.
|
|
22
|
+
*/
|
|
23
|
+
export const PROOF_CONTRACT_PAGE_SIZE = 100;
|
|
18
24
|
// implements REQ-002, REQ-013
|
|
19
25
|
export function buildEntityGoal(input) {
|
|
20
26
|
const { type, id, tags, sourceFile } = input;
|
|
27
|
+
if (type === "test" && input.projection === "proof_contract") {
|
|
28
|
+
const idTerm = id ? `some('${escapeAtomContent(id)}')` : "none";
|
|
29
|
+
const limit = input.limit ?? PROOF_CONTRACT_PAGE_SIZE;
|
|
30
|
+
const offset = input.offset ?? 0;
|
|
31
|
+
return `kb_query_proof_contracts(${idTerm},${limit},${offset},Results)`;
|
|
32
|
+
}
|
|
21
33
|
if (sourceFile) {
|
|
22
34
|
const safeSource = escapeAtomContent(sourceFile);
|
|
23
35
|
if (type) {
|
|
@@ -53,21 +65,61 @@ export function buildEntityGoal(input) {
|
|
|
53
65
|
}
|
|
54
66
|
return "findall([Id,Type,Props], kb_entity(Id, Type, Props), Results)";
|
|
55
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Full test entities carry their receipt histories, which only grow. Callers
|
|
70
|
+
* that must see every full entity of a type page through the indexed query so
|
|
71
|
+
* no single Prolog answer can approach the bounded output capacity.
|
|
72
|
+
*/
|
|
73
|
+
const FULL_ENTITY_PAGE_SIZE = 25;
|
|
74
|
+
// implements REQ-002, REQ-013
|
|
75
|
+
export async function loadEntitiesPaged(prolog, type, pageSize = FULL_ENTITY_PAGE_SIZE) {
|
|
76
|
+
if (!Number.isInteger(pageSize) || pageSize <= 0) {
|
|
77
|
+
throw new Error("loadEntitiesPaged pageSize must be a positive integer");
|
|
78
|
+
}
|
|
79
|
+
const entities = [];
|
|
80
|
+
for (let offset = 0;; offset += pageSize) {
|
|
81
|
+
const page = await loadEntities(prolog, { type, limit: pageSize, offset });
|
|
82
|
+
entities.push(...page);
|
|
83
|
+
if (page.length < pageSize)
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
return dedupeEntities(entities);
|
|
87
|
+
}
|
|
56
88
|
// implements REQ-002, REQ-013
|
|
57
89
|
export async function loadEntities(prolog, input) {
|
|
58
90
|
validateEntityType(input.type);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
const readPage = async (pageInput) => {
|
|
92
|
+
const queryResult = await prolog.query(buildEntityGoal(pageInput));
|
|
93
|
+
if (!queryResult.success) {
|
|
94
|
+
throw new Error(queryResult.error || "Query failed with unknown error");
|
|
95
|
+
}
|
|
96
|
+
const resultsBinding = queryResult.bindings.Results;
|
|
97
|
+
const resultBinding = queryResult.bindings.Result;
|
|
98
|
+
if (resultsBinding) {
|
|
99
|
+
return parseListOfLists(resultsBinding).map(parseEntityFromList);
|
|
100
|
+
}
|
|
101
|
+
return resultBinding ? [parseEntityFromBinding(resultBinding)] : [];
|
|
102
|
+
};
|
|
103
|
+
let entities;
|
|
104
|
+
if (input.type === "test" &&
|
|
105
|
+
input.projection === "proof_contract" &&
|
|
106
|
+
input.id === undefined &&
|
|
107
|
+
input.limit === undefined &&
|
|
108
|
+
input.offset === undefined) {
|
|
109
|
+
entities = [];
|
|
110
|
+
for (let offset = 0;; offset += PROOF_CONTRACT_PAGE_SIZE) {
|
|
111
|
+
const page = await readPage({
|
|
112
|
+
...input,
|
|
113
|
+
limit: PROOF_CONTRACT_PAGE_SIZE,
|
|
114
|
+
offset,
|
|
115
|
+
});
|
|
116
|
+
entities.push(...page);
|
|
117
|
+
if (page.length < PROOF_CONTRACT_PAGE_SIZE)
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
68
120
|
}
|
|
69
|
-
else
|
|
70
|
-
entities =
|
|
121
|
+
else {
|
|
122
|
+
entities = await readPage(input);
|
|
71
123
|
}
|
|
72
124
|
if (input.tags && input.tags.length > 0) {
|
|
73
125
|
const requested = new Set(input.tags.map((tag) => tag.trim()));
|
|
@@ -83,6 +135,161 @@ export async function loadEntities(prolog, input) {
|
|
|
83
135
|
export function paginateResults(results, limit = 100, offset = 0) {
|
|
84
136
|
return results.slice(offset, offset + limit);
|
|
85
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Page size for index-backed search candidate fetches. Each page is one
|
|
140
|
+
* Prolog query, so a fixed page size substantially bounds each response and
|
|
141
|
+
* fixes the observed large-KB output overflow; it is a practical bound, not
|
|
142
|
+
* a byte-size guarantee for arbitrarily large individual entity payloads.
|
|
143
|
+
*/
|
|
144
|
+
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
|
145
|
+
export const SEARCH_CANDIDATE_PAGE_SIZE = 500;
|
|
146
|
+
function isPrologOutputOverflow(error) {
|
|
147
|
+
return error instanceof Error && error.message.includes("ENOBUFS");
|
|
148
|
+
}
|
|
149
|
+
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
|
150
|
+
export async function loadSearchCandidates(prolog, input, signal) {
|
|
151
|
+
// Call through the port property, never via a detached local: EngineClient
|
|
152
|
+
// searchEntities depends on `this` (this.command), and the PrologPort
|
|
153
|
+
// contract does not promise a pre-bound method. Ports without the indexed
|
|
154
|
+
// engine method run the same bounded Prolog search through `query`.
|
|
155
|
+
const readPage = (page) => {
|
|
156
|
+
if (prolog.searchEntities)
|
|
157
|
+
return prolog.searchEntities(page, signal);
|
|
158
|
+
const query = prolog.query;
|
|
159
|
+
if (query === undefined)
|
|
160
|
+
return Promise.resolve({ entities: [], count: 0 });
|
|
161
|
+
return searchEntitiesViaQuery({ query: (goal, querySignal) => query.call(prolog, goal, querySignal) }, page, signal);
|
|
162
|
+
};
|
|
163
|
+
return readCandidatePages(readPage, input);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Projected candidate rows for every entity (optionally of one type), in id
|
|
167
|
+
* order, bounded by `maxCandidates`. For semantic discovery that has no
|
|
168
|
+
* lexical token to pre-filter candidates.
|
|
169
|
+
*/
|
|
170
|
+
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
|
171
|
+
export async function listSearchCandidates(prolog, input, signal) {
|
|
172
|
+
const type = input.type ? `'${escapeAtomContent(input.type)}'` : "none";
|
|
173
|
+
return readCandidatePages((page) => readRowsAndCount(prolog, `kb_list_search_candidates(${type}, ${page.limit}, ${page.offset}, Rows, Count)`, "Search candidate listing failed", signal), { query: "", maxCandidates: input.maxCandidates });
|
|
174
|
+
}
|
|
175
|
+
async function readCandidatePages(readPage, input) {
|
|
176
|
+
const maxCandidates = input.maxCandidates ?? Number.POSITIVE_INFINITY;
|
|
177
|
+
const candidates = [];
|
|
178
|
+
let offset = 0;
|
|
179
|
+
let total = Number.POSITIVE_INFINITY;
|
|
180
|
+
let pageSize = SEARCH_CANDIDATE_PAGE_SIZE;
|
|
181
|
+
while (offset < total && candidates.length < maxCandidates) {
|
|
182
|
+
let page;
|
|
183
|
+
try {
|
|
184
|
+
page = await readPage({
|
|
185
|
+
query: input.query,
|
|
186
|
+
...(input.type !== undefined ? { type: input.type } : {}),
|
|
187
|
+
limit: pageSize,
|
|
188
|
+
offset,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
// A page of unusually large rows can still exceed the bounded Prolog
|
|
193
|
+
// output. Halve the page and retry the same offset; the smaller size is
|
|
194
|
+
// kept for the rest of the scan. Only a single row that overflows on its
|
|
195
|
+
// own is a real failure.
|
|
196
|
+
if (pageSize > 1 && isPrologOutputOverflow(error)) {
|
|
197
|
+
pageSize = Math.max(1, Math.floor(pageSize / 2));
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
if (page.entities.length === 0)
|
|
203
|
+
break;
|
|
204
|
+
candidates.push(...page.entities);
|
|
205
|
+
total = page.count;
|
|
206
|
+
offset += page.entities.length;
|
|
207
|
+
}
|
|
208
|
+
return Number.isFinite(maxCandidates)
|
|
209
|
+
? candidates.slice(0, maxCandidates)
|
|
210
|
+
: candidates;
|
|
211
|
+
}
|
|
212
|
+
function searchEntitiesViaQuery(prolog, input, signal) {
|
|
213
|
+
const type = input.type ? `'${escapeAtomContent(input.type)}'` : "none";
|
|
214
|
+
return readRowsAndCount(prolog, `kb_search_entities(${type}, '${escapeAtomContent(input.query)}', ${input.limit}, ${input.offset}, Rows, Count)`, "Indexed search candidate query failed", signal);
|
|
215
|
+
}
|
|
216
|
+
async function readRowsAndCount(prolog, goal, errorLabel, signal) {
|
|
217
|
+
const result = await prolog.query(goal, signal);
|
|
218
|
+
if (!result.success) {
|
|
219
|
+
// Same message as the engine client's indexed methods, so both surfaces
|
|
220
|
+
// report a failure identically.
|
|
221
|
+
throw new Error(result.error ?? errorLabel);
|
|
222
|
+
}
|
|
223
|
+
const entities = result.bindings.Rows
|
|
224
|
+
? parseListOfLists(result.bindings.Rows).map(parseEntityFromList)
|
|
225
|
+
: [];
|
|
226
|
+
const count = Number.parseInt(result.bindings.Count ?? "0", 10);
|
|
227
|
+
return { entities, count: Number.isFinite(count) ? count : entities.length };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Rows per `kb_query_entities` request. Full entities carry receipt
|
|
231
|
+
* histories, so a caller-sized page (up to 100k rows) is split into bounded
|
|
232
|
+
* requests and concatenated; the reported count is the total match count.
|
|
233
|
+
*/
|
|
234
|
+
export const ENTITY_QUERY_CHUNK_SIZE = 25;
|
|
235
|
+
// implements REQ-kibi-operation-interface-parity
|
|
236
|
+
export async function queryEntityChunks(readChunk, input) {
|
|
237
|
+
const entities = [];
|
|
238
|
+
let count = 0;
|
|
239
|
+
let first = true;
|
|
240
|
+
while (first || entities.length < input.limit) {
|
|
241
|
+
const chunkLimit = Math.min(ENTITY_QUERY_CHUNK_SIZE, input.limit - entities.length);
|
|
242
|
+
const chunk = await readChunk({
|
|
243
|
+
...input,
|
|
244
|
+
limit: chunkLimit,
|
|
245
|
+
offset: input.offset + entities.length,
|
|
246
|
+
});
|
|
247
|
+
if (first)
|
|
248
|
+
count = chunk.count;
|
|
249
|
+
first = false;
|
|
250
|
+
entities.push(...chunk.entities);
|
|
251
|
+
if (chunk.entities.length < chunkLimit || chunkLimit === 0)
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return { entities, count };
|
|
255
|
+
}
|
|
256
|
+
/** Bounded `kb_query_entities` paging for ports without the engine method. */
|
|
257
|
+
// implements REQ-kibi-operation-interface-parity
|
|
258
|
+
export function queryEntitiesViaQuery(prolog, input, signal) {
|
|
259
|
+
const atom = (value) => value === undefined ? "none" : `'${escapeAtomContent(value)}'`;
|
|
260
|
+
const tags = `[${(input.tags ?? []).map((tag) => `'${escapeAtomContent(tag)}'`).join(",")}]`;
|
|
261
|
+
return queryEntityChunks((chunk) => readRowsAndCount(prolog, `kb_query_entities(${atom(chunk.type)}, ${atom(chunk.id)}, ${tags}, ${atom(chunk.sourceFile)}, ${chunk.limit}, ${chunk.offset}, Rows, Count)`, "Indexed entity query failed", signal), input);
|
|
262
|
+
}
|
|
263
|
+
/** Every entity id, without materializing entity properties. */
|
|
264
|
+
// implements REQ-002
|
|
265
|
+
export async function loadEntityIds(prolog) {
|
|
266
|
+
const result = await prolog.query("kb_entity_ids(Ids)");
|
|
267
|
+
if (!result.success) {
|
|
268
|
+
throw new Error(`Entity id enumeration failed: ${result.error ?? "Unknown error"}`);
|
|
269
|
+
}
|
|
270
|
+
return parseAtomList(result.bindings.Ids ?? "[]").map(normalizeEntityId);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Replace projected search candidates with complete entities, one bounded
|
|
274
|
+
* query per entity. Used only for the final result page when a caller asks
|
|
275
|
+
* for full entity bodies.
|
|
276
|
+
*/
|
|
277
|
+
// implements REQ-mcp-search-discovery
|
|
278
|
+
export async function reloadFullEntities(prolog, matches) {
|
|
279
|
+
const reloaded = [];
|
|
280
|
+
for (const match of matches) {
|
|
281
|
+
const id = String(match.entity.id ?? "");
|
|
282
|
+
const type = match.entity.type;
|
|
283
|
+
const [full] = id
|
|
284
|
+
? await loadEntities(prolog, {
|
|
285
|
+
id,
|
|
286
|
+
...(typeof type === "string" ? { type } : {}),
|
|
287
|
+
})
|
|
288
|
+
: [];
|
|
289
|
+
reloaded.push(full ? { ...match, entity: full } : match);
|
|
290
|
+
}
|
|
291
|
+
return reloaded;
|
|
292
|
+
}
|
|
86
293
|
// implements REQ-002
|
|
87
294
|
export function dedupeEntities(entities) {
|
|
88
295
|
const seen = new Set();
|
|
@@ -25,6 +25,7 @@ export type SearchInput = {
|
|
|
25
25
|
readonly semanticFacets?: IntentSearchFacets;
|
|
26
26
|
readonly sourceLocations?: readonly SourceLocation[];
|
|
27
27
|
readonly minScore?: number;
|
|
28
|
+
readonly fields?: "summary" | "full";
|
|
28
29
|
};
|
|
29
30
|
export type SearchPayload = {
|
|
30
31
|
readonly results: readonly (SearchMatch | IntentSearchMatch)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAC;AAG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AAC,CAAC,CAAC;KACzD,CAAC;CACH,CAAC;AAqBF,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA2CxC;AAmDD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAiGzC;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CA4OzC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { compilerFingerprintReason } from "../../commands/sync/cache.js";
|
|
1
2
|
import { EngineClient } from "../../engine.js";
|
|
2
3
|
import { executeIntentSearch, validateIntentSearchInput, } from "../../intent-search.js";
|
|
3
4
|
import { classifyActivation } from "../../operations/bootstrap/activation.js";
|
|
4
5
|
import { rankEntities } from "../../search-ranking.js";
|
|
5
6
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
6
|
-
import { branchStoreReason,
|
|
7
|
-
import {
|
|
7
|
+
import { branchStoreReason, inspectBranchStore, storeLockJournalReason, } from "../../utils/branch-store.js";
|
|
8
|
+
import { loadSearchCandidates, paginateResults, queryEntitiesViaQuery, reloadFullEntities, validateEntityType, } from "./discovery-entities.js";
|
|
8
9
|
import { buildActionsFromStatus, readMigrationConfigStatus, } from "./migration-plan.js";
|
|
9
10
|
import { OperationJsonDecodeError, runOperationJsonQuery, } from "./prolog-json.js";
|
|
10
11
|
import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
|
|
@@ -28,42 +29,28 @@ export async function executeQuery(input, context) {
|
|
|
28
29
|
// implements REQ-kibi-operation-interface-parity
|
|
29
30
|
const { type, id, tags, sourceFile, limit = 100, offset = 0 } = input;
|
|
30
31
|
try {
|
|
32
|
+
validateEntityType(type);
|
|
31
33
|
const prolog = requireProlog(context);
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
...(type !== undefined ? { type } : {}),
|
|
35
|
-
...(id !== undefined ? { id } : {}),
|
|
36
|
-
...(tags !== undefined ? { tags } : {}),
|
|
37
|
-
...(sourceFile !== undefined ? { sourceFile } : {}),
|
|
38
|
-
limit,
|
|
39
|
-
offset,
|
|
40
|
-
})
|
|
41
|
-
: null;
|
|
42
|
-
if (indexedPage !== null) {
|
|
43
|
-
const paginated = indexedPage.entities;
|
|
44
|
-
const text = indexedPage.count === 0
|
|
45
|
-
? `No entities found${type ? ` of type '${type}'` : ""}.`
|
|
46
|
-
: `Found ${indexedPage.count} entities${type ? ` of type '${type}'` : ""}. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
|
|
47
|
-
.map((entity) => {
|
|
48
|
-
const entityId = String(entity.id ?? "").replace(/^file:\/\/.*\//, "");
|
|
49
|
-
return `${entityId} (${String(entity.title ?? "")}, status=${String(entity.status ?? "")})`;
|
|
50
|
-
})
|
|
51
|
-
.join(", ")}`;
|
|
52
|
-
return {
|
|
53
|
-
content: [{ type: "text", text }],
|
|
54
|
-
structuredContent: { entities: paginated, count: indexedPage.count },
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const entities = await loadEntities(requireProlog(context), {
|
|
34
|
+
const signal = context.signal;
|
|
35
|
+
const pageInput = {
|
|
58
36
|
...(type !== undefined ? { type } : {}),
|
|
59
37
|
...(id !== undefined ? { id } : {}),
|
|
60
38
|
...(tags !== undefined ? { tags } : {}),
|
|
61
39
|
...(sourceFile !== undefined ? { sourceFile } : {}),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
40
|
+
limit,
|
|
41
|
+
offset,
|
|
42
|
+
};
|
|
43
|
+
// Both paths return one bounded page plus the total count. Ports without
|
|
44
|
+
// the engine method page kb_query_entities through `query` instead of
|
|
45
|
+
// materializing every matching entity (receipt histories make an
|
|
46
|
+
// all-tests answer exceed the bounded engine output).
|
|
47
|
+
const indexedPage = prolog.queryEntities
|
|
48
|
+
? await prolog.queryEntities(pageInput, signal)
|
|
49
|
+
: await queryEntitiesViaQuery(prolog, pageInput, signal);
|
|
50
|
+
const paginated = indexedPage.entities;
|
|
51
|
+
const text = indexedPage.count === 0
|
|
65
52
|
? `No entities found${type ? ` of type '${type}'` : ""}.`
|
|
66
|
-
: `Found ${
|
|
53
|
+
: `Found ${indexedPage.count} entities${type ? ` of type '${type}'` : ""}. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
|
|
67
54
|
.map((entity) => {
|
|
68
55
|
const entityId = String(entity.id ?? "").replace(/^file:\/\/.*\//, "");
|
|
69
56
|
return `${entityId} (${String(entity.title ?? "")}, status=${String(entity.status ?? "")})`;
|
|
@@ -71,7 +58,7 @@ export async function executeQuery(input, context) {
|
|
|
71
58
|
.join(", ")}`;
|
|
72
59
|
return {
|
|
73
60
|
content: [{ type: "text", text }],
|
|
74
|
-
structuredContent: { entities: paginated, count:
|
|
61
|
+
structuredContent: { entities: paginated, count: indexedPage.count },
|
|
75
62
|
};
|
|
76
63
|
}
|
|
77
64
|
catch (error) {
|
|
@@ -79,9 +66,48 @@ export async function executeQuery(input, context) {
|
|
|
79
66
|
throw new Error(`Query execution failed: ${message}`);
|
|
80
67
|
}
|
|
81
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Identifying metadata a caller needs to decide which hits to open.
|
|
71
|
+
*
|
|
72
|
+
* Search is a discovery step, so returning complete entity bodies for every
|
|
73
|
+
* hit spends a large share of an agent's context before it has chosen
|
|
74
|
+
* anything. Full bodies stay available through `fields: "full"` or a follow-up
|
|
75
|
+
* kb_query for the exact ids.
|
|
76
|
+
*/
|
|
77
|
+
const SUMMARY_ENTITY_FIELDS = [
|
|
78
|
+
"id",
|
|
79
|
+
"type",
|
|
80
|
+
"title",
|
|
81
|
+
"status",
|
|
82
|
+
"priority",
|
|
83
|
+
"tags",
|
|
84
|
+
"source",
|
|
85
|
+
"sourceFile",
|
|
86
|
+
"updated_at",
|
|
87
|
+
];
|
|
88
|
+
function summarizeMatch(match) {
|
|
89
|
+
const entity = match.entity;
|
|
90
|
+
if (entity === null || typeof entity !== "object" || Array.isArray(entity)) {
|
|
91
|
+
return match;
|
|
92
|
+
}
|
|
93
|
+
const row = entity;
|
|
94
|
+
const summary = {};
|
|
95
|
+
for (const field of SUMMARY_ENTITY_FIELDS) {
|
|
96
|
+
if (row[field] !== undefined)
|
|
97
|
+
summary[field] = row[field];
|
|
98
|
+
}
|
|
99
|
+
return { ...match, entity: summary };
|
|
100
|
+
}
|
|
101
|
+
// Candidates are projected rows, so `fields: "full"` reloads the final page's
|
|
102
|
+
// complete entities by id (one bounded query each).
|
|
103
|
+
async function projectMatches(prolog, matches, fields) {
|
|
104
|
+
return fields === "full"
|
|
105
|
+
? reloadFullEntities(prolog, matches)
|
|
106
|
+
: matches.map(summarizeMatch);
|
|
107
|
+
}
|
|
82
108
|
export async function executeSearch(input, context) {
|
|
83
109
|
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
|
84
|
-
const { query, type, limit = 20, offset = 0, rankingMode = "legacy", semanticFacets, sourceLocations, minScore, } = input;
|
|
110
|
+
const { query, type, limit = 20, offset = 0, rankingMode = "legacy", semanticFacets, sourceLocations, minScore, fields = "summary", } = input;
|
|
85
111
|
const trimmedQuery = query.trim();
|
|
86
112
|
if (!trimmedQuery) {
|
|
87
113
|
throw new Error("Search execution failed: query must be a non-empty string");
|
|
@@ -111,25 +137,19 @@ export async function executeSearch(input, context) {
|
|
|
111
137
|
return {
|
|
112
138
|
content: [{ type: "text", text }],
|
|
113
139
|
structuredContent: {
|
|
114
|
-
results: paginated,
|
|
140
|
+
results: await projectMatches(prolog, paginated, fields),
|
|
115
141
|
count: intentResult.matches.length,
|
|
116
142
|
queryAnalysis: intentResult.analysis,
|
|
117
143
|
},
|
|
118
144
|
};
|
|
119
145
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
: null;
|
|
128
|
-
const entities = indexedCandidates
|
|
129
|
-
? [...indexedCandidates.entities]
|
|
130
|
-
: await loadEntities(prolog, {
|
|
131
|
-
...(type !== undefined ? { type } : {}),
|
|
132
|
-
});
|
|
146
|
+
// Candidates are projected rows (no receipt histories or other large
|
|
147
|
+
// structured properties); ports without the engine method run the same
|
|
148
|
+
// bounded Prolog search through `query`.
|
|
149
|
+
const entities = await loadSearchCandidates(prolog, {
|
|
150
|
+
query: trimmedQuery,
|
|
151
|
+
...(type !== undefined ? { type } : {}),
|
|
152
|
+
}, context.signal);
|
|
133
153
|
const matches = await rankEntities(entities, trimmedQuery, context.workspaceRoot);
|
|
134
154
|
const paginated = paginateResults(matches, limit, offset);
|
|
135
155
|
const text = matches.length === 0
|
|
@@ -139,7 +159,10 @@ export async function executeSearch(input, context) {
|
|
|
139
159
|
.join(", ")}`;
|
|
140
160
|
return {
|
|
141
161
|
content: [{ type: "text", text }],
|
|
142
|
-
structuredContent: {
|
|
162
|
+
structuredContent: {
|
|
163
|
+
results: await projectMatches(prolog, paginated, fields),
|
|
164
|
+
count: matches.length,
|
|
165
|
+
},
|
|
143
166
|
};
|
|
144
167
|
}
|
|
145
168
|
catch (error) {
|
|
@@ -180,16 +203,22 @@ export async function executeStatus(_input, context) {
|
|
|
180
203
|
}
|
|
181
204
|
else
|
|
182
205
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
206
|
+
// Prefer an injected or session-backed engine so MCP status shares the
|
|
207
|
+
// same client as discovery tools. Only spawn an owned fallback when no
|
|
208
|
+
// host session is available (CLI status without a live runtime port).
|
|
209
|
+
let prolog = context.prolog;
|
|
210
|
+
if (!prolog && context.ensureProlog) {
|
|
211
|
+
prolog = await context.ensureProlog();
|
|
212
|
+
}
|
|
213
|
+
if (!prolog) {
|
|
214
|
+
ownedEngine = new EngineClient({
|
|
215
|
+
workspaceRoot: context.workspaceRoot,
|
|
216
|
+
branch: attachment.kbBranch,
|
|
217
|
+
timeout: 15_000,
|
|
218
|
+
});
|
|
219
|
+
prolog = ownedEngine;
|
|
220
|
+
}
|
|
221
|
+
payload = await runOperationJsonQuery(prolog, "status.pl", "status:kb_status_json(JsonString)", "Status execution", context.signal);
|
|
193
222
|
if (!isStatusPayload(payload)) {
|
|
194
223
|
throw new Error("Status execution query returned an invalid payload");
|
|
195
224
|
}
|
|
@@ -227,6 +256,7 @@ export async function executeStatus(_input, context) {
|
|
|
227
256
|
const existingReasons = payload.staleReasons ?? [];
|
|
228
257
|
const storeReason = branchStoreReason(store);
|
|
229
258
|
const lockReason = storeLockJournalReason(store.path);
|
|
259
|
+
const compilerReason = compilerFingerprintReason(store.path);
|
|
230
260
|
const engineReason = engineStatus
|
|
231
261
|
? {
|
|
232
262
|
code: engineStatus.errorCode ?? "engine_status_unavailable",
|
|
@@ -244,10 +274,14 @@ export async function executeStatus(_input, context) {
|
|
|
244
274
|
...existingReasons,
|
|
245
275
|
...(storeReason ? [storeReason] : []),
|
|
246
276
|
...(lockReason ? [lockReason] : []),
|
|
277
|
+
...(compilerReason ? [compilerReason] : []),
|
|
247
278
|
...(engineReason ? [engineReason] : []),
|
|
248
279
|
].sort((left, right) => String(left.path ?? "").localeCompare(String(right.path ?? "")));
|
|
249
280
|
const enrichedPayload = {
|
|
250
281
|
...payload,
|
|
282
|
+
// Source hashes can all match while the compilation itself is lossy, so
|
|
283
|
+
// a compiler contract change alone makes the store stale.
|
|
284
|
+
...(compilerReason ? { syncState: "stale", dirty: true } : {}),
|
|
251
285
|
branchAttachment: attachment,
|
|
252
286
|
branchStore: store,
|
|
253
287
|
...(engineStatus ? { engineStatus } : {}),
|
|
@@ -70,6 +70,8 @@ export declare function compareReadyActionIds(left: string, right: string, byId:
|
|
|
70
70
|
export declare function buildMigrationPlan(input?: PlanInput): MigrationPlan;
|
|
71
71
|
export declare function mergeMigrationPlans(plans: readonly MigrationPlan[]): MigrationPlan;
|
|
72
72
|
export declare function migrationAction(input: Partial<MigrationAction> & Pick<MigrationAction, "id" | "code">): MigrationAction;
|
|
73
|
+
/** Migration code for mechanical predicate namespace/alias repairs. */
|
|
74
|
+
export declare const PREDICATE_SCHEMA_ALIGNMENT_CODE = "predicate_schema_alignment";
|
|
73
75
|
export declare function buildActionsFromCheck(input: {
|
|
74
76
|
violations?: readonly Readonly<Record<string, unknown>>[];
|
|
75
77
|
qualityDiagnostics?: readonly Readonly<Record<string, unknown>>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../../src/public/operations/migration-plan.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,sBAAsB,EAAG,wBAAiC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,SAAS,CAAC;AACvD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC1C,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEP,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,EAAE,E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