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,6 +1,6 @@
|
|
|
1
1
|
import type { PrologPort } from "../../public/operations/runtime-types.js";
|
|
2
|
-
import type { RelationshipInput } from "./types.js";
|
|
3
|
-
export declare const RELATIONSHIP_TYPES: readonly ["depends_on", "specified_by", "verified_by", "validates", "implements", "covered_by", "executable_for", "constrained_by", "constrains", "requires_property", "requires_predicate", "requires_rule", "guards", "publishes", "consumes", "supersedes", "restates", "relates_to"];
|
|
2
|
+
import type { RelationshipInput, StagedUpsertState } from "./types.js";
|
|
3
|
+
export declare const RELATIONSHIP_TYPES: readonly ["depends_on", "specified_by", "verified_by", "validates", "implements", "covered_by", "executable_for", "constrained_by", "constrains", "requires_property", "requires_predicate", "requires_rule", "guards", "publishes", "consumes", "supersedes", "restates", "assumes", "exempts", "relates_to"];
|
|
4
4
|
export type RelationshipType = (typeof RELATIONSHIP_TYPES)[number];
|
|
5
5
|
export declare function wrongKindRelationshipError(type: string, target: string, wrongKind: string): Error;
|
|
6
6
|
export declare function dependentRelationshipsGoal(entityId: string): string;
|
|
@@ -19,10 +19,10 @@ type SupersedesHistoryDeps = Readonly<{
|
|
|
19
19
|
}>;
|
|
20
20
|
export declare function firstGitAdditionCommit(workspaceRoot: string, source: string): string | null;
|
|
21
21
|
export declare function classifySupersedesHistory(workspaceRoot: string, sourceCommit: string | null, targetCommit: string | null, deps?: Pick<SupersedesHistoryDeps, "isAncestor">): SupersedesHistory;
|
|
22
|
-
export declare function validateSupersedesSourceHistory(prolog: PrologPort, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], workspaceRoot: string, deps?: SupersedesHistoryDeps): Promise<void>;
|
|
22
|
+
export declare function validateSupersedesSourceHistory(prolog: PrologPort, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], workspaceRoot: string, deps?: SupersedesHistoryDeps, staged?: StagedUpsertState): Promise<void>;
|
|
23
23
|
export declare function formatRelationshipSourceMismatch(entityId: string, relationship: RelationshipInput): string;
|
|
24
|
-
export declare function validateLiveRelationshipTargets(prolog: PrologPort, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[]): Promise<void>;
|
|
25
|
-
export declare function validateStrictLanePairing(prolog: PrologPort, relationships: readonly RelationshipInput[]): Promise<void>;
|
|
24
|
+
export declare function validateLiveRelationshipTargets(prolog: PrologPort, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], staged?: StagedUpsertState): Promise<void>;
|
|
25
|
+
export declare function validateStrictLanePairing(prolog: PrologPort, relationships: readonly RelationshipInput[], staged?: StagedUpsertState): Promise<void>;
|
|
26
26
|
export declare function existingRelationships(prolog: PrologPort, entityId: string): Promise<readonly RelationshipInput[]>;
|
|
27
27
|
export {};
|
|
28
28
|
//# sourceMappingURL=relationships.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEvE,eAAO,MAAM,kBAAkB,gTAqBrB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,KAAK,CAKP;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,OA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CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA4Cf;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,iBAAiB,GAC9B,MAAM,CAIR;AA2BD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAUD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA2Cf;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAevC"}
|
|
@@ -19,6 +19,8 @@ export const RELATIONSHIP_TYPES = [
|
|
|
19
19
|
"consumes",
|
|
20
20
|
"supersedes",
|
|
21
21
|
"restates",
|
|
22
|
+
"assumes",
|
|
23
|
+
"exempts",
|
|
22
24
|
"relates_to",
|
|
23
25
|
];
|
|
24
26
|
export function wrongKindRelationshipError(type, target, wrongKind) {
|
|
@@ -111,7 +113,7 @@ export function classifySupersedesHistory(workspaceRoot, sourceCommit, targetCom
|
|
|
111
113
|
return sourceBeforeTarget === true ? "reversed" : "unknown";
|
|
112
114
|
}
|
|
113
115
|
// implements REQ-011
|
|
114
|
-
export async function validateSupersedesSourceHistory(prolog, entity, relationships, workspaceRoot, deps = DEFAULT_SUPERSEDES_HISTORY_DEPS) {
|
|
116
|
+
export async function validateSupersedesSourceHistory(prolog, entity, relationships, workspaceRoot, deps = DEFAULT_SUPERSEDES_HISTORY_DEPS, staged) {
|
|
115
117
|
const sourceId = typeof entity.id === "string" ? entity.id : "";
|
|
116
118
|
const source = typeof entity.source === "string" ? entity.source : "";
|
|
117
119
|
const sourceCommit = deps.firstAdditionCommit(workspaceRoot, source);
|
|
@@ -120,7 +122,11 @@ export async function validateSupersedesSourceHistory(prolog, entity, relationsh
|
|
|
120
122
|
continue;
|
|
121
123
|
const targetId = stringField(relationship, "to");
|
|
122
124
|
let targetSource = "";
|
|
123
|
-
|
|
125
|
+
const planned = staged?.entities.get(targetId);
|
|
126
|
+
if (planned !== undefined) {
|
|
127
|
+
targetSource = typeof planned.source === "string" ? planned.source : "";
|
|
128
|
+
}
|
|
129
|
+
else if (prolog.queryEntities) {
|
|
124
130
|
const targetPage = await prolog.queryEntities({
|
|
125
131
|
id: targetId,
|
|
126
132
|
limit: 1,
|
|
@@ -146,9 +152,12 @@ export function formatRelationshipSourceMismatch(entityId, relationship) {
|
|
|
146
152
|
const to = stringField(relationship, "to");
|
|
147
153
|
return `Relationship source must match the upserted entity ${entityId}; received from=${from}. To add ${from} -> ${to}, upsert ${from} instead and include the relationship in that call.`;
|
|
148
154
|
}
|
|
149
|
-
async function endpointType(prolog, entity, endpointId) {
|
|
155
|
+
async function endpointType(prolog, entity, endpointId, staged) {
|
|
150
156
|
if (endpointId === entity.id && typeof entity.type === "string")
|
|
151
157
|
return entity.type;
|
|
158
|
+
const planned = staged?.entities.get(endpointId);
|
|
159
|
+
if (planned !== undefined && typeof planned.type === "string")
|
|
160
|
+
return planned.type;
|
|
152
161
|
let result;
|
|
153
162
|
try {
|
|
154
163
|
result = await prolog.query(`kb_entity('${escapeAtom(endpointId)}', Type, _)`);
|
|
@@ -163,10 +172,10 @@ async function endpointType(prolog, entity, endpointId) {
|
|
|
163
172
|
const type = result.bindings.Type;
|
|
164
173
|
return type ? type.replace(/^['"]|['"]$/g, "") : null;
|
|
165
174
|
}
|
|
166
|
-
export async function validateLiveRelationshipTargets(prolog, entity, relationships) {
|
|
175
|
+
export async function validateLiveRelationshipTargets(prolog, entity, relationships, staged) {
|
|
167
176
|
for (const relationship of relationships) {
|
|
168
|
-
const fromType = await endpointType(prolog, entity, stringField(relationship, "from"));
|
|
169
|
-
const toType = await endpointType(prolog, entity, stringField(relationship, "to"));
|
|
177
|
+
const fromType = await endpointType(prolog, entity, stringField(relationship, "from"), staged);
|
|
178
|
+
const toType = await endpointType(prolog, entity, stringField(relationship, "to"), staged);
|
|
170
179
|
if (fromType === null || toType === null)
|
|
171
180
|
continue;
|
|
172
181
|
const tuple = {
|
|
@@ -179,12 +188,21 @@ export async function validateLiveRelationshipTargets(prolog, entity, relationsh
|
|
|
179
188
|
throw new Error(formatInvalidRelationshipTuple(tuple));
|
|
180
189
|
}
|
|
181
190
|
}
|
|
182
|
-
|
|
191
|
+
function plannedFactKind(planned) {
|
|
192
|
+
return planned.type === "fact" && typeof planned.fact_kind === "string"
|
|
193
|
+
? planned.fact_kind
|
|
194
|
+
: undefined;
|
|
195
|
+
}
|
|
196
|
+
export async function validateStrictLanePairing(prolog, relationships, staged) {
|
|
183
197
|
for (const relationship of relationships) {
|
|
184
198
|
const target = stringField(relationship, "to");
|
|
199
|
+
// A target an earlier plan step writes is judged by that write.
|
|
200
|
+
const planned = staged?.entities.get(target);
|
|
185
201
|
if (relationship.type === "requires_rule") {
|
|
186
|
-
const
|
|
187
|
-
|
|
202
|
+
const isRule = planned !== undefined
|
|
203
|
+
? plannedFactKind(planned) === "rule"
|
|
204
|
+
: (await prolog.query(`once((kb_entity('${escapeAtom(target)}', fact, _RuleProps), memberchk(fact_kind=_RuleKind, _RuleProps), normalize_term_atom(_RuleKind, rule)))`)).success;
|
|
205
|
+
if (!isRule) {
|
|
188
206
|
throw new Error(`Relationship 'requires_rule' requires target '${target}' to be a fact_kind=rule fact.`);
|
|
189
207
|
}
|
|
190
208
|
continue;
|
|
@@ -196,8 +214,10 @@ export async function validateStrictLanePairing(prolog, relationships) {
|
|
|
196
214
|
: null;
|
|
197
215
|
if (wrongKind === null)
|
|
198
216
|
continue;
|
|
199
|
-
const
|
|
200
|
-
|
|
217
|
+
const isWrongKind = planned !== undefined
|
|
218
|
+
? plannedFactKind(planned) === wrongKind
|
|
219
|
+
: (await prolog.query(`once((kb_entity('${escapeAtom(target)}', fact, _SlpProps), memberchk(fact_kind=_SlpFK, _SlpProps), normalize_term_atom(_SlpFK, ${wrongKind})))`)).success;
|
|
220
|
+
if (isWrongKind)
|
|
201
221
|
throw wrongKindRelationshipError(String(relationship.type), target, wrongKind);
|
|
202
222
|
}
|
|
203
223
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAwDpD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,CAMR;AAGD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAOxE;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBtD"}
|
|
@@ -12,6 +12,7 @@ const ATOM_FIELDS = [
|
|
|
12
12
|
"operator",
|
|
13
13
|
"value_type",
|
|
14
14
|
"polarity",
|
|
15
|
+
"expects",
|
|
15
16
|
];
|
|
16
17
|
const STRING_FIELDS = [
|
|
17
18
|
"id",
|
|
@@ -32,7 +33,8 @@ function serializeValue(key, value) {
|
|
|
32
33
|
key === "semantic_inventory" ||
|
|
33
34
|
key === "proof_contract" ||
|
|
34
35
|
key === "proof_bindings" ||
|
|
35
|
-
key === "proof_receipts"
|
|
36
|
+
key === "proof_receipts" ||
|
|
37
|
+
key === "origin") {
|
|
36
38
|
return toPrologString(JSON.stringify(value));
|
|
37
39
|
}
|
|
38
40
|
if (Array.isArray(value))
|
|
@@ -62,6 +62,12 @@ export declare function renderYamlRelationshipDeletion(sourcePathValue: string,
|
|
|
62
62
|
body: string;
|
|
63
63
|
removed: boolean;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* The bytes an upsert of `entity` publishes at `relativePath`, merged into the
|
|
67
|
+
* document's current content. Compile plans render their documents with it
|
|
68
|
+
* so a plan writes exactly what `kb_upsert` would.
|
|
69
|
+
*/
|
|
70
|
+
export declare function renderSourceDocument(input: UpsertInput, entity: Readonly<Record<string, unknown>>, existingContent: string | undefined, relativePath: string): string;
|
|
65
71
|
export declare function writeSourceForUpsert(input: UpsertInput, entity: Readonly<Record<string, unknown>>, existing?: Readonly<Record<string, unknown>>, context?: OperationContext, sourceDocumentOverride?: string): Promise<{
|
|
66
72
|
receipt: SourceWriteReceipt;
|
|
67
73
|
rollback: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-authoring.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/source-authoring.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAMjF,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAmBH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,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CA4DpC;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAiEpC;
|
|
1
|
+
{"version":3,"file":"source-authoring.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/source-authoring.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAMjF,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAmBH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,IAAI,CAiBN;AAED;;;;GAIG;AAEH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,IAAI,CAMN;AAgBD,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,MAAM,CAqCR;AAED,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,MAAM,CAoBR;AAsBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM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W,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,YAAY,EAAE,MAAM,GACnB,MAAM,CAsBR;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,gBAAgB,EAC1B,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC;IACT,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,GAAG,IAAI,CAAC,CAoHR;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC3C,MAAM,CAOR"}
|
|
@@ -601,7 +601,13 @@ export function renderYamlRelationshipDeletion(sourcePathValue, existingContent,
|
|
|
601
601
|
? { body: doc.toString(AUTHORED_YAML_OPTIONS), removed: true }
|
|
602
602
|
: { body: existingContent, removed: false };
|
|
603
603
|
}
|
|
604
|
-
|
|
604
|
+
/**
|
|
605
|
+
* The bytes an upsert of `entity` publishes at `relativePath`, merged into the
|
|
606
|
+
* document's current content. Compile plans render their documents with it
|
|
607
|
+
* so a plan writes exactly what `kb_upsert` would.
|
|
608
|
+
*/
|
|
609
|
+
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
610
|
+
export function renderSourceDocument(input, entity, existingContent, relativePath) {
|
|
605
611
|
const extension = path.extname(relativePath).toLowerCase();
|
|
606
612
|
if (extension === ".yaml" || extension === ".yml") {
|
|
607
613
|
if (input.type !== "symbol") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-refresh.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-refresh.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAgBjF,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,WAAW,GACX,SAAS,GACT,WAAW,CAAC;AAGhB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,0BAA0B,CAAC;CACnD,CAAC;AAGF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,IAAI,IAAI,CAAC;CAClB,CAAC;AAEF,KAAK,qBAAqB,GAAG,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,KACtB,OAAO,CAAC,aAAa,CAAC,CAAC;AAsD5B,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,IAAI,CAMN;
|
|
1
|
+
{"version":3,"file":"symbol-refresh.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-refresh.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAgBjF,MAAM,MAAM,sB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-165,7 +165,10 @@ async function refreshUnlocked(symbolId, context, options = {}) {
|
|
|
165
165
|
}
|
|
166
166
|
const sourceFile = typeof entry.sourceFile === "string" ? entry.sourceFile : "";
|
|
167
167
|
const title = typeof entry.title === "string" ? entry.title : "";
|
|
168
|
-
|
|
168
|
+
// Targeted refresh publishes coordinates only, like
|
|
169
|
+
// `kibi sync --refresh-symbol-coordinates`, so decorated Python may bind
|
|
170
|
+
// explicit declarations while the analysis itself stays partial.
|
|
171
|
+
const [enriched] = await enrichSymbolCoordinates([{ ...entry, id: symbolId, title, sourceFile }], context.workspaceRoot, { allowPythonDecoratorCoordinates: true });
|
|
169
172
|
let next = coordinate(enriched);
|
|
170
173
|
let sourceText = next === null ? sourceTextFor(sourceFile, context.workspaceRoot) : null;
|
|
171
174
|
if (next === null &&
|
|
@@ -12,9 +12,23 @@ export type UpsertInput = {
|
|
|
12
12
|
/** Complete document bytes. Omit to preserve the existing body bytes. */
|
|
13
13
|
readonly body?: string;
|
|
14
14
|
};
|
|
15
|
+
/** Validate and preview the write without mutating the KB. */
|
|
16
|
+
readonly dryRun?: boolean;
|
|
15
17
|
readonly _skipContradictionCheck?: boolean;
|
|
16
18
|
readonly _requestId?: string;
|
|
17
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Store state an upsert's validation must see in addition to the live KB:
|
|
22
|
+
* what earlier steps of the same plan will have written by the time this
|
|
23
|
+
* upsert runs. Validators treat these entities and relationships as present,
|
|
24
|
+
* and a staged entity shadows the stored entity with the same id.
|
|
25
|
+
*/
|
|
26
|
+
export type StagedUpsertState = {
|
|
27
|
+
/** Validated entities (id, type and properties) by id. */
|
|
28
|
+
readonly entities: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
|
|
29
|
+
/** Relationships the earlier steps add, in step order. */
|
|
30
|
+
readonly relationships: readonly RelationshipInput[];
|
|
31
|
+
};
|
|
18
32
|
export type ValidatedUpsert = {
|
|
19
33
|
readonly entity: Record<string, unknown>;
|
|
20
34
|
readonly rel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IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;QACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;KAC3B,EAAE,CAAC;IACJ,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,QAAQ,CAAC,OAAO,EAAE,8BAA8B,CAAC;QACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;QACtC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;QAC/D,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS;YAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;YAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;YACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;SACxB,EAAE,CAAC;QACJ,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;KACxC,CAAC;CACH,CAAC"}
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
2
|
import type { OperationResult } from "../../public/operations/types.js";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
3
|
+
import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
|
|
4
|
+
import type { RelationshipInput, StagedUpsertState, UpsertInput, UpsertPayload, ValidatedUpsert } from "./types.js";
|
|
5
|
+
export declare function assertRelationshipShardContained(workspaceRoot: string, shardPath: string): void;
|
|
6
|
+
export declare function validateAppendOnlyProofReceipts(entity: Readonly<Record<string, unknown>>, context: OperationContext, staged?: StagedUpsertState): Promise<void>;
|
|
7
|
+
export declare function effectiveRelationships(input: UpsertInput, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], context: OperationContext, staged?: StagedUpsertState): Promise<readonly RelationshipInput[]>;
|
|
8
|
+
export type UpsertValidationOptions = Readonly<{
|
|
9
|
+
/** Skip the append-only receipt check (kibi proof prune only). */
|
|
10
|
+
readonly allowReceiptsPrune?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* What earlier steps of the same plan will have written when this upsert
|
|
13
|
+
* runs. Entities and relationships they create count as present.
|
|
14
|
+
*/
|
|
15
|
+
readonly staged?: StagedUpsertState;
|
|
16
|
+
}>;
|
|
17
|
+
export type UpsertValidation = Readonly<{
|
|
18
|
+
readonly validated: ValidatedUpsert;
|
|
19
|
+
/** The upsert's relationships merged with the entity's existing ones. */
|
|
20
|
+
readonly relationships: readonly RelationshipInput[];
|
|
21
|
+
readonly semantic: ReturnType<typeof analyzeSemanticAdvisorInput>;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* The complete validation an upsert passes before its first write: schema,
|
|
25
|
+
* append-only proof receipts, relationship sources, symbol granularity,
|
|
26
|
+
* strict-lane pairing, live relationship targets, supersedes direction,
|
|
27
|
+
* proposition-complete ingestion, logical grounding claim keys and predicate
|
|
28
|
+
* argument vocabulary. executeUpsert runs it for every write, and
|
|
29
|
+
* kb_apply_plan runs it for every plan step before the plan's first write,
|
|
30
|
+
* passing the earlier steps' writes as `staged`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateUpsertForCommit(input: UpsertInput, context: OperationContext, options?: UpsertValidationOptions): Promise<UpsertValidation>;
|
|
6
33
|
export type UpsertExecutionOptions = Readonly<{
|
|
7
34
|
/**
|
|
8
35
|
* Internal escape hatch for proof-receipt ingest: when provided, the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAUxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAiCnF,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAC;AA6CpB,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,IAAI,CAkBN;AAmCD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CA8BvC;AAmCD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,kEAAkE;IAClE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CACrC,CAAC,CAAC;AAGH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;CACnE,CAAC,CAAC;AAGH;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CAkE3B;AAGD,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C;;;;;;OAMG;IAEH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC,CAAC;AAyBH,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAggBzC"}
|
|
@@ -14,6 +14,8 @@ import { entityIdStyleWarnings } from "../../utils/entity-id-style.js";
|
|
|
14
14
|
import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
|
|
15
15
|
import { assertLogicalGroundingClaimKeys, assertSemanticInventoryBoundary, } from "../semantic-advisor/ingestion-boundary.js";
|
|
16
16
|
import { buildUpsertCommitGoal, formatUpsertError } from "./contradictions.js";
|
|
17
|
+
import { resolveUpsertOrigin } from "./origin.js";
|
|
18
|
+
import { planRecoveryNotes, settlePendingPlanApplyJournals, withPlanRecoveryNotes, } from "./plan-apply-journal.js";
|
|
17
19
|
import { assertPredicateArgumentVocabulary } from "./predicate-vocabulary-guard.js";
|
|
18
20
|
import { existingRelationships, validateLiveRelationshipTargets, validateRelationshipSources, validateStrictLanePairing, validateSupersedesSourceHistory, } from "./relationships.js";
|
|
19
21
|
import { MutationRollbackFailureError, MutationSaga } from "./saga.js";
|
|
@@ -51,7 +53,8 @@ function fileHash(pathname) {
|
|
|
51
53
|
function textHash(value) {
|
|
52
54
|
return createHash("sha256").update(value).digest("hex");
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
// implements REQ-core-atomic-upsert-persistence
|
|
57
|
+
export function assertRelationshipShardContained(workspaceRoot, shardPath) {
|
|
55
58
|
const root = path.resolve(workspaceRoot);
|
|
56
59
|
const relationshipRoot = path.resolve(root, ".kb", "relationships");
|
|
57
60
|
const absolute = path.resolve(shardPath);
|
|
@@ -92,13 +95,20 @@ function restoreRelationshipShard(shardPath, before, expectedAfterHash) {
|
|
|
92
95
|
}
|
|
93
96
|
writeFileSync(shardPath, before, "utf8");
|
|
94
97
|
}
|
|
95
|
-
export async function validateAppendOnlyProofReceipts(entity, context) {
|
|
98
|
+
export async function validateAppendOnlyProofReceipts(entity, context, staged) {
|
|
96
99
|
if (entity.type !== "test")
|
|
97
100
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
// An earlier plan step that writes the same test is the history this
|
|
102
|
+
// write must extend.
|
|
103
|
+
const planned = staged?.entities.get(String(entity.id));
|
|
104
|
+
const existing = planned !== undefined
|
|
105
|
+
? planned.type === "test"
|
|
106
|
+
? [planned]
|
|
107
|
+
: []
|
|
108
|
+
: await loadEntities(requireProlog(context), {
|
|
109
|
+
id: String(entity.id),
|
|
110
|
+
type: "test",
|
|
111
|
+
});
|
|
102
112
|
const previous = receiptRecords(existing[0]?.proof_receipts);
|
|
103
113
|
if (!previous || previous.length === 0)
|
|
104
114
|
return;
|
|
@@ -108,19 +118,24 @@ export async function validateAppendOnlyProofReceipts(entity, context) {
|
|
|
108
118
|
throw new Error(`Entity validation failed: ${errors.join("; ")}`);
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
|
-
export async function effectiveRelationships(input, entity, relationships, context) {
|
|
121
|
+
export async function effectiveRelationships(input, entity, relationships, context, staged) {
|
|
112
122
|
const prolog = requireProlog(context);
|
|
123
|
+
// Relationships an earlier plan step adds from this entity will exist when
|
|
124
|
+
// this upsert runs.
|
|
125
|
+
const plannedOwn = (staged?.relationships ?? []).filter((relationship) => relationship.from === input.id);
|
|
113
126
|
const exists = await prolog.query(`once(kb_entity('${escapeAtom(input.id)}', _, _))`);
|
|
114
|
-
if (!exists.success)
|
|
127
|
+
if (!exists.success && plannedOwn.length === 0)
|
|
115
128
|
return relationships;
|
|
116
129
|
try {
|
|
117
|
-
const current =
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
const current = exists.success
|
|
131
|
+
? (await existingRelationships(prolog, String(entity.id)))
|
|
132
|
+
// An upsert owns only relationships whose source is the upserted
|
|
133
|
+
// entity. Incoming relationships must not be copied into its
|
|
134
|
+
// validation or canonical source projection.
|
|
135
|
+
.filter((relationship) => relationship.from === input.id)
|
|
136
|
+
: [];
|
|
122
137
|
const merged = new Map();
|
|
123
|
-
for (const relationship of [...current, ...relationships]) {
|
|
138
|
+
for (const relationship of [...current, ...plannedOwn, ...relationships]) {
|
|
124
139
|
const key = `${String(relationship.type)}\u0000${String(relationship.from)}\u0000${String(relationship.to)}`;
|
|
125
140
|
// The explicit input wins so any supplied metadata is retained.
|
|
126
141
|
merged.set(key, relationship);
|
|
@@ -161,7 +176,68 @@ function reextractCanonicalSymbolEntity(symbolId, authoredRelativePath, workspac
|
|
|
161
176
|
: { sourceFile: result.sourceFile }),
|
|
162
177
|
};
|
|
163
178
|
}
|
|
179
|
+
// implements REQ-kibi-truthful-consistency
|
|
180
|
+
/**
|
|
181
|
+
* The complete validation an upsert passes before its first write: schema,
|
|
182
|
+
* append-only proof receipts, relationship sources, symbol granularity,
|
|
183
|
+
* strict-lane pairing, live relationship targets, supersedes direction,
|
|
184
|
+
* proposition-complete ingestion, logical grounding claim keys and predicate
|
|
185
|
+
* argument vocabulary. executeUpsert runs it for every write, and
|
|
186
|
+
* kb_apply_plan runs it for every plan step before the plan's first write,
|
|
187
|
+
* passing the earlier steps' writes as `staged`.
|
|
188
|
+
*/
|
|
189
|
+
export async function validateUpsertForCommit(input, context, options = {}) {
|
|
190
|
+
const prolog = requireProlog(context);
|
|
191
|
+
const staged = options.staged;
|
|
192
|
+
const validated = validateUpsertInput(input, context.clock());
|
|
193
|
+
if (options.allowReceiptsPrune !== true) {
|
|
194
|
+
await validateAppendOnlyProofReceipts(validated.entity, context, staged);
|
|
195
|
+
}
|
|
196
|
+
validateRelationshipSources(input.id, validated.relationships);
|
|
197
|
+
await validateSymbolGranularity(validated.entity, validated.relationships, context);
|
|
198
|
+
const relationships = await effectiveRelationships(input, validated.entity, validated.relationships, context, staged);
|
|
199
|
+
await validateStrictLanePairing(prolog, validated.relationships, staged);
|
|
200
|
+
await validateLiveRelationshipTargets(prolog, validated.entity, validated.relationships, staged);
|
|
201
|
+
await validateSupersedesSourceHistory(prolog, validated.entity, validated.relationships, context.workspaceRoot, undefined, staged);
|
|
202
|
+
const semantic = analyzeSemanticAdvisorInput({
|
|
203
|
+
payload: { ...input, relationships },
|
|
204
|
+
});
|
|
205
|
+
assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
|
|
206
|
+
await assertLogicalGroundingClaimKeys(prolog, { ...input, relationships }, relationships, staged);
|
|
207
|
+
await assertPredicateArgumentVocabulary(prolog, validated.entity, staged);
|
|
208
|
+
// The origin the write records is added last: none of the checks above
|
|
209
|
+
// reads it, and a rejected payload never pays for the stored-origin read.
|
|
210
|
+
const recorded = await resolveUpsertOrigin(input, prolog, context.clock(), staged);
|
|
211
|
+
return {
|
|
212
|
+
validated: recorded === input
|
|
213
|
+
? validated
|
|
214
|
+
: validateUpsertInput(recorded, context.clock()),
|
|
215
|
+
relationships,
|
|
216
|
+
semantic,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// implements REQ-kibi-operation-interface-parity
|
|
220
|
+
/**
|
|
221
|
+
* A dry run is the former kb_validate_upsert preflight on the kb_upsert
|
|
222
|
+
* surface: the same validation and semantic advisor receipt, no KB or
|
|
223
|
+
* workspace write, and both write effects reported as skipped.
|
|
224
|
+
*/
|
|
225
|
+
async function dryRunUpsert(input, context) {
|
|
226
|
+
const { dryRun: _dryRun, ...payload } = input;
|
|
227
|
+
const { executeValidateUpsert } = await import("./validate-upsert.js");
|
|
228
|
+
const result = await executeValidateUpsert(payload, context);
|
|
229
|
+
return {
|
|
230
|
+
content: result.content,
|
|
231
|
+
structuredContent: {
|
|
232
|
+
...result.structuredContent,
|
|
233
|
+
dryRun: true,
|
|
234
|
+
skippedEffects: ["kb-write", "workspace-write"],
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
164
238
|
export async function executeUpsert(input, context, options = {}) {
|
|
239
|
+
if (input.dryRun === true)
|
|
240
|
+
return dryRunUpsert(input, context);
|
|
165
241
|
const branchAttachment = context.branchAttachment ?? resolveBranchAttachment(context.workspaceRoot);
|
|
166
242
|
if ("error" in branchAttachment) {
|
|
167
243
|
throw new Error(`Unable to resolve KB branch: ${branchAttachment.error}`);
|
|
@@ -186,6 +262,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
186
262
|
let operationFailure;
|
|
187
263
|
const relationshipShardBefore = new Map();
|
|
188
264
|
const relationshipShardAfterHash = new Map();
|
|
265
|
+
let planRecoveryWarnings = [];
|
|
189
266
|
const holdsSymbolCompilerLock = input.type === "symbol" &&
|
|
190
267
|
context.fs !== undefined &&
|
|
191
268
|
context.sourceFirst !== false;
|
|
@@ -195,6 +272,10 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
195
272
|
try {
|
|
196
273
|
if (holdsSourceMutationLock) {
|
|
197
274
|
sourceMutationLock = await acquireWorkspaceMutationLock(context.workspaceRoot);
|
|
275
|
+
// implements REQ-core-atomic-upsert-persistence
|
|
276
|
+
// An interrupted kb_apply_plan left a journal: complete or roll it back
|
|
277
|
+
// before this write reads or changes the files the journal guards.
|
|
278
|
+
planRecoveryWarnings = planRecoveryNotes(await settlePendingPlanApplyJournals({ ...context, branchAttachment }, { prolog: async () => prolog }));
|
|
198
279
|
}
|
|
199
280
|
if (holdsSymbolCompilerLock) {
|
|
200
281
|
// Symbol source publication, coordinate refresh, canonical
|
|
@@ -203,24 +284,11 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
203
284
|
// upserts cannot lose updates.
|
|
204
285
|
compilerLock = await acquireSymbolCompilerLock(context.workspaceRoot);
|
|
205
286
|
}
|
|
206
|
-
const validated =
|
|
207
|
-
|
|
208
|
-
await validateAppendOnlyProofReceipts(validated.entity, context);
|
|
209
|
-
}
|
|
210
|
-
validateRelationshipSources(input.id, validated.relationships);
|
|
211
|
-
await validateSymbolGranularity(validated.entity, validated.relationships, context);
|
|
212
|
-
const relationships = await effectiveRelationships(input, validated.entity, validated.relationships, context);
|
|
213
|
-
relationshipCount = validated.relationships.length;
|
|
214
|
-
await validateStrictLanePairing(prolog, validated.relationships);
|
|
215
|
-
await validateLiveRelationshipTargets(prolog, validated.entity, validated.relationships);
|
|
216
|
-
await validateSupersedesSourceHistory(prolog, validated.entity, validated.relationships, context.workspaceRoot);
|
|
217
|
-
const semantic = analyzeSemanticAdvisorInput({
|
|
218
|
-
payload: { ...input, relationships },
|
|
287
|
+
const { validated, relationships, semantic } = await validateUpsertForCommit(input, context, {
|
|
288
|
+
allowReceiptsPrune: options.allowReceiptsPrune === true,
|
|
219
289
|
});
|
|
290
|
+
relationshipCount = validated.relationships.length;
|
|
220
291
|
semanticAdvisor = semantic.receipt;
|
|
221
|
-
assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
|
|
222
|
-
await assertLogicalGroundingClaimKeys(prolog, { ...input, relationships }, relationships);
|
|
223
|
-
await assertPredicateArgumentVocabulary(prolog, validated.entity);
|
|
224
292
|
if (context.fs !== undefined && context.sourceFirst !== false) {
|
|
225
293
|
const existingRows = await loadEntities(prolog, {
|
|
226
294
|
id: input.id,
|
|
@@ -374,7 +442,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
374
442
|
created: 0,
|
|
375
443
|
updated: 0,
|
|
376
444
|
relationships_created: validated.relationships.length,
|
|
377
|
-
warnings: semantic.warnings,
|
|
445
|
+
warnings: [...planRecoveryWarnings, ...semantic.warnings],
|
|
378
446
|
semanticAdvisor: semantic.receipt,
|
|
379
447
|
deferredCommit,
|
|
380
448
|
...(sourceWrite ? { sourceWrites: [sourceWrite.receipt] } : {}),
|
|
@@ -444,6 +512,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
444
512
|
updated: changeKind === "updated" ? 1 : 0,
|
|
445
513
|
relationships_created: validated.relationships.length,
|
|
446
514
|
warnings: [
|
|
515
|
+
...planRecoveryWarnings,
|
|
447
516
|
...semantic.warnings,
|
|
448
517
|
...coverage,
|
|
449
518
|
...idStyleWarnings,
|
|
@@ -519,7 +588,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
519
588
|
created: changeKind === "created" ? 1 : 0,
|
|
520
589
|
updated: changeKind === "updated" ? 1 : 0,
|
|
521
590
|
relationships_created: relationshipCount,
|
|
522
|
-
warnings: [detail],
|
|
591
|
+
warnings: [...planRecoveryWarnings, detail],
|
|
523
592
|
semanticAdvisor: semanticAdvisor,
|
|
524
593
|
status: "committed_with_repairs",
|
|
525
594
|
effectFailures: [
|
|
@@ -560,11 +629,12 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
560
629
|
throw failure;
|
|
561
630
|
}
|
|
562
631
|
if (error instanceof OperationError) {
|
|
563
|
-
|
|
564
|
-
|
|
632
|
+
const failure = withPlanRecoveryNotes(error, planRecoveryWarnings);
|
|
633
|
+
operationFailure = { error: failure };
|
|
634
|
+
throw failure;
|
|
565
635
|
}
|
|
566
636
|
const message = error instanceof Error ? error.message : String(error);
|
|
567
|
-
const failure = new Error(`Upsert execution failed: ${message}`);
|
|
637
|
+
const failure = withPlanRecoveryNotes(new Error(`Upsert execution failed: ${message}`), planRecoveryWarnings);
|
|
568
638
|
operationFailure = { error: failure };
|
|
569
639
|
throw failure;
|
|
570
640
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
2
|
import type { OperationResult } from "../../public/operations/types.js";
|
|
3
3
|
import type { UpsertInput, ValidateUpsertPayload } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* kb_upsert dryRun:true (and the former kb_validate_upsert preflight). With a
|
|
6
|
+
* store it runs validateUpsertForCommit, the exact validation a real
|
|
7
|
+
* kb_upsert runs before its first write, so a dry run accepts only what the
|
|
8
|
+
* write would accept; without a store it runs the store-independent checks.
|
|
9
|
+
*/
|
|
4
10
|
export declare function executeValidateUpsert(input: UpsertInput, context: OperationContext): Promise<OperationResult<ValidateUpsertPayload>>;
|
|
5
11
|
//# sourceMappingURL=validate-upsert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validate-upsert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validate-upsert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA+CrE;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAwDjD"}
|