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
|
@@ -33,10 +33,18 @@ export type ProposalDecision = Readonly<{
|
|
|
33
33
|
proposalId: string;
|
|
34
34
|
decision: "accept" | "reject";
|
|
35
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* One witness from the staged what-if analysis. The engine's full evidence
|
|
38
|
+
* (sides, facts, scenario, comparison) is kept alongside these normalized
|
|
39
|
+
* fields so callers can act on more than requirement ids.
|
|
40
|
+
*/
|
|
36
41
|
export type ContradictionWitness = Readonly<{
|
|
37
42
|
requirements: readonly string[];
|
|
38
43
|
reason: string;
|
|
39
|
-
|
|
44
|
+
status?: string;
|
|
45
|
+
/** property | predicate | rule | scenario_feasibility */
|
|
46
|
+
kind?: string;
|
|
47
|
+
} & Record<string, unknown>>;
|
|
40
48
|
export type TraceabilityProposal = Readonly<{
|
|
41
49
|
proposalId: string;
|
|
42
50
|
candidateId: string;
|
|
@@ -84,7 +92,14 @@ export type CompilePlanV1 = Readonly<{
|
|
|
84
92
|
}[];
|
|
85
93
|
contradictionAnalysis: {
|
|
86
94
|
outcome: "no_conflict" | "conflict" | "unresolved";
|
|
95
|
+
/** Witnesses that decided the outcome: introduced ones, plus staged ones naming the target requirement. */
|
|
87
96
|
witnesses: readonly ContradictionWitness[];
|
|
97
|
+
/** Staged witnesses the current KB does not have. */
|
|
98
|
+
introduced?: readonly ContradictionWitness[];
|
|
99
|
+
/** Current witnesses the plan resolves. */
|
|
100
|
+
removed?: readonly ContradictionWitness[];
|
|
101
|
+
/** Staged witnesses that already exist in the current KB. */
|
|
102
|
+
unchanged?: readonly ContradictionWitness[];
|
|
88
103
|
};
|
|
89
104
|
proposals: readonly TraceabilityProposal[];
|
|
90
105
|
steps: readonly PlanStep[];
|
|
@@ -147,6 +162,24 @@ export type SourceWritePlan = Readonly<{
|
|
|
147
162
|
afterHash: string | null;
|
|
148
163
|
body?: string;
|
|
149
164
|
}>;
|
|
165
|
+
/** Rolled-back staging goal for a plan's steps (see what_if_analysis/2). */
|
|
166
|
+
export declare function planWhatIfGoal(steps: readonly PlanStep[], now: Date): string;
|
|
167
|
+
export type WhatIfAnalysis = Readonly<{
|
|
168
|
+
after: readonly ContradictionWitness[];
|
|
169
|
+
introduced: readonly ContradictionWitness[];
|
|
170
|
+
removed: readonly ContradictionWitness[];
|
|
171
|
+
unchanged: readonly ContradictionWitness[];
|
|
172
|
+
}>;
|
|
173
|
+
/**
|
|
174
|
+
* Parse checks:what_if_analysis_json/2 output. The binding is a quoted Prolog
|
|
175
|
+
* string, so the JSON may arrive encoded once more as a JSON string. A bare
|
|
176
|
+
* witness array (the what_if_contradiction_witnesses_json/2 shape) carries no
|
|
177
|
+
* current-KB baseline, so every witness in it is treated as introduced.
|
|
178
|
+
* Returns null when the output cannot be read.
|
|
179
|
+
*/
|
|
180
|
+
export declare function parseWhatIfAnalysis(raw: unknown): WhatIfAnalysis | null;
|
|
181
|
+
/** Blocking: a proven contradiction or an infeasible success scenario. */
|
|
182
|
+
export declare function isBlockingWitness(witness: ContradictionWitness): boolean;
|
|
150
183
|
export declare function executeCompileIntent(args: CompileIntentArgs, context: OperationContext): Promise<{
|
|
151
184
|
content: Array<{
|
|
152
185
|
type: "text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-intent.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/compile-intent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-intent.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/compile-intent.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAOlD,OAAO,KAAK,EAEV,2BAA2B,EAE5B,MAAM,8BAA8B,CAAC;AAGtC,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAC;AAGpE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC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,CAAC,CAAC;CACJ,CAAC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,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,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AA0UH,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,CAqC5E;AAGD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACvC,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C,OAAO,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACzC,SAAS,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC5C,CAAC,CAAC;AAqBH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAoBvE;AAGD,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAExE;AAqQD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,aAAa,CAAC;CAClC,CAAC,CA8YD"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { dump as dumpYaml } from "js-yaml";
|
|
4
3
|
import { executeIntentSearch, } from "../../intent-search.js";
|
|
5
4
|
import { publicCapabilityStamp } from "../../plugins/compose-semantic-classifier.js";
|
|
6
|
-
import { normalizeEntityId
|
|
5
|
+
import { normalizeEntityId } from "../../prolog/codec.js";
|
|
7
6
|
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
8
7
|
import { executeStatus } from "../../public/operations/discovery-executors.js";
|
|
9
|
-
import {
|
|
8
|
+
import { buildWhatIfAnalysisGoal } from "../mutation/contradictions.js";
|
|
9
|
+
import { canonicalSourcePath } from "../mutation/source-authoring.js";
|
|
10
|
+
import { validateUpsertInput } from "../mutation/validation.js";
|
|
10
11
|
import { analyzeSemanticAdvisorInputWithPlugins } from "../semantic-advisor/plugin-orchestration.js";
|
|
11
12
|
import { canonicalize } from "../semantic-advisor/shared.js";
|
|
12
|
-
// implements REQ-kibi-change-to-proof-plan-compiler
|
|
13
|
+
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
13
14
|
export const COMPILE_PLAN_VERSION = "kibi.compile-plan.v1";
|
|
14
|
-
// implements REQ-kibi-change-to-proof-plan-compiler
|
|
15
|
+
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
15
16
|
export function compilePlanHash(plan) {
|
|
16
17
|
const { planHash: _ignored, ...body } = plan;
|
|
17
18
|
return hash(body);
|
|
@@ -103,15 +104,56 @@ function mergeSteps(steps) {
|
|
|
103
104
|
]);
|
|
104
105
|
merged.set(key, { ...previous, ...step, properties, relationships });
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// Steps apply in order and a relationship needs both endpoints, so order
|
|
108
|
+
// by what links to what: tests before the scenarios that are verified_by
|
|
109
|
+
// them, and the requirement (specified_by, requires_*) last.
|
|
110
|
+
const rank = (step) => ({ test: 1, scenario: 2, req: 3 })[text(step.type)] ?? 0;
|
|
111
|
+
return [...merged.values()].sort((left, right) => rank(left) - rank(right) || text(left.id).localeCompare(text(right.id)));
|
|
111
112
|
}
|
|
112
113
|
function isRecord(value) {
|
|
113
114
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
114
115
|
}
|
|
116
|
+
// implements REQ-kibi-truthful-consistency
|
|
117
|
+
// Each advisor suggestion carries an inventory in which only its own clause is
|
|
118
|
+
// modeled, so merging suggestion steps left the requirement with whichever
|
|
119
|
+
// inventory came last (or none). The compiled plan already knows every
|
|
120
|
+
// proposition's final status: write that one inventory, and a logic_claims
|
|
121
|
+
// manifest covering every assertive proposition, onto the requirement step.
|
|
122
|
+
function withRequirementInventory(steps, requirementId, receipt, propositions) {
|
|
123
|
+
if (propositions.length === 0)
|
|
124
|
+
return [...steps];
|
|
125
|
+
const roles = new Map(receipt.propositions.map((proposition) => [
|
|
126
|
+
proposition.claim_key,
|
|
127
|
+
proposition.role,
|
|
128
|
+
]));
|
|
129
|
+
const inventory = propositions.map((proposition) => ({
|
|
130
|
+
claim_key: proposition.claimKey,
|
|
131
|
+
claim_text: proposition.text,
|
|
132
|
+
role: roles.get(proposition.claimKey) ?? "descriptive",
|
|
133
|
+
status: proposition.status,
|
|
134
|
+
span: proposition.span,
|
|
135
|
+
}));
|
|
136
|
+
const logicClaims = propositions
|
|
137
|
+
.filter((proposition) => proposition.status !== "nonlogical")
|
|
138
|
+
.map((proposition) => proposition.claimKey);
|
|
139
|
+
return steps.map((step) => {
|
|
140
|
+
if (text(step.type) !== "req" || text(step.id) !== requirementId)
|
|
141
|
+
return step;
|
|
142
|
+
const properties = isRecord(step.properties) ? step.properties : {};
|
|
143
|
+
return {
|
|
144
|
+
...step,
|
|
145
|
+
properties: {
|
|
146
|
+
...properties,
|
|
147
|
+
logic_claims: logicClaims,
|
|
148
|
+
semantic_clauses: propositions.map((proposition) => proposition.text),
|
|
149
|
+
semantic_inventory_version: receipt.inventory_contract.version,
|
|
150
|
+
semantic_source_field: receipt.inventory_contract.source_field,
|
|
151
|
+
semantic_source_hash: receipt.inventory_contract.source_hash,
|
|
152
|
+
semantic_inventory: inventory,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
}
|
|
115
157
|
function propositionStatus(proposition, suggestion) {
|
|
116
158
|
if (proposition.role === "rationale" ||
|
|
117
159
|
proposition.role === "example" ||
|
|
@@ -166,81 +208,213 @@ async function sourceHashes(context, locations) {
|
|
|
166
208
|
}
|
|
167
209
|
return hashes;
|
|
168
210
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return
|
|
177
|
-
|
|
211
|
+
/**
|
|
212
|
+
* A markdown source location may name the requirement's authored document.
|
|
213
|
+
* Any other location is changed-code evidence and is never a write target.
|
|
214
|
+
*/
|
|
215
|
+
function requirementDocumentPath(locations) {
|
|
216
|
+
const explicit = locations?.[0]?.path?.trim().replaceAll("\\", "/");
|
|
217
|
+
if (!explicit || !/\.(?:md|mdx)$/i.test(explicit))
|
|
218
|
+
return undefined;
|
|
219
|
+
// Kibi owns the .kb layout: entities there live at their canonical path.
|
|
220
|
+
if (explicit === ".kb" || explicit.startsWith(".kb/"))
|
|
221
|
+
return undefined;
|
|
222
|
+
return explicit;
|
|
178
223
|
}
|
|
179
|
-
|
|
224
|
+
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
225
|
+
/**
|
|
226
|
+
* Name the authored document every entity step writes, as `kb_upsert` would
|
|
227
|
+
* choose it: the entity's existing authored document, else its canonical
|
|
228
|
+
* `.kb/<lane>/<ID>.md` (the requirement may name its own markdown document).
|
|
229
|
+
* `kb_apply_plan` renders each step's entity into its document and journals
|
|
230
|
+
* the bytes with the rest of the plan. Without documents a plan's entities
|
|
231
|
+
* lived only in the branch store and vanished on `kibi sync --rebuild` or a
|
|
232
|
+
* fresh clone.
|
|
233
|
+
*
|
|
234
|
+
* The plan stays deterministic: it names targets and the requirement's body,
|
|
235
|
+
* not bytes, because the document carries the origin the apply records.
|
|
236
|
+
* Symbol steps keep the manifest path through `kb_upsert`, which also
|
|
237
|
+
* refreshes their coordinates.
|
|
238
|
+
*/
|
|
239
|
+
async function withDocumentTargets(context, prolog, steps, requirement, now) {
|
|
180
240
|
if (!context.fs)
|
|
181
|
-
return [];
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
241
|
+
return [...steps];
|
|
242
|
+
const targeted = [];
|
|
243
|
+
for (const step of steps) {
|
|
244
|
+
const type = text(step.type);
|
|
245
|
+
const id = text(step.id);
|
|
246
|
+
const properties = isRecord(step.properties) ? step.properties : {};
|
|
247
|
+
if (type === "symbol" || Object.keys(properties).length === 0) {
|
|
248
|
+
targeted.push(step);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const stepDocument = isRecord(step.document) ? step.document : {};
|
|
252
|
+
const document = type === "req" && id === requirement.id
|
|
253
|
+
? {
|
|
254
|
+
body: requirement.body,
|
|
255
|
+
...(requirement.path !== undefined
|
|
256
|
+
? { path: requirement.path }
|
|
257
|
+
: {}),
|
|
258
|
+
}
|
|
259
|
+
: typeof stepDocument.body === "string"
|
|
260
|
+
? { body: stepDocument.body.replace(/\n*$/, "\n") }
|
|
261
|
+
: {};
|
|
262
|
+
const input = {
|
|
263
|
+
type,
|
|
264
|
+
id,
|
|
265
|
+
properties,
|
|
266
|
+
relationships: (Array.isArray(step.relationships)
|
|
267
|
+
? step.relationships.filter(isRecord)
|
|
268
|
+
: []),
|
|
269
|
+
document,
|
|
270
|
+
};
|
|
271
|
+
// An invalid entity or an unwritable document would fail the apply.
|
|
272
|
+
const { entity } = validateUpsertInput(input, now);
|
|
273
|
+
const [existing] = document.path === undefined
|
|
274
|
+
? await loadEntities(prolog, { id, type })
|
|
275
|
+
: [];
|
|
276
|
+
targeted.push({
|
|
277
|
+
...step,
|
|
278
|
+
document: {
|
|
279
|
+
...document,
|
|
280
|
+
path: canonicalSourcePath(context, input, entity, existing),
|
|
281
|
+
},
|
|
282
|
+
});
|
|
192
283
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
284
|
+
return targeted;
|
|
285
|
+
}
|
|
286
|
+
function generatedRequirementId(intent) {
|
|
287
|
+
return `REQ-${slug(intent)}-${shortHash(intent).toUpperCase()}`;
|
|
288
|
+
}
|
|
289
|
+
// implements REQ-kibi-truthful-consistency
|
|
290
|
+
/** Rolled-back staging goal for a plan's steps (see what_if_analysis/2). */
|
|
291
|
+
export function planWhatIfGoal(steps, now) {
|
|
292
|
+
return buildWhatIfAnalysisGoal(steps.map((step) => {
|
|
293
|
+
const relationships = (Array.isArray(step.relationships)
|
|
294
|
+
? step.relationships.filter(isRecord)
|
|
295
|
+
: []).map((relationship) => ({
|
|
296
|
+
type: text(relationship.type),
|
|
297
|
+
from: text(relationship.from),
|
|
298
|
+
to: text(relationship.to),
|
|
299
|
+
}));
|
|
300
|
+
const properties = isRecord(step.properties) ? step.properties : {};
|
|
301
|
+
if (Object.keys(properties).length === 0) {
|
|
302
|
+
return {
|
|
303
|
+
entity: { id: text(step.id), type: text(step.type) },
|
|
304
|
+
relationships,
|
|
305
|
+
skipContradictionCheck: true,
|
|
306
|
+
relationshipsOnly: true,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const validated = validateUpsertInput({
|
|
310
|
+
type: text(step.type),
|
|
311
|
+
id: text(step.id),
|
|
312
|
+
properties,
|
|
313
|
+
relationships,
|
|
314
|
+
}, now);
|
|
315
|
+
return {
|
|
316
|
+
entity: validated.entity,
|
|
317
|
+
relationships: validated.relationships,
|
|
318
|
+
skipContradictionCheck: true,
|
|
319
|
+
};
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
function whatIfWitness(witness) {
|
|
323
|
+
return {
|
|
324
|
+
...witness,
|
|
325
|
+
requirements: Array.isArray(witness.requirements)
|
|
326
|
+
? witness.requirements.map((id) => normalizeEntityId(String(id)))
|
|
327
|
+
: [],
|
|
328
|
+
reason: text(witness.reason),
|
|
329
|
+
status: text(witness.status) || "contradiction",
|
|
330
|
+
...(typeof witness.kind === "string" ? { kind: witness.kind } : {}),
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function whatIfWitnesses(value) {
|
|
334
|
+
return (Array.isArray(value) ? value.filter(isRecord) : []).map(whatIfWitness);
|
|
335
|
+
}
|
|
336
|
+
// implements REQ-kibi-truthful-consistency
|
|
337
|
+
/**
|
|
338
|
+
* Parse checks:what_if_analysis_json/2 output. The binding is a quoted Prolog
|
|
339
|
+
* string, so the JSON may arrive encoded once more as a JSON string. A bare
|
|
340
|
+
* witness array (the what_if_contradiction_witnesses_json/2 shape) carries no
|
|
341
|
+
* current-KB baseline, so every witness in it is treated as introduced.
|
|
342
|
+
* Returns null when the output cannot be read.
|
|
343
|
+
*/
|
|
344
|
+
export function parseWhatIfAnalysis(raw) {
|
|
345
|
+
if (typeof raw !== "string")
|
|
346
|
+
return null;
|
|
347
|
+
let parsed;
|
|
202
348
|
try {
|
|
203
|
-
|
|
349
|
+
parsed = JSON.parse(raw);
|
|
350
|
+
if (typeof parsed === "string")
|
|
351
|
+
parsed = JSON.parse(parsed);
|
|
204
352
|
}
|
|
205
353
|
catch {
|
|
206
|
-
|
|
354
|
+
return null;
|
|
207
355
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
];
|
|
356
|
+
if (Array.isArray(parsed)) {
|
|
357
|
+
const after = whatIfWitnesses(parsed);
|
|
358
|
+
return { after, introduced: after, removed: [], unchanged: [] };
|
|
359
|
+
}
|
|
360
|
+
if (!isRecord(parsed))
|
|
361
|
+
return null;
|
|
362
|
+
return {
|
|
363
|
+
after: whatIfWitnesses(parsed.after),
|
|
364
|
+
introduced: whatIfWitnesses(parsed.introduced),
|
|
365
|
+
removed: whatIfWitnesses(parsed.removed),
|
|
366
|
+
unchanged: whatIfWitnesses(parsed.unchanged),
|
|
367
|
+
};
|
|
221
368
|
}
|
|
222
|
-
|
|
223
|
-
|
|
369
|
+
// implements REQ-kibi-truthful-consistency
|
|
370
|
+
/** Blocking: a proven contradiction or an infeasible success scenario. */
|
|
371
|
+
export function isBlockingWitness(witness) {
|
|
372
|
+
return witness.status === "contradiction" || witness.status === "infeasible";
|
|
224
373
|
}
|
|
225
|
-
|
|
226
|
-
|
|
374
|
+
// implements REQ-kibi-truthful-consistency
|
|
375
|
+
// Check the KB as it would be after this plan, not the KB as it is: stage every
|
|
376
|
+
// planned step in a rolled-back transaction and compare its contradiction and
|
|
377
|
+
// scenario-feasibility witnesses with the current KB's. Any witness the plan
|
|
378
|
+
// introduces counts, whichever requirements it names; a staged witness that
|
|
379
|
+
// already existed counts only when it names the target requirement. Rule
|
|
380
|
+
// overlap the checker can neither prove nor exclude stays unresolved rather
|
|
381
|
+
// than becoming consistency.
|
|
382
|
+
async function contradictionAnalysis(prolog, requirementId, steps, now) {
|
|
383
|
+
const unavailable = {
|
|
384
|
+
outcome: "unresolved",
|
|
385
|
+
witnesses: [],
|
|
386
|
+
introduced: [],
|
|
387
|
+
removed: [],
|
|
388
|
+
unchanged: [],
|
|
389
|
+
};
|
|
390
|
+
let goal;
|
|
391
|
+
try {
|
|
392
|
+
goal = planWhatIfGoal(steps, now);
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
return unavailable;
|
|
396
|
+
}
|
|
397
|
+
const result = await prolog.query(goal);
|
|
227
398
|
if (!result.success)
|
|
228
|
-
return
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
399
|
+
return unavailable;
|
|
400
|
+
const analysis = parseWhatIfAnalysis(result.bindings.JsonString);
|
|
401
|
+
if (analysis === null)
|
|
402
|
+
return unavailable;
|
|
403
|
+
const witnesses = [
|
|
404
|
+
...analysis.introduced,
|
|
405
|
+
...analysis.unchanged.filter((witness) => witness.requirements.includes(requirementId)),
|
|
406
|
+
];
|
|
407
|
+
const outcome = witnesses.some(isBlockingWitness)
|
|
408
|
+
? "conflict"
|
|
409
|
+
: witnesses.length > 0
|
|
410
|
+
? "unresolved"
|
|
411
|
+
: "no_conflict";
|
|
241
412
|
return {
|
|
242
|
-
outcome
|
|
413
|
+
outcome,
|
|
243
414
|
witnesses,
|
|
415
|
+
introduced: analysis.introduced,
|
|
416
|
+
removed: analysis.removed,
|
|
417
|
+
unchanged: analysis.unchanged,
|
|
244
418
|
};
|
|
245
419
|
}
|
|
246
420
|
function proposalFor(requirementId, match) {
|
|
@@ -291,11 +465,16 @@ function applyAcceptedProposals(steps, proposals) {
|
|
|
291
465
|
function draftId(prefix, title, index) {
|
|
292
466
|
return `${prefix}-${slug(title)}-${shortHash(`${title}\0${index}`).toUpperCase()}`;
|
|
293
467
|
}
|
|
294
|
-
// implements REQ-kibi-change-to-proof-plan-compiler
|
|
468
|
+
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
295
469
|
function draftSteps(requirementId, scenarios, tests) {
|
|
296
470
|
const diagnostics = [];
|
|
297
471
|
const steps = [];
|
|
472
|
+
const testSteps = [];
|
|
298
473
|
const scenarioIds = [];
|
|
474
|
+
// verified_by runs scenario -> test, and an upsert step may only carry
|
|
475
|
+
// relationships from its own entity, so each scenario step carries the
|
|
476
|
+
// links to its tests and the tests are written before it.
|
|
477
|
+
const scenarioTests = new Map();
|
|
299
478
|
const linkedScenarioIds = new Set();
|
|
300
479
|
const duplicateScenarioIds = new Set();
|
|
301
480
|
const testIds = new Set();
|
|
@@ -306,15 +485,18 @@ function draftSteps(requirementId, scenarios, tests) {
|
|
|
306
485
|
diagnostics.push(`unresolved duplicate scenario draft ID ${id}; scenario associations are ambiguous.`);
|
|
307
486
|
}
|
|
308
487
|
scenarioIds.push(id);
|
|
488
|
+
// The draft prose is document body, not an entity property: the entity
|
|
489
|
+
// schema has no `body`, so carrying it in properties made every staged
|
|
490
|
+
// what-if check and every apply of a plan with drafts fail validation.
|
|
309
491
|
steps.push({
|
|
310
492
|
type: "scenario",
|
|
311
493
|
id,
|
|
312
494
|
properties: {
|
|
313
495
|
title: scenario.title.trim(),
|
|
314
496
|
status: "draft",
|
|
315
|
-
body: scenario.body.trim(),
|
|
316
497
|
source: "mcp://kibi/compile-intent",
|
|
317
498
|
},
|
|
499
|
+
document: { body: scenario.body.trim() },
|
|
318
500
|
relationships: [],
|
|
319
501
|
});
|
|
320
502
|
});
|
|
@@ -354,26 +536,36 @@ function draftSteps(requirementId, scenarios, tests) {
|
|
|
354
536
|
diagnostics.push(`unresolved test draft ${id} references unknown scenario ID ${scenarioId}.`);
|
|
355
537
|
}
|
|
356
538
|
}
|
|
357
|
-
for (const scenarioId of validScenarioIds)
|
|
539
|
+
for (const scenarioId of validScenarioIds) {
|
|
358
540
|
linkedScenarioIds.add(scenarioId);
|
|
359
|
-
|
|
541
|
+
scenarioTests.set(scenarioId, [
|
|
542
|
+
...(scenarioTests.get(scenarioId) ?? []),
|
|
543
|
+
id,
|
|
544
|
+
]);
|
|
545
|
+
}
|
|
546
|
+
testSteps.push({
|
|
360
547
|
type: "test",
|
|
361
548
|
id,
|
|
362
549
|
properties: {
|
|
363
550
|
title: test.title.trim(),
|
|
364
551
|
status: "draft",
|
|
365
|
-
body: test.body.trim(),
|
|
366
552
|
source: "mcp://kibi/compile-intent",
|
|
367
553
|
verification_scope: test.verificationScope ?? "integration",
|
|
368
554
|
verification_perspective: test.verificationPerspective ?? "internal",
|
|
369
555
|
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
from: scenarioId,
|
|
373
|
-
to: id,
|
|
374
|
-
})),
|
|
556
|
+
document: { body: test.body.trim() },
|
|
557
|
+
relationships: [],
|
|
375
558
|
});
|
|
376
559
|
});
|
|
560
|
+
const scenarioSteps = steps.map((step) => ({
|
|
561
|
+
...step,
|
|
562
|
+
relationships: (scenarioTests.get(text(step.id)) ?? []).map((to) => ({
|
|
563
|
+
type: "verified_by",
|
|
564
|
+
from: text(step.id),
|
|
565
|
+
to,
|
|
566
|
+
})),
|
|
567
|
+
}));
|
|
568
|
+
steps.splice(0, steps.length, ...testSteps, ...scenarioSteps);
|
|
377
569
|
for (const scenarioId of scenarioIds) {
|
|
378
570
|
if (!linkedScenarioIds.has(scenarioId)) {
|
|
379
571
|
diagnostics.push(`unresolved scenario draft ${scenarioId} has no test draft; add a test with scenarioIds to establish executable coverage.`);
|
|
@@ -393,7 +585,7 @@ function draftSteps(requirementId, scenarios, tests) {
|
|
|
393
585
|
}
|
|
394
586
|
return { steps, diagnostics };
|
|
395
587
|
}
|
|
396
|
-
// implements REQ-kibi-change-to-proof-plan-compiler
|
|
588
|
+
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
397
589
|
export async function executeCompileIntent(args, context) {
|
|
398
590
|
const intent = requiredIntent(args);
|
|
399
591
|
const prolog = context.prolog;
|
|
@@ -471,9 +663,9 @@ export async function executeCompileIntent(args, context) {
|
|
|
471
663
|
text(existingEntity.title) ||
|
|
472
664
|
intent.split(/[.!?]/, 1)[0] ||
|
|
473
665
|
intent;
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
"mcp://kibi/compile-intent";
|
|
666
|
+
const requirementDocument = requirementDocumentPath(args.sourceLocations);
|
|
667
|
+
const source = requirementDocument ??
|
|
668
|
+
(text(existingEntity.source) || "mcp://kibi/compile-intent");
|
|
477
669
|
const orchestrated = await analyzeSemanticAdvisorInputWithPlugins({
|
|
478
670
|
payload: {
|
|
479
671
|
type: "req",
|
|
@@ -594,6 +786,7 @@ export async function executeCompileIntent(args, context) {
|
|
|
594
786
|
: []),
|
|
595
787
|
]),
|
|
596
788
|
]);
|
|
789
|
+
const stepsWithInventory = withRequirementInventory(steps, requirementId, advisor.receipt, propositions);
|
|
597
790
|
const drafts = draftSteps(requirementId, args.scenarioDrafts ?? [], args.testDrafts ?? []);
|
|
598
791
|
diagnostics.push(...drafts.diagnostics);
|
|
599
792
|
const proposalDecisions = new Map((args.proposalDecisions ?? []).map((decision) => [
|
|
@@ -616,12 +809,19 @@ export async function executeCompileIntent(args, context) {
|
|
|
616
809
|
},
|
|
617
810
|
];
|
|
618
811
|
});
|
|
619
|
-
|
|
620
|
-
|
|
812
|
+
// Merging folds the drafts' relationship-only requirement step (its
|
|
813
|
+
// specified_by links) into the requirement step, which an upsert needs:
|
|
814
|
+
// a step without properties fails entity validation.
|
|
815
|
+
const stepsWithAcceptedProposals = applyAcceptedProposals(mergeSteps([...stepsWithInventory, ...drafts.steps]), proposals);
|
|
816
|
+
const contradictions = await contradictionAnalysis(prolog, requirementId, stepsWithAcceptedProposals, context.clock());
|
|
621
817
|
if (contradictions.outcome === "conflict")
|
|
622
|
-
diagnostics.push(
|
|
818
|
+
diagnostics.push(contradictions.witnesses.some((witness) => witness.kind === "scenario_feasibility")
|
|
819
|
+
? "The plan leaves a success scenario infeasible or conflicts with a current requirement: set expects: rejection, correct the assumption, record an approved exception, or supersede the conflicting requirement before applying this plan."
|
|
820
|
+
: "Current requirement conflicts must be resolved with an explicit supersedes relationship before applying this plan.");
|
|
623
821
|
if (contradictions.outcome === "unresolved")
|
|
624
|
-
diagnostics.push(
|
|
822
|
+
diagnostics.push(contradictions.witnesses.length > 0
|
|
823
|
+
? "Contradiction analysis is unresolved: the planned rules may overlap with current requirements and the checker can neither prove nor exclude a conflict."
|
|
824
|
+
: "Contradiction analysis could not run against the attached KB snapshot with this plan staged.");
|
|
625
825
|
if (args.mode === "create" &&
|
|
626
826
|
existing.length > 0 &&
|
|
627
827
|
diagnostics.some((entry) => entry.includes("already exists with different content")))
|
|
@@ -631,15 +831,31 @@ export async function executeCompileIntent(args, context) {
|
|
|
631
831
|
diagnostics.some((entry) => entry.includes("unresolved") ||
|
|
632
832
|
entry.includes("not found") ||
|
|
633
833
|
entry.includes("different content"));
|
|
634
|
-
|
|
834
|
+
let statusValue = contradictions.outcome === "conflict"
|
|
635
835
|
? "blocked"
|
|
636
836
|
: unresolved
|
|
637
837
|
? "needs_resolution"
|
|
638
838
|
: "ready";
|
|
639
839
|
const sourceHashMap = await sourceHashes(context, args.sourceLocations);
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
840
|
+
// Only a ready plan can be applied, so only a ready plan carries documents.
|
|
841
|
+
// A step whose entity or document cannot be rendered would fail the apply,
|
|
842
|
+
// so it makes the plan need resolution instead of reporting it ready.
|
|
843
|
+
let planSteps = stepsWithAcceptedProposals;
|
|
844
|
+
if (statusValue === "ready") {
|
|
845
|
+
try {
|
|
846
|
+
planSteps = await withDocumentTargets(context, prolog, stepsWithAcceptedProposals, {
|
|
847
|
+
id: requirementId,
|
|
848
|
+
body: `${intent.trim()}\n`,
|
|
849
|
+
...(requirementDocument !== undefined
|
|
850
|
+
? { path: requirementDocument }
|
|
851
|
+
: {}),
|
|
852
|
+
}, context.clock());
|
|
853
|
+
}
|
|
854
|
+
catch (error) {
|
|
855
|
+
statusValue = "needs_resolution";
|
|
856
|
+
diagnostics.push(`A plan step cannot be applied as written: ${error instanceof Error ? error.message : String(error)}`);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
643
859
|
const planBody = {
|
|
644
860
|
version: COMPILE_PLAN_VERSION,
|
|
645
861
|
status: statusValue,
|
|
@@ -657,8 +873,8 @@ export async function executeCompileIntent(args, context) {
|
|
|
657
873
|
propositions,
|
|
658
874
|
contradictionAnalysis: contradictions,
|
|
659
875
|
proposals,
|
|
660
|
-
steps:
|
|
661
|
-
sourceWrites,
|
|
876
|
+
steps: planSteps,
|
|
877
|
+
sourceWrites: [],
|
|
662
878
|
diagnostics,
|
|
663
879
|
};
|
|
664
880
|
// Shadow/provenance metadata is returned for observation but must not enter
|
|
@@ -672,7 +888,7 @@ export async function executeCompileIntent(args, context) {
|
|
|
672
888
|
content: [
|
|
673
889
|
{
|
|
674
890
|
type: "text",
|
|
675
|
-
text: `Compiled ${intent.length} characters into ${statusValue} plan ${plan.planHash.slice(0, 12)} with ${
|
|
891
|
+
text: `Compiled ${intent.length} characters into ${statusValue} plan ${plan.planHash.slice(0, 12)} with ${planSteps.length} step(s).`,
|
|
676
892
|
},
|
|
677
893
|
],
|
|
678
894
|
structuredContent: plan,
|