kibi-cli 2.3.0 → 2.5.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-json-command.d.ts +6 -0
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +39 -11
- package/dist/cli-operation-loader.d.ts.map +1 -1
- package/dist/cli-operation-loader.js +7 -0
- package/dist/cli-operation-metadata.d.ts +13 -5
- package/dist/cli-operation-metadata.d.ts.map +1 -1
- package/dist/cli-operation-metadata.js +15 -5
- package/dist/cli-protocol.d.ts +14 -0
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +31 -2
- package/dist/cli-register-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +7 -0
- package/dist/cli-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +13 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +11 -2
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +8 -2
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +4 -2
- package/dist/commands/gc.d.ts.map +1 -1
- package/dist/commands/gc.js +7 -0
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +0 -1
- package/dist/commands/merge-driver.d.ts +31 -0
- package/dist/commands/merge-driver.d.ts.map +1 -0
- package/dist/commands/merge-driver.js +268 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +281 -14
- package/dist/commands/proof-compact.d.ts +9 -0
- package/dist/commands/proof-compact.d.ts.map +1 -0
- package/dist/commands/proof-compact.js +58 -0
- package/dist/commands/prove.d.ts +38 -0
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +222 -47
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +61 -16
- package/dist/commands/sync.d.ts +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +42 -16
- package/dist/diagnostics.js +1 -1
- package/dist/engine-limits.d.ts +74 -0
- package/dist/engine-limits.d.ts.map +1 -0
- package/dist/engine-limits.js +201 -0
- package/dist/engine.d.ts +10 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +57 -9
- package/dist/extractors/manifest.d.ts +8 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +34 -5
- package/dist/extractors/markdown.d.ts +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +57 -0
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +2 -0
- package/dist/intent-search.d.ts +4 -1
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +186 -33
- package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidate-helpers.js +8 -1
- package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidates.js +55 -39
- package/dist/operations/bootstrap/discovery.js +1 -1
- package/dist/operations/bootstrap/generate.d.ts +2 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +107 -37
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +3 -0
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +7 -1
- package/dist/operations/bootstrap/intent-claims.d.ts +17 -0
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -0
- package/dist/operations/bootstrap/intent-claims.js +103 -0
- package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
- package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/markdown-candidates.js +32 -10
- package/dist/operations/bootstrap/presentation.d.ts +2 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +66 -3
- package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
- package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/requirement-claims.js +13 -1
- package/dist/operations/bootstrap/types.d.ts +28 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/bootstrap/types.js +16 -0
- package/dist/operations/bootstrap/validation.d.ts +4 -0
- package/dist/operations/bootstrap/validation.d.ts.map +1 -0
- package/dist/operations/bootstrap/validation.js +20 -0
- package/dist/operations/migration/inventory-rederive.d.ts +81 -0
- package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
- package/dist/operations/migration/inventory-rederive.js +484 -0
- package/dist/operations/migration/kb-sources.d.ts +53 -0
- package/dist/operations/migration/kb-sources.d.ts.map +1 -0
- package/dist/operations/migration/kb-sources.js +233 -0
- package/dist/operations/migration/origin-backfill.d.ts +39 -0
- package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
- package/dist/operations/migration/origin-backfill.js +164 -0
- package/dist/operations/migration/polarity-values.d.ts +10 -0
- package/dist/operations/migration/polarity-values.d.ts.map +1 -0
- package/dist/operations/migration/polarity-values.js +60 -0
- package/dist/operations/migration/schema6.d.ts +59 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -0
- package/dist/operations/migration/schema6.js +379 -0
- package/dist/operations/migration/source-paths.d.ts +131 -0
- package/dist/operations/migration/source-paths.d.ts.map +1 -0
- package/dist/operations/migration/source-paths.js +308 -0
- package/dist/operations/migration/superseded-closure.d.ts +54 -0
- package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
- package/dist/operations/migration/superseded-closure.js +187 -0
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +3 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +225 -67
- package/dist/operations/mutation/contradictions.d.ts +16 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +32 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +15 -7
- package/dist/operations/mutation/origin.d.ts +21 -0
- package/dist/operations/mutation/origin.d.ts.map +1 -0
- package/dist/operations/mutation/origin.js +78 -0
- package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
- package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
- package/dist/operations/mutation/plan-apply-journal.js +613 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
- package/dist/operations/mutation/relationships.d.ts +5 -5
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +31 -11
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +3 -1
- 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 +7 -1
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +4 -1
- package/dist/operations/mutation/types.d.ts +14 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +30 -3
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +105 -35
- package/dist/operations/mutation/validate-upsert.d.ts +6 -0
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +34 -30
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +751 -144
- package/dist/operations/planning/compile-intent.d.ts +34 -1
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +314 -98
- package/dist/operations/proof/code-scope.d.ts +28 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +72 -0
- package/dist/operations/proof/compact-receipts.d.ts +49 -0
- package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
- package/dist/operations/proof/compact-receipts.js +160 -0
- package/dist/operations/proof/ingest-proof.d.ts +2 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +44 -23
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +5 -9
- package/dist/operations/proof/receipt-compaction.d.ts +48 -0
- package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
- package/dist/operations/proof/receipt-compaction.js +121 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +11 -1
- package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
- package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
- package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -1
- package/dist/prolog.d.ts +9 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +56 -10
- package/dist/proof/command-test-report.d.ts +74 -0
- package/dist/proof/command-test-report.d.ts.map +1 -0
- package/dist/proof/command-test-report.js +206 -0
- package/dist/public/branch-resolver.d.ts +1 -0
- package/dist/public/branch-resolver.d.ts.map +1 -1
- package/dist/public/branch-resolver.js +1 -0
- package/dist/public/diagnostic-usage.d.ts +14 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +55 -1
- package/dist/public/entity-origin.d.ts +69 -0
- package/dist/public/entity-origin.d.ts.map +1 -0
- package/dist/public/entity-origin.js +142 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +1 -0
- package/dist/public/impact/requirement-quality.js +1 -1
- package/dist/public/operations/catalog.d.ts +203 -20
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/catalog.js +3 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +8 -0
- package/dist/public/operations/contracts.d.ts +0 -5
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +63 -14
- package/dist/public/operations/discovery-entities.d.ts +15 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +59 -0
- package/dist/public/operations/discovery-executors.d.ts +6 -1
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +65 -6
- package/dist/public/operations/index.d.ts +1 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +1 -0
- package/dist/public/operations/migration-plan.d.ts +5 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +26 -1
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +24 -3
- package/dist/public/operations/origin-review.d.ts +51 -0
- package/dist/public/operations/origin-review.d.ts.map +1 -0
- package/dist/public/operations/origin-review.js +307 -0
- package/dist/public/operations/predicate-schema-conformance.js +1 -1
- package/dist/public/operations/repair-plan.d.ts.map +1 -1
- package/dist/public/operations/repair-plan.js +4 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +17 -5
- package/dist/public/operations/runtime-types.d.ts +9 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/schema6-check-actions.d.ts +127 -0
- package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
- package/dist/public/operations/schema6-check-actions.js +575 -0
- package/dist/public/operations/source-path-dangling.d.ts +17 -0
- package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
- package/dist/public/operations/source-path-dangling.js +66 -0
- package/dist/public/operations/specs/bootstrap.d.ts +73 -1
- package/dist/public/operations/specs/bootstrap.d.ts.map +1 -1
- package/dist/public/operations/specs/bootstrap.js +66 -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 +15 -1
- package/dist/public/operations/specs/check.d.ts +2 -2
- package/dist/public/operations/specs/check.js +1 -1
- package/dist/public/operations/specs/composite.d.ts +351 -0
- package/dist/public/operations/specs/composite.d.ts.map +1 -0
- package/dist/public/operations/specs/composite.js +96 -0
- package/dist/public/operations/specs/discovery.d.ts +8 -3
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +8 -3
- package/dist/public/operations/specs/modeling.d.ts +2 -2
- package/dist/public/operations/specs/modeling.js +2 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +43 -7
- package/dist/public/operations/specs/mutation.d.ts +1 -1
- package/dist/public/operations/specs/mutation.js +1 -1
- package/dist/public/operations/specs/planning.d.ts +2 -2
- package/dist/public/operations/specs/planning.js +4 -4
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +13 -26
- package/dist/public/operations/specs/upsert.d.ts +79 -9
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +6 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +3 -1
- package/dist/public/operations/types.d.ts +1 -1
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/proof-receipt.d.ts +1 -0
- package/dist/public/proof-receipt.d.ts.map +1 -1
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +52 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +2 -0
- package/dist/public/skills/kibi-bootstrap/SKILL.md +52 -11
- package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
- package/dist/public/skills/kibi-usage/SKILL.md +82 -18
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
- package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
- package/dist/public/skills/kibi-usage/resources/operation-access.md +29 -1
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
- package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
- package/dist/public/telemetry-acceptance.d.ts +64 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +143 -7
- package/dist/public/telemetry-remediation.d.ts.map +1 -1
- package/dist/public/telemetry-remediation.js +26 -10
- package/dist/relationships/shards.d.ts +13 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +54 -28
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +44 -3
- package/dist/runtime/detached-snapshot.d.ts +38 -0
- package/dist/runtime/detached-snapshot.d.ts.map +1 -0
- package/dist/runtime/detached-snapshot.js +92 -0
- package/dist/schemas/entity.schema.json +122 -0
- package/dist/search-answer.d.ts +157 -0
- package/dist/search-answer.d.ts.map +1 -0
- package/dist/search-answer.js +846 -0
- package/dist/traceability/impact-knowledge.d.ts.map +1 -1
- package/dist/traceability/impact-knowledge.js +7 -0
- package/dist/traceability/symbol-extract.js +3 -3
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +12 -0
- package/dist/types/entities.d.ts +13 -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/branch-resolver.d.ts +37 -1
- package/dist/utils/branch-resolver.d.ts.map +1 -1
- package/dist/utils/branch-resolver.js +130 -3
- package/dist/utils/repo-relative-path.d.ts +18 -0
- package/dist/utils/repo-relative-path.d.ts.map +1 -0
- package/dist/utils/repo-relative-path.js +58 -0
- package/dist/utils/rule-registry.generated.d.ts +75 -3
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +89 -3
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.d.ts.map +1 -1
- package/dist/utils/schema-version.js +4 -3
- package/dist/utils/strict-modeling.d.ts +1 -1
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +23 -3
- package/package.json +3 -3
- package/schema/entities.pl +22 -0
- package/schema/relationships.pl +14 -0
- package/schema/validation.pl +45 -1
- package/src/public/branch-resolver.ts +1 -0
- package/src/public/diagnostic-usage.ts +59 -1
- package/src/public/entity-origin.ts +175 -0
- package/src/public/impact/full-kb-quality.ts +1 -0
- package/src/public/impact/requirement-quality.ts +1 -1
- package/src/public/operations/catalog.ts +3 -0
- package/src/public/operations/check-executor.ts +15 -0
- package/src/public/operations/contracts.ts +75 -15
- package/src/public/operations/discovery-entities.ts +74 -0
- package/src/public/operations/discovery-executors.ts +88 -10
- package/src/public/operations/index.ts +1 -0
- package/src/public/operations/migration-plan.ts +30 -1
- package/src/public/operations/node-ports.ts +24 -3
- package/src/public/operations/origin-review.ts +375 -0
- package/src/public/operations/predicate-schema-conformance.ts +1 -1
- package/src/public/operations/repair-plan.ts +4 -0
- package/src/public/operations/result-envelope.ts +18 -6
- package/src/public/operations/runtime-types.ts +9 -0
- package/src/public/operations/schema6-check-actions.ts +699 -0
- package/src/public/operations/source-path-dangling.ts +81 -0
- package/src/public/operations/specs/bootstrap.ts +78 -4
- package/src/public/operations/specs/check-rules.generated.ts +15 -1
- package/src/public/operations/specs/check.ts +1 -1
- package/src/public/operations/specs/composite.ts +141 -0
- package/src/public/operations/specs/discovery.ts +9 -3
- package/src/public/operations/specs/modeling.ts +2 -2
- package/src/public/operations/specs/mutation-schemas.ts +49 -7
- package/src/public/operations/specs/mutation.ts +1 -1
- package/src/public/operations/specs/planning.ts +4 -4
- package/src/public/operations/specs/reporting.ts +13 -38
- package/src/public/operations/specs/upsert.ts +7 -1
- package/src/public/operations/symbol-repair-plan.ts +3 -1
- package/src/public/operations/types.ts +2 -0
- package/src/public/proof-receipt.ts +1 -0
- package/src/public/schemas/entity.ts +57 -0
- package/src/public/schemas/relationship.ts +2 -0
- package/src/public/skills/kibi-bootstrap/SKILL.md +52 -11
- package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
- package/src/public/skills/kibi-usage/SKILL.md +82 -18
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
- package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
- package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
- package/src/public/skills/kibi-usage/resources/operation-access.md +29 -1
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
- package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
- package/src/public/telemetry-acceptance-types.d.ts +4 -1
- package/src/public/telemetry-acceptance.ts +210 -7
- package/src/public/telemetry-remediation.ts +39 -10
- package/src/schemas/entity.schema.json +122 -0
- package/src/schemas/relationship.schema.json +2 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Entity provenance (`origin`): who authored an entity and on what authority.
|
|
21
|
+
*
|
|
22
|
+
* `origin` is one structured property shared by every authored entity type.
|
|
23
|
+
* It is a YAML mapping in Markdown frontmatter and symbol manifests, a JSON
|
|
24
|
+
* object at the public operation boundary, and a JSON string inside Prolog
|
|
25
|
+
* (like `proof_contract`).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** How an entity entered the knowledge base. */
|
|
29
|
+
// implements REQ-kibi-entity-origin
|
|
30
|
+
export const ENTITY_ORIGIN_KINDS = [
|
|
31
|
+
"human",
|
|
32
|
+
"agent",
|
|
33
|
+
"migration",
|
|
34
|
+
"import",
|
|
35
|
+
] as const;
|
|
36
|
+
|
|
37
|
+
// implements REQ-kibi-entity-origin
|
|
38
|
+
export type EntityOriginKind = (typeof ENTITY_ORIGIN_KINDS)[number];
|
|
39
|
+
|
|
40
|
+
// implements REQ-kibi-entity-origin
|
|
41
|
+
export type EntityOrigin = {
|
|
42
|
+
/** human | agent | migration | import */
|
|
43
|
+
kind: EntityOriginKind;
|
|
44
|
+
/** Source reference: URL, document path, ticket, commit or conversation id. */
|
|
45
|
+
ref?: string;
|
|
46
|
+
/** The person who approved the authored content. */
|
|
47
|
+
approved_by?: string;
|
|
48
|
+
/** ISO-8601 time the provenance was recorded. */
|
|
49
|
+
recorded_at?: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** `ref` recorded on entities backfilled by the schema v5 -> v6 migration. */
|
|
53
|
+
// implements REQ-kibi-entity-origin
|
|
54
|
+
export const SCHEMA6_MIGRATION_ORIGIN_REF = "kibi migrate v5->v6";
|
|
55
|
+
|
|
56
|
+
const ISO_TIMESTAMP_PATTERN =
|
|
57
|
+
"^\\d{4}-\\d{2}-\\d{2}(?:[T ]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:?\\d{2})?)?$";
|
|
58
|
+
|
|
59
|
+
/** JSON Schema shared by the entity schema and the kb_upsert input schema. */
|
|
60
|
+
// implements REQ-kibi-entity-origin
|
|
61
|
+
export const ENTITY_ORIGIN_SCHEMA = {
|
|
62
|
+
type: "object",
|
|
63
|
+
required: ["kind"],
|
|
64
|
+
properties: {
|
|
65
|
+
kind: {
|
|
66
|
+
type: "string",
|
|
67
|
+
enum: [...ENTITY_ORIGIN_KINDS],
|
|
68
|
+
description:
|
|
69
|
+
"Who authored the entity: human, agent, migration (backfilled by kibi migrate) or import.",
|
|
70
|
+
},
|
|
71
|
+
ref: {
|
|
72
|
+
type: "string",
|
|
73
|
+
minLength: 1,
|
|
74
|
+
pattern: "\\S",
|
|
75
|
+
description:
|
|
76
|
+
"Source reference for the authored content: URL, document path, ticket, commit or conversation id.",
|
|
77
|
+
},
|
|
78
|
+
approved_by: {
|
|
79
|
+
type: "string",
|
|
80
|
+
minLength: 1,
|
|
81
|
+
pattern: "\\S",
|
|
82
|
+
description:
|
|
83
|
+
"The person who reviewed and approved this entity's content. Distinct from the requirement-level approved_by of an exception.",
|
|
84
|
+
},
|
|
85
|
+
recorded_at: {
|
|
86
|
+
type: "string",
|
|
87
|
+
pattern: ISO_TIMESTAMP_PATTERN,
|
|
88
|
+
description: "ISO-8601 time the provenance was recorded.",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
94
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
95
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function nonEmptyText(value: unknown): string | undefined {
|
|
99
|
+
return typeof value === "string" && value.trim() !== ""
|
|
100
|
+
? value.trim()
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Normalize an authored origin mapping. YAML parsers turn an unquoted
|
|
106
|
+
* `recorded_at` into a Date; it is stored as its ISO-8601 string. Returns the
|
|
107
|
+
* reason when the mapping is not a valid origin.
|
|
108
|
+
*/
|
|
109
|
+
// implements REQ-kibi-entity-origin, REQ-007
|
|
110
|
+
export function normalizeEntityOrigin(
|
|
111
|
+
value: unknown,
|
|
112
|
+
): { origin: EntityOrigin } | { error: string } {
|
|
113
|
+
if (!isRecord(value)) {
|
|
114
|
+
return { error: "origin must be a mapping with at least a kind" };
|
|
115
|
+
}
|
|
116
|
+
const allowed = new Set(["kind", "ref", "approved_by", "recorded_at"]);
|
|
117
|
+
const unknown = Object.keys(value).filter((key) => !allowed.has(key));
|
|
118
|
+
if (unknown.length > 0) {
|
|
119
|
+
return {
|
|
120
|
+
error: `origin has unknown field(s) ${unknown.join(", ")}; allowed: kind, ref, approved_by, recorded_at`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const kind = value.kind;
|
|
124
|
+
if (
|
|
125
|
+
typeof kind !== "string" ||
|
|
126
|
+
!(ENTITY_ORIGIN_KINDS as readonly string[]).includes(kind)
|
|
127
|
+
) {
|
|
128
|
+
return {
|
|
129
|
+
error: `origin.kind must be one of ${ENTITY_ORIGIN_KINDS.join(", ")}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const origin: EntityOrigin = { kind: kind as EntityOriginKind };
|
|
133
|
+
for (const field of ["ref", "approved_by"] as const) {
|
|
134
|
+
if (value[field] === undefined) continue;
|
|
135
|
+
const text = nonEmptyText(value[field]);
|
|
136
|
+
if (text === undefined) {
|
|
137
|
+
return { error: `origin.${field} must be a non-empty string` };
|
|
138
|
+
}
|
|
139
|
+
origin[field] = text;
|
|
140
|
+
}
|
|
141
|
+
if (value.recorded_at !== undefined) {
|
|
142
|
+
const recordedAt =
|
|
143
|
+
value.recorded_at instanceof Date
|
|
144
|
+
? Number.isNaN(value.recorded_at.getTime())
|
|
145
|
+
? undefined
|
|
146
|
+
: value.recorded_at.toISOString()
|
|
147
|
+
: nonEmptyText(value.recorded_at);
|
|
148
|
+
if (
|
|
149
|
+
recordedAt === undefined ||
|
|
150
|
+
!new RegExp(ISO_TIMESTAMP_PATTERN).test(recordedAt)
|
|
151
|
+
) {
|
|
152
|
+
return { error: "origin.recorded_at must be an ISO-8601 timestamp" };
|
|
153
|
+
}
|
|
154
|
+
origin.recorded_at = recordedAt;
|
|
155
|
+
}
|
|
156
|
+
return { origin };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Read an origin from a compiled entity row: an object at the public
|
|
161
|
+
* boundary, or the JSON string Prolog stores. Malformed values read as absent.
|
|
162
|
+
*/
|
|
163
|
+
// implements REQ-kibi-entity-origin
|
|
164
|
+
export function readEntityOrigin(value: unknown): EntityOrigin | null {
|
|
165
|
+
let candidate = value;
|
|
166
|
+
if (typeof candidate === "string") {
|
|
167
|
+
try {
|
|
168
|
+
candidate = JSON.parse(candidate) as unknown;
|
|
169
|
+
} catch {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const normalized = normalizeEntityOrigin(candidate);
|
|
174
|
+
return "origin" in normalized ? normalized.origin : null;
|
|
175
|
+
}
|
|
@@ -242,7 +242,7 @@ function createLogicalCoverageDiagnostics(
|
|
|
242
242
|
docs: ["docs/modeling-cheatsheet.md", "docs/error-reference.md"],
|
|
243
243
|
message: `Current requirement ${result.entity.id} has no atomic logic_claims manifest, so prose and existing fact links cannot prove complete logical coverage.`,
|
|
244
244
|
suggestion:
|
|
245
|
-
"Call
|
|
245
|
+
"Call kb_model with mode analyze on the complete requirement prose and atomic clauses, ground each returned claim key through kb_model (mode requirement or predicates), and persist all keys in logic_claims.",
|
|
246
246
|
evidence: {
|
|
247
247
|
strictRelationshipTypes: relationshipTypes,
|
|
248
248
|
},
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "./contracts.js";
|
|
6
6
|
import { planBootstrapSpec } from "./specs/bootstrap.js";
|
|
7
7
|
import { checkSpec } from "./specs/check.js";
|
|
8
|
+
import { modelSpec, skillsSpec } from "./specs/composite.js";
|
|
8
9
|
import { querySpec, searchSpec, statusSpec } from "./specs/discovery.js";
|
|
9
10
|
import { prepareImpactReviewSpec } from "./specs/impact-review-preparation.js";
|
|
10
11
|
import {
|
|
@@ -36,6 +37,7 @@ export const OPERATION_CATALOG = [
|
|
|
36
37
|
skillsListSpec,
|
|
37
38
|
skillsLoadSpec,
|
|
38
39
|
skillsReadSpec,
|
|
40
|
+
skillsSpec,
|
|
39
41
|
querySpec,
|
|
40
42
|
searchSpec,
|
|
41
43
|
statusSpec,
|
|
@@ -45,6 +47,7 @@ export const OPERATION_CATALOG = [
|
|
|
45
47
|
semanticAdvisorSpec,
|
|
46
48
|
modelRequirementSpec,
|
|
47
49
|
suggestPredicatesSpec,
|
|
50
|
+
modelSpec,
|
|
48
51
|
planBootstrapSpec,
|
|
49
52
|
validateUpsertSpec,
|
|
50
53
|
upsertSpec,
|
|
@@ -39,8 +39,13 @@ import {
|
|
|
39
39
|
buildMigrationPlan,
|
|
40
40
|
mergeMigrationPlans,
|
|
41
41
|
} from "./migration-plan.js";
|
|
42
|
+
import { collectOriginReviewViolations } from "./origin-review.js";
|
|
42
43
|
import { collectPredicateSchemaConformanceViolations } from "./predicate-schema-conformance.js";
|
|
43
44
|
import type { OperationContext, PrologPort } from "./runtime-types.js";
|
|
45
|
+
import {
|
|
46
|
+
SOURCE_PATH_DANGLING_RULE,
|
|
47
|
+
collectSourcePathDanglingViolations,
|
|
48
|
+
} from "./source-path-dangling.js";
|
|
44
49
|
import { collectSourceRelationshipParityViolations } from "./source-relationship-parity.js";
|
|
45
50
|
import type { OperationResult } from "./types.js";
|
|
46
51
|
import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
|
|
@@ -211,11 +216,21 @@ export async function executeCheck(
|
|
|
211
216
|
)
|
|
212
217
|
? await collectPredicateSchemaConformanceViolations(prolog)
|
|
213
218
|
: [];
|
|
219
|
+
const sourcePathFindings = rulesAllowlist.has(SOURCE_PATH_DANGLING_RULE)
|
|
220
|
+
? collectSourcePathDanglingViolations(workspaceRoot)
|
|
221
|
+
: [];
|
|
222
|
+
const originReviewFindings = await collectOriginReviewViolations(
|
|
223
|
+
prolog,
|
|
224
|
+
rulesAllowlist,
|
|
225
|
+
workspaceRoot,
|
|
226
|
+
);
|
|
214
227
|
const partitioned = partitionCheckFindings([
|
|
215
228
|
...aggregatedFindings,
|
|
216
229
|
...queryPlanViolations,
|
|
217
230
|
...sourceRelationshipParityViolations,
|
|
231
|
+
...sourcePathFindings,
|
|
218
232
|
...predicateConformanceFindings,
|
|
233
|
+
...originReviewFindings,
|
|
219
234
|
]);
|
|
220
235
|
const violations: Violation[] = partitioned.violations;
|
|
221
236
|
|
|
@@ -429,8 +429,8 @@ export function nullableJsonSchema(
|
|
|
429
429
|
* implementations. Every catalog entry therefore has a concrete payload
|
|
430
430
|
* shape, while nested domain records can still evolve independently.
|
|
431
431
|
*/
|
|
432
|
-
|
|
433
|
-
Record<OperationName, OperationJsonSchema>
|
|
432
|
+
const BASE_DATA_SCHEMAS: Readonly<
|
|
433
|
+
Record<Exclude<OperationName, "kb_skills" | "kb_model">, OperationJsonSchema>
|
|
434
434
|
> = {
|
|
435
435
|
kb_skills_list: objectData({ skills: valueArray }, ["skills"]),
|
|
436
436
|
kb_skills_load: objectData({
|
|
@@ -446,7 +446,13 @@ export const OPERATION_DATA_SCHEMAS: Readonly<
|
|
|
446
446
|
"count",
|
|
447
447
|
]),
|
|
448
448
|
kb_search: objectData(
|
|
449
|
-
{
|
|
449
|
+
{
|
|
450
|
+
results: valueArray,
|
|
451
|
+
count: integerValue,
|
|
452
|
+
truncated: booleanValue,
|
|
453
|
+
queryAnalysis: recordValue,
|
|
454
|
+
answer: recordValue,
|
|
455
|
+
},
|
|
450
456
|
["results", "count"],
|
|
451
457
|
),
|
|
452
458
|
kb_status: objectData({
|
|
@@ -601,18 +607,36 @@ export const OPERATION_DATA_SCHEMAS: Readonly<
|
|
|
601
607
|
semanticAdvisor: nullableJsonSchema(recordValue),
|
|
602
608
|
normalizedPreview: nullableJsonSchema(recordValue),
|
|
603
609
|
}),
|
|
604
|
-
kb_upsert:
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
610
|
+
kb_upsert: {
|
|
611
|
+
description:
|
|
612
|
+
"Committed upsert payload, or the validation preview when dryRun:true wrote nothing.",
|
|
613
|
+
anyOf: [
|
|
614
|
+
objectData({
|
|
615
|
+
created: integerValue,
|
|
616
|
+
updated: integerValue,
|
|
617
|
+
relationships_created: integerValue,
|
|
618
|
+
warnings: valueArray,
|
|
619
|
+
semanticAdvisor: recordValue,
|
|
620
|
+
status: stringValue,
|
|
621
|
+
effectFailures: recordArray,
|
|
622
|
+
nextActions: recordArray,
|
|
623
|
+
sourceWrites: recordArray,
|
|
624
|
+
contradictionCheck: recordValue,
|
|
625
|
+
}),
|
|
626
|
+
objectData(
|
|
627
|
+
{
|
|
628
|
+
valid: booleanValue,
|
|
629
|
+
errors: valueArray,
|
|
630
|
+
warnings: valueArray,
|
|
631
|
+
semanticAdvisor: nullableJsonSchema(recordValue),
|
|
632
|
+
normalizedPreview: nullableJsonSchema(recordValue),
|
|
633
|
+
dryRun: { const: true },
|
|
634
|
+
skippedEffects: stringArray,
|
|
635
|
+
},
|
|
636
|
+
["valid", "dryRun", "skippedEffects"],
|
|
637
|
+
),
|
|
638
|
+
],
|
|
639
|
+
},
|
|
616
640
|
kb_delete: objectData({
|
|
617
641
|
deleted: integerValue,
|
|
618
642
|
relationships_deleted: integerValue,
|
|
@@ -722,6 +746,40 @@ export const OPERATION_DATA_SCHEMAS: Readonly<
|
|
|
722
746
|
}),
|
|
723
747
|
};
|
|
724
748
|
|
|
749
|
+
/** A composite operation returns the routed operation's payload plus the
|
|
750
|
+
* selector that chose it. */
|
|
751
|
+
function compositeData(
|
|
752
|
+
selector: "action" | "mode",
|
|
753
|
+
routes: Readonly<Record<string, OperationJsonSchema>>,
|
|
754
|
+
): OperationJsonSchema {
|
|
755
|
+
return {
|
|
756
|
+
anyOf: Object.entries(routes).map(([choice, schema]) => ({
|
|
757
|
+
...schema,
|
|
758
|
+
required: [selector, ...((schema.required as string[]) ?? [])],
|
|
759
|
+
properties: {
|
|
760
|
+
[selector]: { const: choice },
|
|
761
|
+
...(schema.properties as Record<string, OperationJsonSchema>),
|
|
762
|
+
},
|
|
763
|
+
})),
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
export const OPERATION_DATA_SCHEMAS: Readonly<
|
|
768
|
+
Record<OperationName, OperationJsonSchema>
|
|
769
|
+
> = {
|
|
770
|
+
...BASE_DATA_SCHEMAS,
|
|
771
|
+
kb_skills: compositeData("action", {
|
|
772
|
+
list: BASE_DATA_SCHEMAS.kb_skills_list,
|
|
773
|
+
load: BASE_DATA_SCHEMAS.kb_skills_load,
|
|
774
|
+
read: BASE_DATA_SCHEMAS.kb_skills_read,
|
|
775
|
+
}),
|
|
776
|
+
kb_model: compositeData("mode", {
|
|
777
|
+
analyze: BASE_DATA_SCHEMAS.kb_semantic_advisor,
|
|
778
|
+
requirement: BASE_DATA_SCHEMAS.kb_model_requirement,
|
|
779
|
+
predicates: BASE_DATA_SCHEMAS.kb_suggest_predicates,
|
|
780
|
+
}),
|
|
781
|
+
};
|
|
782
|
+
|
|
725
783
|
type EffectOverrides = Readonly<{
|
|
726
784
|
destructive?: boolean;
|
|
727
785
|
retrySafety?: "safe" | "unsafe";
|
|
@@ -737,6 +795,7 @@ const EFFECT_OVERRIDES: Readonly<
|
|
|
737
795
|
kb_skills_list: {},
|
|
738
796
|
kb_skills_load: {},
|
|
739
797
|
kb_skills_read: {},
|
|
798
|
+
kb_skills: {},
|
|
740
799
|
kb_query: {},
|
|
741
800
|
kb_search: {},
|
|
742
801
|
kb_status: {},
|
|
@@ -747,6 +806,7 @@ const EFFECT_OVERRIDES: Readonly<
|
|
|
747
806
|
kb_semantic_advisor: {},
|
|
748
807
|
kb_model_requirement: {},
|
|
749
808
|
kb_suggest_predicates: {},
|
|
809
|
+
kb_model: {},
|
|
750
810
|
kb_plan_bootstrap: {},
|
|
751
811
|
kb_validate_upsert: {},
|
|
752
812
|
kb_upsert: {
|
|
@@ -404,6 +404,80 @@ export async function loadEntityIds(
|
|
|
404
404
|
return parseAtomList(result.bindings.Ids ?? "[]").map(normalizeEntityId);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Properties a projected entity row keeps: what intent ranking, result
|
|
409
|
+
* summaries and the search answer layer read. Large structured properties
|
|
410
|
+
* (receipt histories, proof contracts, semantic inventories, rule IR) are
|
|
411
|
+
* left in the store, as for search candidate rows.
|
|
412
|
+
*/
|
|
413
|
+
// implements REQ-kibi-search-answer-layer-v2
|
|
414
|
+
export const ENTITY_ROW_KEYS = [
|
|
415
|
+
"id",
|
|
416
|
+
"title",
|
|
417
|
+
"status",
|
|
418
|
+
"priority",
|
|
419
|
+
"severity",
|
|
420
|
+
"owner",
|
|
421
|
+
"tags",
|
|
422
|
+
"source",
|
|
423
|
+
"sourceFile",
|
|
424
|
+
"sourceLine",
|
|
425
|
+
"sourceColumn",
|
|
426
|
+
"sourceEndLine",
|
|
427
|
+
"sourceEndColumn",
|
|
428
|
+
"source_line",
|
|
429
|
+
"source_end_line",
|
|
430
|
+
"updated_at",
|
|
431
|
+
"created_at",
|
|
432
|
+
"semantic_text",
|
|
433
|
+
"text_ref",
|
|
434
|
+
"fact_kind",
|
|
435
|
+
"expects",
|
|
436
|
+
"approved_by",
|
|
437
|
+
"approval_ref",
|
|
438
|
+
] as const;
|
|
439
|
+
|
|
440
|
+
/** Upper bound on ids per batched row query, so one answer stays bounded. */
|
|
441
|
+
// implements REQ-kibi-search-answer-layer-v2
|
|
442
|
+
export const ENTITY_ROW_BATCH_LIMIT = 200;
|
|
443
|
+
|
|
444
|
+
// implements REQ-mcp-search-discovery, REQ-kibi-search-answer-layer-v2
|
|
445
|
+
export function entityRowsGoal(
|
|
446
|
+
ids: readonly string[],
|
|
447
|
+
keys: readonly string[] = ENTITY_ROW_KEYS,
|
|
448
|
+
): string {
|
|
449
|
+
const idList = ids.map((id) => `'${escapeAtomContent(id)}'`).join(",");
|
|
450
|
+
const keyList = keys.map((key) => `'${escapeAtomContent(key)}'`).join(",");
|
|
451
|
+
return `findall([Id,Type,Row], (member(Id, [${idList}]), kb_entity(Id, Type, Props), findall(Key=Value, (member(Key=Value, Props), memberchk(Key, [${keyList}])), Row)), Results)`;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Projected rows for several entities in one Prolog query, in place of one
|
|
456
|
+
* `loadEntities({ id })` round trip per entity. Unknown ids are skipped.
|
|
457
|
+
*/
|
|
458
|
+
// implements REQ-mcp-search-discovery, REQ-kibi-search-answer-layer-v2
|
|
459
|
+
export async function loadEntityRows(
|
|
460
|
+
prolog: Pick<PrologPort, "query">,
|
|
461
|
+
ids: readonly string[],
|
|
462
|
+
keys: readonly string[] = ENTITY_ROW_KEYS,
|
|
463
|
+
): Promise<Record<string, unknown>[]> {
|
|
464
|
+
const unique = [...new Set(ids.filter((id) => id.length > 0))];
|
|
465
|
+
const rows: Record<string, unknown>[] = [];
|
|
466
|
+
for (let start = 0; start < unique.length; start += ENTITY_ROW_BATCH_LIMIT) {
|
|
467
|
+
const batch = unique.slice(start, start + ENTITY_ROW_BATCH_LIMIT);
|
|
468
|
+
const result = await prolog.query(entityRowsGoal(batch, keys));
|
|
469
|
+
if (!result.success) {
|
|
470
|
+
throw new Error(result.error || "Entity row query failed");
|
|
471
|
+
}
|
|
472
|
+
rows.push(
|
|
473
|
+
...parseListOfLists(result.bindings.Results ?? "[]").map(
|
|
474
|
+
parseEntityFromList,
|
|
475
|
+
),
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
return dedupeEntities(rows);
|
|
479
|
+
}
|
|
480
|
+
|
|
407
481
|
/**
|
|
408
482
|
* Replace projected search candidates with complete entities, one bounded
|
|
409
483
|
* query per entity. Used only for the final result page when a caller asks
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import { compilerFingerprintReason } from "../../commands/sync/cache.js";
|
|
2
3
|
import { EngineClient } from "../../engine.js";
|
|
3
4
|
import {
|
|
@@ -9,6 +10,8 @@ import {
|
|
|
9
10
|
validateIntentSearchInput,
|
|
10
11
|
} from "../../intent-search.js";
|
|
11
12
|
import { classifyActivation } from "../../operations/bootstrap/activation.js";
|
|
13
|
+
import { SwiplResolutionError } from "../../prolog/swipl-resolver.js";
|
|
14
|
+
import { type SearchAnswer, buildSearchAnswer } from "../../search-answer.js";
|
|
12
15
|
import { rankEntities } from "../../search-ranking.js";
|
|
13
16
|
import type { SearchMatch } from "../../search-ranking.js";
|
|
14
17
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
@@ -64,12 +67,15 @@ export type SearchInput = {
|
|
|
64
67
|
readonly sourceLocations?: readonly SourceLocation[];
|
|
65
68
|
readonly minScore?: number;
|
|
66
69
|
readonly fields?: "summary" | "full";
|
|
70
|
+
readonly answer?: boolean;
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
export type SearchPayload = {
|
|
70
74
|
readonly results: readonly (SearchMatch | IntentSearchMatch)[];
|
|
71
75
|
readonly count: number;
|
|
76
|
+
readonly truncated?: boolean;
|
|
72
77
|
readonly queryAnalysis?: IntentSearchAnalysis;
|
|
78
|
+
readonly answer?: SearchAnswer;
|
|
73
79
|
};
|
|
74
80
|
|
|
75
81
|
export type StatusInput = Readonly<Record<string, never>>;
|
|
@@ -94,7 +100,11 @@ export type StatusPayload = {
|
|
|
94
100
|
readonly branchAttachment?: {
|
|
95
101
|
readonly gitBranch: string;
|
|
96
102
|
readonly kbBranch: string;
|
|
97
|
-
readonly kind:
|
|
103
|
+
readonly kind:
|
|
104
|
+
| "exact"
|
|
105
|
+
| "explicit_override"
|
|
106
|
+
| "legacy_compat"
|
|
107
|
+
| "detached_snapshot";
|
|
98
108
|
readonly migrationRequired: boolean;
|
|
99
109
|
};
|
|
100
110
|
readonly proofSnapshotChanges?: readonly Record<string, unknown>[];
|
|
@@ -110,6 +120,9 @@ export type StatusPayload = {
|
|
|
110
120
|
readonly schemaStatus?: MigrationConfigStatus;
|
|
111
121
|
readonly migrationPlan?: MigrationPlan;
|
|
112
122
|
readonly bootstrap?: {
|
|
123
|
+
readonly incompleteApplications?: readonly Readonly<
|
|
124
|
+
Record<string, unknown>
|
|
125
|
+
>[];
|
|
113
126
|
readonly activationState: string;
|
|
114
127
|
readonly activationMode: string;
|
|
115
128
|
readonly planEligible: boolean;
|
|
@@ -244,11 +257,12 @@ export async function executeSearch(
|
|
|
244
257
|
type,
|
|
245
258
|
limit = 20,
|
|
246
259
|
offset = 0,
|
|
247
|
-
rankingMode = "
|
|
260
|
+
rankingMode = "intent-v1",
|
|
248
261
|
semanticFacets,
|
|
249
262
|
sourceLocations,
|
|
250
263
|
minScore,
|
|
251
264
|
fields = "summary",
|
|
265
|
+
answer,
|
|
252
266
|
} = input;
|
|
253
267
|
const trimmedQuery = query.trim();
|
|
254
268
|
if (!trimmedQuery) {
|
|
@@ -278,21 +292,34 @@ export async function executeSearch(
|
|
|
278
292
|
context.workspaceRoot,
|
|
279
293
|
);
|
|
280
294
|
const paginated = paginateResults(intentResult.matches, limit, offset);
|
|
295
|
+
// The answer layer summarizes the whole ranking, so it belongs to the
|
|
296
|
+
// first page only.
|
|
297
|
+
const answerLayer =
|
|
298
|
+
(answer ?? true) && offset === 0 && intentResult.matches.length > 0
|
|
299
|
+
? await buildSearchAnswer(prolog, intentResult.matches, {
|
|
300
|
+
workspaceRoot: context.workspaceRoot,
|
|
301
|
+
branch: context.branchAttachment?.kbBranch ?? null,
|
|
302
|
+
})
|
|
303
|
+
: undefined;
|
|
304
|
+
// The structured payload carries every row; the text is a short
|
|
305
|
+
// human-readable digest instead of a second copy of the results.
|
|
281
306
|
const text =
|
|
282
307
|
intentResult.matches.length === 0
|
|
283
308
|
? `No intent search results for '${trimmedQuery}' (abstained).`
|
|
284
|
-
: `Found ${intentResult.matches.length} intent search results for '${trimmedQuery}'
|
|
285
|
-
.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
.join(", ")}
|
|
309
|
+
: `Found ${intentResult.matches.length} intent search results for '${trimmedQuery}'${intentResult.analysis.ambiguous ? " (top matches are close; confirm before relying on one)" : ""}. Top: ${paginated
|
|
310
|
+
.slice(0, 5)
|
|
311
|
+
.map((match) => String(match.entity.id ?? ""))
|
|
312
|
+
.join(
|
|
313
|
+
", ",
|
|
314
|
+
)}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}.`;
|
|
290
315
|
return {
|
|
291
316
|
content: [{ type: "text", text }],
|
|
292
317
|
structuredContent: {
|
|
293
318
|
results: await projectMatches(prolog, paginated, fields),
|
|
294
319
|
count: intentResult.matches.length,
|
|
320
|
+
truncated: offset + paginated.length < intentResult.matches.length,
|
|
295
321
|
queryAnalysis: intentResult.analysis,
|
|
322
|
+
...(answerLayer ? { answer: answerLayer } : {}),
|
|
296
323
|
},
|
|
297
324
|
};
|
|
298
325
|
}
|
|
@@ -327,6 +354,7 @@ export async function executeSearch(
|
|
|
327
354
|
structuredContent: {
|
|
328
355
|
results: await projectMatches(prolog, paginated, fields),
|
|
329
356
|
count: matches.length,
|
|
357
|
+
truncated: offset + paginated.length < matches.length,
|
|
330
358
|
},
|
|
331
359
|
};
|
|
332
360
|
} catch (error) {
|
|
@@ -408,7 +436,9 @@ export async function executeStatus(
|
|
|
408
436
|
errorCode:
|
|
409
437
|
error instanceof OperationJsonDecodeError
|
|
410
438
|
? error.code
|
|
411
|
-
:
|
|
439
|
+
: error instanceof SwiplResolutionError
|
|
440
|
+
? error.code
|
|
441
|
+
: "engine_status_unavailable",
|
|
412
442
|
detail: message,
|
|
413
443
|
recoveryRequired: false,
|
|
414
444
|
};
|
|
@@ -440,8 +470,13 @@ export async function executeStatus(
|
|
|
440
470
|
detail:
|
|
441
471
|
engineStatus.detail ??
|
|
442
472
|
"The branch store is structurally readable but the engine status response is unavailable.",
|
|
473
|
+
// implements REQ-prolog-doctor-runtime-report
|
|
474
|
+
// A missing or unusable SWI-Prolog is not fixed by restarting the
|
|
475
|
+
// engine; point at the diagnostic that reports the resolution.
|
|
443
476
|
remediation: {
|
|
444
|
-
command_argv:
|
|
477
|
+
command_argv: engineStatus.errorCode?.startsWith("swipl_")
|
|
478
|
+
? ["kibi", "doctor"]
|
|
479
|
+
: ["kibi", "engine", "stop"],
|
|
445
480
|
applyRequired: false,
|
|
446
481
|
},
|
|
447
482
|
}
|
|
@@ -519,11 +554,54 @@ export async function executeStatus(
|
|
|
519
554
|
context,
|
|
520
555
|
bootstrapSourceFiles,
|
|
521
556
|
);
|
|
557
|
+
const incompleteApplications: Readonly<Record<string, unknown>>[] = [];
|
|
558
|
+
if (context.fs?.glob) {
|
|
559
|
+
// Scope the scan to recovery itself: workspace globs intentionally exclude
|
|
560
|
+
// compiled and recovery internals from source discovery.
|
|
561
|
+
const recoveryRoot = path.join(context.workspaceRoot, ".kb", "recovery");
|
|
562
|
+
const journals = await context.fs.glob(["bootstrap-*.json"], {
|
|
563
|
+
cwd: recoveryRoot,
|
|
564
|
+
});
|
|
565
|
+
for (const journalPath of journals) {
|
|
566
|
+
try {
|
|
567
|
+
const journal = JSON.parse(
|
|
568
|
+
await context.fs.readFile(path.resolve(recoveryRoot, journalPath)),
|
|
569
|
+
);
|
|
570
|
+
if (
|
|
571
|
+
journal.kind === "bootstrap" &&
|
|
572
|
+
["rejected", "repair_required", "applying"].includes(journal.state)
|
|
573
|
+
)
|
|
574
|
+
incompleteApplications.push({
|
|
575
|
+
journalId: path.basename(journalPath, ".json"),
|
|
576
|
+
state: journal.state,
|
|
577
|
+
appliedActions: (journal.results ?? []).filter(
|
|
578
|
+
(row: { outcome?: string }) => row.outcome === "applied",
|
|
579
|
+
).length,
|
|
580
|
+
failedActions: (journal.results ?? []).filter(
|
|
581
|
+
(row: { outcome?: string }) => row.outcome === "failed",
|
|
582
|
+
),
|
|
583
|
+
nextOperation:
|
|
584
|
+
journal.state === "rejected"
|
|
585
|
+
? "kb_plan_bootstrap"
|
|
586
|
+
: "kb_apply_plan",
|
|
587
|
+
});
|
|
588
|
+
} catch (error) {
|
|
589
|
+
incompleteApplications.push({
|
|
590
|
+
journalId: path.basename(journalPath, ".json"),
|
|
591
|
+
state: "unreadable",
|
|
592
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
522
597
|
const statusWithPlan: StatusPayload = {
|
|
523
598
|
...enrichedPayload,
|
|
524
599
|
schemaStatus,
|
|
525
600
|
migrationPlan,
|
|
526
601
|
bootstrap: {
|
|
602
|
+
...(incompleteApplications.length > 0
|
|
603
|
+
? { incompleteApplications }
|
|
604
|
+
: {}),
|
|
527
605
|
activationState: bootstrapActivation.activationState,
|
|
528
606
|
activationMode: bootstrapActivation.activationMode,
|
|
529
607
|
planEligible:
|
|
@@ -11,6 +11,7 @@ export * from "./migration-plan.js";
|
|
|
11
11
|
export * from "./symbol-repair-plan.js";
|
|
12
12
|
export * from "./specs/bootstrap.js";
|
|
13
13
|
export * from "./specs/check.js";
|
|
14
|
+
export * from "./specs/composite.js";
|
|
14
15
|
export * from "./specs/impact-review-preparation.js";
|
|
15
16
|
export * from "./specs/discovery.js";
|
|
16
17
|
export * from "./specs/modeling.js";
|