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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { buildStrictWriteSet, } from "../../public/check-types.js";
|
|
2
2
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
3
3
|
import { isConventionalSubjectKey, normalizeSubjectKey, } from "../../utils/strict-modeling.js";
|
|
4
|
-
import {
|
|
4
|
+
import { propositionRole } from "../semantic-advisor/analyze-prose.js";
|
|
5
|
+
import { extractSemanticClauses, modeledClaimRole, normalizeSemanticClause, semanticClaimKey, } from "../semantic-advisor/clauses.js";
|
|
6
|
+
import { detectConditionalRule } from "../semantic-advisor/conditional-rules.js";
|
|
5
7
|
import { semanticSourceHash } from "../semantic-advisor/shared.js";
|
|
6
8
|
import { buildLogicApplyPlan } from "./logic-modeling.js";
|
|
7
9
|
import { strictWriteSetToApplyPlan, writeSetPrimaryEntityId, } from "./requirement-applyplan.js";
|
|
@@ -196,9 +198,7 @@ export function annotateModelRequirementStep(step, context) {
|
|
|
196
198
|
{
|
|
197
199
|
claim_key: context.claimKey,
|
|
198
200
|
claim_text: normalizedClaimText,
|
|
199
|
-
role:
|
|
200
|
-
? "normative"
|
|
201
|
-
: "descriptive",
|
|
201
|
+
role: modeledClaimRole(claimText),
|
|
202
202
|
status: "modeled",
|
|
203
203
|
span: {
|
|
204
204
|
start: 0,
|
|
@@ -211,92 +211,250 @@ export function annotateModelRequirementStep(step, context) {
|
|
|
211
211
|
}
|
|
212
212
|
return step;
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return status.warning;
|
|
214
|
+
function stepProperties(step) {
|
|
215
|
+
return step.properties !== null && typeof step.properties === "object"
|
|
216
|
+
? step.properties
|
|
217
|
+
: {};
|
|
219
218
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
// implements REQ-kibi-truthful-consistency
|
|
220
|
+
function unresolvedObservationStep(step) {
|
|
221
|
+
if (step.type !== "fact")
|
|
222
|
+
return step;
|
|
223
|
+
const properties = stepProperties(step);
|
|
224
|
+
const tags = Array.isArray(properties.tags) ? properties.tags : [];
|
|
225
|
+
return {
|
|
226
|
+
...step,
|
|
227
|
+
properties: {
|
|
228
|
+
...properties,
|
|
229
|
+
tags: Array.from(new Set([...tags, "review:ontology-gap"])),
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// implements REQ-kibi-proposition-complete-ingestion
|
|
234
|
+
// The advisor decides each proposition's role, and proposition-complete
|
|
235
|
+
// ingestion compares the persisted inventory with it. A rule modality alone
|
|
236
|
+
// would call "X must not happen unless C" normative where the advisor reads an
|
|
237
|
+
// exception, so the role comes from the advisor's own clause analysis.
|
|
238
|
+
function advisorRole(semanticText, claimKey) {
|
|
239
|
+
const clause = extractSemanticClauses(semanticText).find((entry) => entry.claim_key === claimKey);
|
|
240
|
+
return clause ? propositionRole(clause.text, clause.normative) : null;
|
|
241
|
+
}
|
|
242
|
+
function withAdvisorRoles(plan) {
|
|
243
|
+
return plan.map((step) => {
|
|
244
|
+
if (step.type !== "req")
|
|
245
|
+
return step;
|
|
246
|
+
const properties = stepProperties(step);
|
|
247
|
+
const semanticText = properties.semantic_text;
|
|
248
|
+
const inventory = properties.semantic_inventory;
|
|
249
|
+
if (typeof semanticText !== "string" || !Array.isArray(inventory))
|
|
250
|
+
return step;
|
|
251
|
+
return {
|
|
252
|
+
...step,
|
|
253
|
+
properties: {
|
|
254
|
+
...properties,
|
|
255
|
+
semantic_inventory: inventory.map((entry) => {
|
|
256
|
+
if (entry === null || typeof entry !== "object")
|
|
257
|
+
return entry;
|
|
258
|
+
const row = entry;
|
|
259
|
+
const role = typeof row.claim_key === "string"
|
|
260
|
+
? advisorRole(semanticText, row.claim_key)
|
|
261
|
+
: null;
|
|
262
|
+
return role === null ? row : { ...row, role };
|
|
263
|
+
}),
|
|
264
|
+
},
|
|
265
|
+
};
|
|
226
266
|
});
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
267
|
+
}
|
|
268
|
+
// implements REQ-kibi-logical-requirement-coverage
|
|
269
|
+
async function logicModelResult(args, extracted, logic, workspaceRoot, confidence) {
|
|
270
|
+
const logicPlan = buildLogicApplyPlan({
|
|
271
|
+
text: args.text,
|
|
272
|
+
logic,
|
|
273
|
+
source: extracted.source,
|
|
274
|
+
...(typeof args.requirementId === "string"
|
|
275
|
+
? { requirementId: args.requirementId }
|
|
276
|
+
: {}),
|
|
277
|
+
...(args.existingLogicClaims !== undefined
|
|
278
|
+
? { existingLogicClaims: args.existingLogicClaims }
|
|
279
|
+
: {}),
|
|
280
|
+
...(args.claimKey !== undefined ? { claimKey: args.claimKey } : {}),
|
|
281
|
+
...(args.claimText !== undefined ? { claimText: args.claimText } : {}),
|
|
282
|
+
});
|
|
283
|
+
const applyPlan = withAdvisorRoles(logicPlan.applyPlan);
|
|
284
|
+
const fallbackWriteSet = buildStrictWriteSet({
|
|
285
|
+
claim: extracted.claim,
|
|
286
|
+
statement: extracted.statement,
|
|
287
|
+
});
|
|
288
|
+
const migrationWarning = await getWorkspaceMigrationWarning(workspaceRoot);
|
|
289
|
+
const structuredContent = {
|
|
290
|
+
statement: extracted.statement,
|
|
291
|
+
claimKey: logicPlan.claimKey,
|
|
292
|
+
logicClaims: Array.from(new Set([...(args.existingLogicClaims ?? []), logicPlan.claimKey])),
|
|
293
|
+
source: extracted.source,
|
|
294
|
+
sourceFiles: extracted.sourceFiles,
|
|
295
|
+
claim: extracted.claim,
|
|
296
|
+
writeSet: fallbackWriteSet,
|
|
297
|
+
applyPlan,
|
|
298
|
+
isStrict: false,
|
|
299
|
+
confidence,
|
|
300
|
+
extractionMode: extracted.extractionMode,
|
|
301
|
+
extractionWarnings: extracted.extractionWarnings,
|
|
302
|
+
warnings: [],
|
|
303
|
+
migrationWarning,
|
|
304
|
+
logic: {
|
|
305
|
+
semanticKey: logicPlan.semanticKey,
|
|
248
306
|
claimKey: logicPlan.claimKey,
|
|
249
|
-
|
|
307
|
+
claimText: logicPlan.claimText,
|
|
308
|
+
renderedProlog: logicPlan.renderedProlog,
|
|
309
|
+
normalized: logicPlan.normalized,
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
return {
|
|
313
|
+
content: [
|
|
314
|
+
{
|
|
315
|
+
type: "text",
|
|
316
|
+
text: `Modeled typed kibi.logic.v1 rule ${logicPlan.semanticKey}; apply the returned schema, rule, and requirement steps sequentially.`,
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
structuredContent,
|
|
320
|
+
applyPlan,
|
|
321
|
+
writeSet: fallbackWriteSet,
|
|
322
|
+
migrationWarning,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
// implements REQ-kibi-truthful-consistency
|
|
326
|
+
// A recognised conditional clause that cannot be translated gets no
|
|
327
|
+
// observation and no strict property. With a requirementId the requirement
|
|
328
|
+
// records the clause as an unresolved ontology gap in its inventory.
|
|
329
|
+
async function unresolvedConditionalResult(args, extracted, reason, workspaceRoot) {
|
|
330
|
+
const semanticText = args.text.trim();
|
|
331
|
+
const claimText = normalizeSemanticClause(extracted.statement);
|
|
332
|
+
const claimKey = semanticClaimKey(claimText);
|
|
333
|
+
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
334
|
+
const start = Math.max(0, semanticText.indexOf(claimText));
|
|
335
|
+
const applyPlan = typeof args.requirementId === "string"
|
|
336
|
+
? [
|
|
337
|
+
{
|
|
338
|
+
type: "req",
|
|
339
|
+
id: args.requirementId,
|
|
340
|
+
properties: {
|
|
341
|
+
title: claimText.split(/[.!?]/, 1)[0] || "Conditional requirement",
|
|
342
|
+
status: "open",
|
|
343
|
+
source: extracted.source,
|
|
344
|
+
semantic_text: semanticText,
|
|
345
|
+
logic_claims: logicClaims,
|
|
346
|
+
semantic_clauses: [claimText],
|
|
347
|
+
semantic_inventory_version: "kibi.semantic-inventory.v1",
|
|
348
|
+
semantic_source_field: "semantic_text",
|
|
349
|
+
semantic_source_hash: semanticSourceHash(semanticText),
|
|
350
|
+
semantic_inventory: [
|
|
351
|
+
{
|
|
352
|
+
claim_key: claimKey,
|
|
353
|
+
claim_text: claimText,
|
|
354
|
+
role: advisorRole(semanticText, claimKey) ??
|
|
355
|
+
modeledClaimRole(claimText),
|
|
356
|
+
status: "ontology_gap",
|
|
357
|
+
span: {
|
|
358
|
+
start: Buffer.byteLength(semanticText.slice(0, start), "utf8"),
|
|
359
|
+
end: Buffer.byteLength(semanticText.slice(0, start + claimText.length), "utf8"),
|
|
360
|
+
},
|
|
361
|
+
reason,
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
},
|
|
365
|
+
relationships: [],
|
|
366
|
+
},
|
|
367
|
+
]
|
|
368
|
+
: [];
|
|
369
|
+
const writeSet = buildStrictWriteSet({
|
|
370
|
+
claim: extracted.claim,
|
|
371
|
+
statement: extracted.statement,
|
|
372
|
+
});
|
|
373
|
+
const migrationWarning = await getWorkspaceMigrationWarning(workspaceRoot);
|
|
374
|
+
return {
|
|
375
|
+
content: [
|
|
376
|
+
{
|
|
377
|
+
type: "text",
|
|
378
|
+
text: "Recognised a conditional requirement but could not translate it; it stays unresolved until a typed kibi.logic.v1 rule is supplied.",
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
structuredContent: {
|
|
382
|
+
statement: extracted.statement,
|
|
383
|
+
claimKey,
|
|
384
|
+
logicClaims,
|
|
250
385
|
source: extracted.source,
|
|
251
386
|
sourceFiles: extracted.sourceFiles,
|
|
252
387
|
claim: extracted.claim,
|
|
253
|
-
writeSet
|
|
254
|
-
applyPlan
|
|
388
|
+
writeSet,
|
|
389
|
+
applyPlan,
|
|
255
390
|
isStrict: false,
|
|
256
|
-
confidence:
|
|
391
|
+
confidence: 0,
|
|
257
392
|
extractionMode: extracted.extractionMode,
|
|
258
393
|
extractionWarnings: extracted.extractionWarnings,
|
|
259
|
-
warnings: [
|
|
260
|
-
migrationWarning,
|
|
261
|
-
logic: {
|
|
262
|
-
semanticKey: logicPlan.semanticKey,
|
|
263
|
-
claimKey: logicPlan.claimKey,
|
|
264
|
-
claimText: logicPlan.claimText,
|
|
265
|
-
renderedProlog: logicPlan.renderedProlog,
|
|
266
|
-
normalized: logicPlan.normalized,
|
|
267
|
-
},
|
|
268
|
-
};
|
|
269
|
-
return {
|
|
270
|
-
content: [
|
|
394
|
+
warnings: [
|
|
271
395
|
{
|
|
272
|
-
|
|
273
|
-
|
|
396
|
+
kind: "unresolved_conditional_clause",
|
|
397
|
+
message: `${reason} The clause stays unresolved: Kibi emitted no strict property and no observation for it.`,
|
|
398
|
+
nextAction: "Pass logic with a kibi.logic.v1 rule that forbids the action unless the condition holds, or call kb_model with mode predicates when the condition is a domain relation, then apply the returned steps sequentially.",
|
|
274
399
|
},
|
|
275
400
|
],
|
|
276
|
-
structuredContent,
|
|
277
|
-
applyPlan: logicPlan.applyPlan,
|
|
278
|
-
writeSet: fallbackWriteSet,
|
|
279
401
|
migrationWarning,
|
|
280
|
-
}
|
|
281
|
-
|
|
402
|
+
},
|
|
403
|
+
applyPlan,
|
|
404
|
+
writeSet,
|
|
405
|
+
migrationWarning,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
export async function getWorkspaceMigrationWarning(workspaceRoot) {
|
|
409
|
+
const status = readKbManifestStatus(workspaceRoot);
|
|
410
|
+
if (status.state === "ok")
|
|
411
|
+
return null;
|
|
412
|
+
return status.warning;
|
|
413
|
+
}
|
|
414
|
+
export async function handleKbModelRequirement(_prolog, args, workspaceRoot, context) {
|
|
415
|
+
const extracted = extractRequirementClaim({
|
|
416
|
+
...args,
|
|
417
|
+
source: normalizeOptionalString(args.source) ??
|
|
418
|
+
normalizeSourceFiles(args.sourceFiles)[0] ??
|
|
419
|
+
"mcp://kibi/model-requirement",
|
|
420
|
+
});
|
|
421
|
+
if (args.logic !== undefined)
|
|
422
|
+
return logicModelResult(args, extracted, args.logic, workspaceRoot, args.confidence ?? 1);
|
|
423
|
+
// implements REQ-kibi-truthful-consistency
|
|
424
|
+
// A conditional requirement ("X may happen only when C", "X must not happen
|
|
425
|
+
// unless C") restricts an action. It goes to the rule lane and never falls
|
|
426
|
+
// back to a strict property or an observation; a conditional clause this
|
|
427
|
+
// reader cannot translate stays unresolved.
|
|
428
|
+
const conditional = extracted.extractionMode === "provided"
|
|
429
|
+
? null
|
|
430
|
+
: detectConditionalRule(extracted.statement);
|
|
431
|
+
if (conditional?.kind === "rule")
|
|
432
|
+
return logicModelResult(args, extracted, conditional.ir, workspaceRoot, args.confidence ?? 0.8);
|
|
433
|
+
if (conditional?.kind === "unparsed")
|
|
434
|
+
return unresolvedConditionalResult(args, extracted, conditional.reason, workspaceRoot);
|
|
282
435
|
const claimKey = semanticClaimKey(extracted.statement);
|
|
283
436
|
const aligned = await applyVocabularyAlignment(context, extracted, claimKey);
|
|
284
437
|
const writeSet = aligned.writeSet;
|
|
285
438
|
const logicClaims = Array.from(new Set([...(args.existingLogicClaims ?? []), claimKey]));
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
439
|
+
const plan = aligned.adjustPlan(strictWriteSetToApplyPlan(writeSet));
|
|
440
|
+
// A strict write set grounds the claim, so its steps carry the claim. The
|
|
441
|
+
// below-threshold observation is only a review artifact: it gets no claim
|
|
442
|
+
// provenance (that would make it look like grounding) and is tagged as an
|
|
443
|
+
// open ontology gap.
|
|
444
|
+
const applyPlan = writeSet.isStrict
|
|
445
|
+
? plan.map((step) => annotateModelRequirementStep(step, {
|
|
446
|
+
claimKey,
|
|
447
|
+
statement: extracted.statement,
|
|
448
|
+
logicClaims,
|
|
449
|
+
}))
|
|
450
|
+
: plan.map(unresolvedObservationStep);
|
|
293
451
|
const migrationWarning = await getWorkspaceMigrationWarning(workspaceRoot);
|
|
294
452
|
const warnings = writeSet.isStrict
|
|
295
453
|
? [...aligned.warnings]
|
|
296
454
|
: [
|
|
297
455
|
{
|
|
298
456
|
kind: "low_confidence_observation_downgrade",
|
|
299
|
-
message: `Claim confidence ${writeSet.confidence.toFixed(2)} is below the strict threshold 0.70, so Kibi emitted
|
|
457
|
+
message: `Claim confidence ${writeSet.confidence.toFixed(2)} is below the strict threshold 0.70, so Kibi emitted a review:ontology-gap observation instead of strict subject/property facts. The clause stays unresolved: the observation does not ground it.`,
|
|
300
458
|
nextAction: "If this is normative, provide subjectKey, propertyKey, operator, and value explicitly, then apply the returned strict write-set sequentially.",
|
|
301
459
|
},
|
|
302
460
|
];
|
|
@@ -6,6 +6,22 @@ type TransactionInput = {
|
|
|
6
6
|
readonly skipContradictionCheck: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare function buildUpsertCommitGoal(input: TransactionInput): string;
|
|
9
|
+
type WhatIfInput = TransactionInput & {
|
|
10
|
+
readonly relationshipsOnly?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Goal that stages inputs in a rolled-back transaction and returns the
|
|
14
|
+
* contradiction witnesses the KB would then contain, as JSON in JsonString.
|
|
15
|
+
* Inputs without entity properties stage only their relationships, so a
|
|
16
|
+
* relationship-only step never erases an existing entity's properties.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildWhatIfContradictionGoal(inputs: readonly WhatIfInput[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Goal for checks:what_if_analysis_json/2: the current and staged
|
|
21
|
+
* contradiction and scenario-infeasibility witnesses, with the
|
|
22
|
+
* introduced/removed/unchanged split, as JSON in JsonString.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildWhatIfAnalysisGoal(inputs: readonly WhatIfInput[]): string;
|
|
9
25
|
/** One transaction and one journal flush for a receipt campaign. */
|
|
10
26
|
export declare function buildUpsertBatchCommitGoal(inputs: readonly TransactionInput[]): string;
|
|
11
27
|
export declare function parseUpsertChangeKinds(bindings: Readonly<Record<string, string>>, count: number): Array<"created" | "updated">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AASrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAOrE;
|
|
1
|
+
{"version":3,"file":"contradictions.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/contradictions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AASrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;CAC1C,CAAC;AAGF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAOrE;AAiBD,KAAK,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAgB/E;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAGD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,MAAM,CAER;AAED,oEAAoE;AAEpE,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,MAAM,CAKR;AAGD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAe9B;AAGD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAOR"}
|
|
@@ -12,6 +12,38 @@ function upsertBatchEntry(input) {
|
|
|
12
12
|
const relationships = input.relationships.map((relationship) => `rel(${String(relationship.type)}, '${escapeAtom(String(relationship.from))}', '${escapeAtom(String(relationship.to))}', ${buildRelationshipMetadata(relationship)})`);
|
|
13
13
|
return `upsert(${type}, ${buildPropertyList(input.entity)}, [${relationships.join(", ")}], ${input.skipContradictionCheck ? "true" : "false"})`;
|
|
14
14
|
}
|
|
15
|
+
// Engines that only loaded kb.pl (one-shot processes, embedders) have not
|
|
16
|
+
// loaded checks.pl yet; load it from kb.pl's directory on first use. The
|
|
17
|
+
// call/1 defers resolving the checks procedure until after the load.
|
|
18
|
+
const ENSURE_CHECKS_LOADED = "(current_predicate(checks:what_if_analysis_json/2) -> true ; module_property(kb, file(KbFile)), file_directory_name(KbFile, KbDir), directory_file_path(KbDir, 'checks.pl', ChecksFile), use_module(ChecksFile))";
|
|
19
|
+
function whatIfEntries(inputs) {
|
|
20
|
+
const entries = inputs.map((input) => {
|
|
21
|
+
const relationships = input.relationships.map((relationship) => `rel(${String(relationship.type)}, '${escapeAtom(String(relationship.from))}', '${escapeAtom(String(relationship.to))}', ${buildRelationshipMetadata(relationship)})`);
|
|
22
|
+
if (input.relationshipsOnly === true)
|
|
23
|
+
return `relate([${relationships.join(", ")}])`;
|
|
24
|
+
return `upsert(${String(input.entity.type)}, ${buildPropertyList(input.entity)}, [${relationships.join(", ")}])`;
|
|
25
|
+
});
|
|
26
|
+
return `[${entries.join(", ")}]`;
|
|
27
|
+
}
|
|
28
|
+
// implements REQ-kibi-truthful-consistency
|
|
29
|
+
/**
|
|
30
|
+
* Goal that stages inputs in a rolled-back transaction and returns the
|
|
31
|
+
* contradiction witnesses the KB would then contain, as JSON in JsonString.
|
|
32
|
+
* Inputs without entity properties stage only their relationships, so a
|
|
33
|
+
* relationship-only step never erases an existing entity's properties.
|
|
34
|
+
*/
|
|
35
|
+
export function buildWhatIfContradictionGoal(inputs) {
|
|
36
|
+
return `(${ENSURE_CHECKS_LOADED}, call(checks:what_if_contradiction_witnesses_json(${whatIfEntries(inputs)}, JsonString)))`;
|
|
37
|
+
}
|
|
38
|
+
// implements REQ-kibi-truthful-consistency
|
|
39
|
+
/**
|
|
40
|
+
* Goal for checks:what_if_analysis_json/2: the current and staged
|
|
41
|
+
* contradiction and scenario-infeasibility witnesses, with the
|
|
42
|
+
* introduced/removed/unchanged split, as JSON in JsonString.
|
|
43
|
+
*/
|
|
44
|
+
export function buildWhatIfAnalysisGoal(inputs) {
|
|
45
|
+
return `(${ENSURE_CHECKS_LOADED}, call(checks:what_if_analysis_json(${whatIfEntries(inputs)}, JsonString)))`;
|
|
46
|
+
}
|
|
15
47
|
/** One transaction and one journal flush for a receipt campaign. */
|
|
16
48
|
// implements REQ-core-atomic-upsert-persistence
|
|
17
49
|
export function buildUpsertBatchCommitGoal(inputs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/delete.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,KAAK,oBAAoB,EAM1B,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/delete.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,KAAK,oBAAoB,EAM1B,MAAM,+BAA+B,CAAC;AAqBvC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAc7D,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,GACzB,OAAO,CAAC,EAAE,IAAI,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAMnD;AAuWD,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,SAAS,oBAAoB,EAAE,EAC1C,OAAO,EAAE,gBAAgB,EACzB,WAAW,GAAE,MAAM,IAAsB,GACxC,OAAO,CAAC,aAAa,CAAC,CA4BxB;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAuSzC"}
|
|
@@ -6,6 +6,7 @@ import { parseEntityFromList, parseListOfLists, toPrologAtom, } from "../../prol
|
|
|
6
6
|
import { listShards, readAllShards, readShard, removeRelationshipsFromShards, renderShardWithout, } from "../../relationships/shards.js";
|
|
7
7
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
8
8
|
import { buildEntityDeleteAuditGoal } from "./audit.js";
|
|
9
|
+
import { planRecoveryNotes, settlePendingPlanApplyJournals, withPlanRecoveryNotes, } from "./plan-apply-journal.js";
|
|
9
10
|
import { RELATIONSHIP_TYPES, dependentRelationshipsGoal, } from "./relationships.js";
|
|
10
11
|
import { saveAtomicMutation, saveMutation } from "./save.js";
|
|
11
12
|
import { normalizeAuthoredSourcePath, renderMarkdownRelationshipDeletion, renderSourceDeletion, renderYamlRelationshipDeletion, resolveContainedSourcePath, writePendingSourceReceipt, } from "./source-authoring.js";
|
|
@@ -349,9 +350,15 @@ export async function executeDelete(input, context) {
|
|
|
349
350
|
let sourceMutationLock;
|
|
350
351
|
let committed = false;
|
|
351
352
|
let operationFailure;
|
|
353
|
+
let recoveryNotes = [];
|
|
354
|
+
const reported = (text) => recoveryNotes.length > 0 ? `${text} ${recoveryNotes.join(" ")}` : text;
|
|
352
355
|
try {
|
|
353
356
|
if (context.fs && context.sourceMutationLockHeld !== true) {
|
|
354
357
|
sourceMutationLock = await acquireWorkspaceMutationLock(context.workspaceRoot);
|
|
358
|
+
// implements REQ-core-atomic-upsert-persistence
|
|
359
|
+
// Finish an interrupted kb_apply_plan before this delete reads or
|
|
360
|
+
// changes the files its journal guards.
|
|
361
|
+
recoveryNotes = planRecoveryNotes(await settlePendingPlanApplyJournals({ ...context, branchAttachment }, { prolog: async () => prolog }));
|
|
355
362
|
}
|
|
356
363
|
const ids = input.ids ?? [];
|
|
357
364
|
const relationships = input.relationships ?? [];
|
|
@@ -367,7 +374,7 @@ export async function executeDelete(input, context) {
|
|
|
367
374
|
content: [
|
|
368
375
|
{
|
|
369
376
|
type: "text",
|
|
370
|
-
text: `Deleted ${payload.relationships_deleted ?? 0} relationships. Skipped ${payload.skipped}.${payload.sync_required ? " Run kibi sync to reconcile the relationship shard." : ""}
|
|
377
|
+
text: reported(`Deleted ${payload.relationships_deleted ?? 0} relationships. Skipped ${payload.skipped}.${payload.sync_required ? " Run kibi sync to reconcile the relationship shard." : ""}`),
|
|
371
378
|
},
|
|
372
379
|
],
|
|
373
380
|
structuredContent: payload,
|
|
@@ -505,7 +512,7 @@ export async function executeDelete(input, context) {
|
|
|
505
512
|
content: [
|
|
506
513
|
{
|
|
507
514
|
type: "text",
|
|
508
|
-
text: `Deletion plan ${planHash.slice(0, 12)} must be applied through kb_apply_plan
|
|
515
|
+
text: reported(`Deletion plan ${planHash.slice(0, 12)} must be applied through kb_apply_plan.`),
|
|
509
516
|
},
|
|
510
517
|
],
|
|
511
518
|
structuredContent: payload,
|
|
@@ -533,7 +540,7 @@ export async function executeDelete(input, context) {
|
|
|
533
540
|
content: [
|
|
534
541
|
{
|
|
535
542
|
type: "text",
|
|
536
|
-
text: `Deleted ${payload.deleted} entities. Skipped ${payload.skipped}.${errors.length > 0 ? ` Errors: ${errors.join("; ")}` : ""}
|
|
543
|
+
text: reported(`Deleted ${payload.deleted} entities. Skipped ${payload.skipped}.${errors.length > 0 ? ` Errors: ${errors.join("; ")}` : ""}`),
|
|
537
544
|
},
|
|
538
545
|
],
|
|
539
546
|
structuredContent: payload,
|
|
@@ -545,15 +552,16 @@ export async function executeDelete(input, context) {
|
|
|
545
552
|
// wrap it as non-retryable immediately instead of only when lock release
|
|
546
553
|
// also fails.
|
|
547
554
|
if (error instanceof OperationError || error instanceof InputError) {
|
|
548
|
-
|
|
549
|
-
|
|
555
|
+
const failure = withPlanRecoveryNotes(error, recoveryNotes);
|
|
556
|
+
operationFailure = { error: failure };
|
|
557
|
+
throw failure;
|
|
550
558
|
}
|
|
551
559
|
if (committed) {
|
|
552
|
-
const failure = classifySourceMutationFailure("Delete", error, true);
|
|
560
|
+
const failure = withPlanRecoveryNotes(classifySourceMutationFailure("Delete", error, true), recoveryNotes);
|
|
553
561
|
operationFailure = { error: failure };
|
|
554
562
|
throw failure;
|
|
555
563
|
}
|
|
556
|
-
const failure = new Error(`Delete execution failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
564
|
+
const failure = withPlanRecoveryNotes(new Error(`Delete execution failed: ${error instanceof Error ? error.message : String(error)}`), recoveryNotes);
|
|
557
565
|
operationFailure = { error: failure };
|
|
558
566
|
throw failure;
|
|
559
567
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PrologPort } from "../../public/operations/runtime-types.js";
|
|
2
|
+
import type { StagedUpsertState, UpsertInput } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the provenance an upsert writes. kb_upsert never overwrites who
|
|
5
|
+
* authored an entity by omission:
|
|
6
|
+
*
|
|
7
|
+
* 1. A supplied `origin` is written as given (schema validation follows);
|
|
8
|
+
* when it omits `recorded_at`, the write time is recorded.
|
|
9
|
+
* 2. Without one, an existing entity keeps its stored origin unchanged.
|
|
10
|
+
* 3. Without one, a new entity is recorded as `{kind: agent, recorded_at}`:
|
|
11
|
+
* kb_upsert is the agent write path, and a human or import author says so
|
|
12
|
+
* explicitly.
|
|
13
|
+
* 4. Without one, an existing entity that has no origin (authored before
|
|
14
|
+
* schema 6, or by hand) stays without one; editing it does not make the
|
|
15
|
+
* editor its author. `kibi migrate` backfills `kind: migration`.
|
|
16
|
+
*
|
|
17
|
+
* Without a Prolog runtime the existing entity cannot be read, so only rule 1
|
|
18
|
+
* applies.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveUpsertOrigin(input: UpsertInput, prolog: Pick<PrologPort, "query"> | undefined, now: Date, staged?: StagedUpsertState): Promise<UpsertInput>;
|
|
21
|
+
//# sourceMappingURL=origin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/origin.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUjE;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CAiCtB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
import { escapeAtom } from "../../prolog/codec.js";
|
|
19
|
+
import { readEntityOrigin } from "../../public/entity-origin.js";
|
|
20
|
+
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
21
|
+
function isRecord(value) {
|
|
22
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
function withOrigin(input, origin) {
|
|
25
|
+
return { ...input, properties: { ...input.properties, origin } };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the provenance an upsert writes. kb_upsert never overwrites who
|
|
29
|
+
* authored an entity by omission:
|
|
30
|
+
*
|
|
31
|
+
* 1. A supplied `origin` is written as given (schema validation follows);
|
|
32
|
+
* when it omits `recorded_at`, the write time is recorded.
|
|
33
|
+
* 2. Without one, an existing entity keeps its stored origin unchanged.
|
|
34
|
+
* 3. Without one, a new entity is recorded as `{kind: agent, recorded_at}`:
|
|
35
|
+
* kb_upsert is the agent write path, and a human or import author says so
|
|
36
|
+
* explicitly.
|
|
37
|
+
* 4. Without one, an existing entity that has no origin (authored before
|
|
38
|
+
* schema 6, or by hand) stays without one; editing it does not make the
|
|
39
|
+
* editor its author. `kibi migrate` backfills `kind: migration`.
|
|
40
|
+
*
|
|
41
|
+
* Without a Prolog runtime the existing entity cannot be read, so only rule 1
|
|
42
|
+
* applies.
|
|
43
|
+
*/
|
|
44
|
+
// implements REQ-kibi-entity-origin
|
|
45
|
+
export async function resolveUpsertOrigin(input, prolog, now, staged) {
|
|
46
|
+
const supplied = input.properties.origin;
|
|
47
|
+
if (supplied !== undefined) {
|
|
48
|
+
return isRecord(supplied) && supplied.recorded_at === undefined
|
|
49
|
+
? withOrigin(input, { ...supplied, recorded_at: now.toISOString() })
|
|
50
|
+
: input;
|
|
51
|
+
}
|
|
52
|
+
if (prolog === undefined)
|
|
53
|
+
return input;
|
|
54
|
+
// An earlier step of the same plan that writes this entity is its history.
|
|
55
|
+
const planned = staged?.entities.get(input.id);
|
|
56
|
+
if (planned !== undefined) {
|
|
57
|
+
const stored = readEntityOrigin(planned.origin);
|
|
58
|
+
return stored === null ? input : withOrigin(input, stored);
|
|
59
|
+
}
|
|
60
|
+
// The same existence probe the rest of the upsert uses.
|
|
61
|
+
const exists = await prolog.query(`once(kb_entity('${escapeAtom(input.id)}', _, _))`);
|
|
62
|
+
if (!exists.success) {
|
|
63
|
+
return withOrigin(input, { kind: "agent", recorded_at: now.toISOString() });
|
|
64
|
+
}
|
|
65
|
+
let stored = null;
|
|
66
|
+
try {
|
|
67
|
+
const [existing] = await loadEntities(prolog, {
|
|
68
|
+
id: input.id,
|
|
69
|
+
type: input.type,
|
|
70
|
+
});
|
|
71
|
+
stored = readEntityOrigin(existing?.origin);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Unreadable: leave origin out. The source-first write merges the
|
|
75
|
+
// authored frontmatter, so a stored origin there survives either way.
|
|
76
|
+
}
|
|
77
|
+
return stored === null ? input : withOrigin(input, stored);
|
|
78
|
+
}
|