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
|
@@ -132,11 +132,11 @@ export function validateSemanticInventoryBoundary(payload, relationships, receip
|
|
|
132
132
|
export function assertSemanticInventoryBoundary(payload, relationships, receipt) {
|
|
133
133
|
const result = validateSemanticInventoryBoundary(payload, relationships, receipt);
|
|
134
134
|
if (result.errors.length > 0) {
|
|
135
|
-
throw new Error(`Proposition-complete ingestion failed: ${result.errors.join("; ")}. Run
|
|
135
|
+
throw new Error(`Proposition-complete ingestion failed: ${result.errors.join("; ")}. Run kb_model mode analyze (CLI: semantic-advisor) with the complete prose and preserve its inventory contract before retrying.`);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
// implements REQ-kibi-proposition-complete-ingestion
|
|
139
|
-
export async function assertLogicalGroundingClaimKeys(prolog, payload, relationships) {
|
|
139
|
+
export async function assertLogicalGroundingClaimKeys(prolog, payload, relationships, staged) {
|
|
140
140
|
if (stringValue(payload.type) !== "req")
|
|
141
141
|
return;
|
|
142
142
|
if (propertiesOf(payload).semantic_inventory_version !==
|
|
@@ -151,10 +151,18 @@ export async function assertLogicalGroundingClaimKeys(prolog, payload, relations
|
|
|
151
151
|
!LOGICAL_RELATIONSHIPS.has(stringValue(relationship.type)))
|
|
152
152
|
continue;
|
|
153
153
|
const target = stringValue(relationship.to);
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
// A grounding fact an earlier plan step writes is read from that write.
|
|
155
|
+
const planned = staged?.entities.get(target);
|
|
156
|
+
let claimKey = "";
|
|
157
|
+
if (planned !== undefined) {
|
|
158
|
+
claimKey = planned.type === "fact" ? stringValue(planned.claim_key) : "";
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const result = await prolog.query(`once((kb_entity('${escapeAtom(target)}', fact, _SemanticGroundProps), memberchk(claim_key=_SemanticGroundRaw, _SemanticGroundProps), normalize_term_atom(_SemanticGroundRaw, ClaimKey)))`);
|
|
162
|
+
claimKey = result.success
|
|
163
|
+
? stringValue(result.bindings.ClaimKey).replace(/^['"]|['"]$/g, "")
|
|
164
|
+
: "";
|
|
165
|
+
}
|
|
158
166
|
if (!claimKey) {
|
|
159
167
|
throw new Error(`Proposition-complete ingestion failed: logical grounding target '${target}' must declare a claim_key.`);
|
|
160
168
|
}
|
|
@@ -140,7 +140,7 @@ export function applyOntologyMatchSuggestions(analysis, ontologyMatches, options
|
|
|
140
140
|
confidence: match.confidence,
|
|
141
141
|
evidence: match.evidence,
|
|
142
142
|
rationale: match.rationale ??
|
|
143
|
-
`Ontology pack '${match.packId}' matched ${match.predicateName}; review via
|
|
143
|
+
`Ontology pack '${match.packId}' matched ${match.predicateName}; review via kb_model (mode predicates) before mutation.`,
|
|
144
144
|
suggested_next_tool: "kb_suggest_predicates",
|
|
145
145
|
recommendedPredicateSchema: {
|
|
146
146
|
predicate_name: match.predicateName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/prolog/codec.ts"],"names":[],"mappings":"AAUA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYhD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASpD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAU5D;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACrC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAO9B;AAED,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EA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,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAmBlE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAoBzE;AAyCD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE,CA6DjE"}
|
package/dist/prolog/codec.js
CHANGED
|
@@ -196,7 +196,8 @@ export function parsePropertyList(propsStr) {
|
|
|
196
196
|
key === "semantic_inventory" ||
|
|
197
197
|
key === "proof_receipts" ||
|
|
198
198
|
key === "proof_contract" ||
|
|
199
|
-
key === "proof_bindings"
|
|
199
|
+
key === "proof_bindings" ||
|
|
200
|
+
key === "origin") &&
|
|
200
201
|
typeof parsed === "string") {
|
|
201
202
|
try {
|
|
202
203
|
parsed = JSON.parse(parsed);
|
package/dist/prolog.d.ts
CHANGED
|
@@ -67,6 +67,9 @@ export declare class PrologProcess {
|
|
|
67
67
|
*/
|
|
68
68
|
private interactiveStarted;
|
|
69
69
|
private terminationReason;
|
|
70
|
+
/** Wake hook of the in-flight interactive query, run when output arrives. */
|
|
71
|
+
private outputWaiter;
|
|
72
|
+
private outputWakeScheduled;
|
|
70
73
|
constructor(options?: PrologOptions);
|
|
71
74
|
attachProcessExitHandler(on?: (event: "exit", listener: () => void) => void): void;
|
|
72
75
|
/**
|
|
@@ -100,6 +103,12 @@ export declare class PrologProcess {
|
|
|
100
103
|
private clearQueryBuffers;
|
|
101
104
|
private appendOutputChunk;
|
|
102
105
|
private appendErrorChunk;
|
|
106
|
+
/**
|
|
107
|
+
* Notify the in-flight query that output arrived. Deferred to the event
|
|
108
|
+
* loop's check phase so every pipe that became readable in this turn
|
|
109
|
+
* (stderr diagnostics precede the stdout answer frame) is drained first.
|
|
110
|
+
*/
|
|
111
|
+
private wakeOutputWaiter;
|
|
103
112
|
private goalLabel;
|
|
104
113
|
private addDiagnosticStage;
|
|
105
114
|
private lastDiagnosticStage;
|
package/dist/prolog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,4BAA4B,CAAC;AA2BpC,wBAAgB,eAAe,IAAI,MAAM,CAsCxC;AACD,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,aAAa,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,+BAA+B;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAO3B;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAGD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,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B,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,kBAAkB;YAIZ,YAAY;IA2C1B,OAAO,CAAC,WAAW;IAkOnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,iBAAiB;YAkBX,oBAAoB;IAyBlC,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,eAAe;IAmCvB,sEAAsE;IACtE,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,cAAc;IAoGtB,SAAS,IAAI,OAAO;IASpB,MAAM,IAAI,MAAM;IAIhB,OAAO,CAAC,gBAAgB;IASlB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAqCjC"}
|
package/dist/prolog.js
CHANGED
|
@@ -136,6 +136,9 @@ export class PrologProcess {
|
|
|
136
136
|
*/
|
|
137
137
|
interactiveStarted = false;
|
|
138
138
|
terminationReason = null;
|
|
139
|
+
/** Wake hook of the in-flight interactive query, run when output arrives. */
|
|
140
|
+
outputWaiter = null;
|
|
141
|
+
outputWakeScheduled = false;
|
|
139
142
|
constructor(options = {}) {
|
|
140
143
|
this.explicitSwiplPath = options.swiplPath || undefined;
|
|
141
144
|
this.swiplResolver = options.swiplResolver ?? (() => resolveSwipl());
|
|
@@ -343,6 +346,15 @@ export class PrologProcess {
|
|
|
343
346
|
this.process?.stdin?.write(`${wrappedGoal}.\nwriteln('${INTERACTIVE_QUERY_FRAME_END}').\n`);
|
|
344
347
|
return new Promise((resolve, reject) => {
|
|
345
348
|
let settled = false;
|
|
349
|
+
let pollTimer = null;
|
|
350
|
+
const settle = () => {
|
|
351
|
+
settled = true;
|
|
352
|
+
clearTimeout(timeoutId);
|
|
353
|
+
if (pollTimer !== null)
|
|
354
|
+
clearTimeout(pollTimer);
|
|
355
|
+
if (this.outputWaiter === wake)
|
|
356
|
+
this.outputWaiter = null;
|
|
357
|
+
};
|
|
346
358
|
const timeoutId = setTimeout(() => {
|
|
347
359
|
const stage = this.lastDiagnosticStage(this.errorBuffer) ?? "unknown";
|
|
348
360
|
const msg = `Query timeout after ${this.timeout / 1000}s (stage=${stage}, pid=${this.process?.pid ?? 0}, killed=${this.process?.killed ? "yes" : "no"}, exitCode=${this.process?.exitCode ?? "null"}, signal=${this.process?.signalCode ?? "null"}, goal=${goalLabel}). If several fresh Kibi commands hang or crawl the same way, the engine state is likely wedged: run 'kibi engine stop' (then 'kibi sync --rebuild' if needed) and retry.`;
|
|
@@ -353,7 +365,7 @@ export class PrologProcess {
|
|
|
353
365
|
.find((line) => line.includes("__KIBI_RUNTIME__"));
|
|
354
366
|
console.error(`[prolog debug] runtime=${runtime ?? "unknown"} packages=${process.env.KIBI_PACKAGE_VERSIONS ?? KIBI_PACKAGE_VERSIONS}`);
|
|
355
367
|
}
|
|
356
|
-
|
|
368
|
+
settle();
|
|
357
369
|
this.terminationReason = `query timeout: ${goalLabel}`;
|
|
358
370
|
void this.terminate().finally(() => {
|
|
359
371
|
reject(new Error(msg));
|
|
@@ -364,8 +376,7 @@ export class PrologProcess {
|
|
|
364
376
|
return;
|
|
365
377
|
}
|
|
366
378
|
if (this.outputOverflowed) {
|
|
367
|
-
|
|
368
|
-
settled = true;
|
|
379
|
+
settle();
|
|
369
380
|
this.terminationReason = `output overflow (ENOBUFS): ${goalLabel}`;
|
|
370
381
|
void this.terminate().finally(() => {
|
|
371
382
|
resolve({
|
|
@@ -377,8 +388,7 @@ export class PrologProcess {
|
|
|
377
388
|
return;
|
|
378
389
|
}
|
|
379
390
|
if (!this.isProcessUsable()) {
|
|
380
|
-
|
|
381
|
-
settled = true;
|
|
391
|
+
settle();
|
|
382
392
|
this.terminationReason ??= `process exited during query: ${goalLabel}`;
|
|
383
393
|
resolve({
|
|
384
394
|
success: false,
|
|
@@ -389,8 +399,7 @@ export class PrologProcess {
|
|
|
389
399
|
}
|
|
390
400
|
if (this.errorBuffer.length > 0 &&
|
|
391
401
|
this.errorBuffer.includes("ERROR")) {
|
|
392
|
-
|
|
393
|
-
settled = true;
|
|
402
|
+
settle();
|
|
394
403
|
if (debug) {
|
|
395
404
|
console.error(`[prolog debug] query error: ${goalLabel} error=${this.errorBuffer.split("\n")[0]}`);
|
|
396
405
|
}
|
|
@@ -405,8 +414,7 @@ export class PrologProcess {
|
|
|
405
414
|
}
|
|
406
415
|
const frameEnd = this.outputBuffer.indexOf(INTERACTIVE_QUERY_FRAME_END);
|
|
407
416
|
if (frameEnd >= 0) {
|
|
408
|
-
|
|
409
|
-
settled = true;
|
|
417
|
+
settle();
|
|
410
418
|
const framedOutput = this.outputBuffer.slice(0, frameEnd).trimEnd();
|
|
411
419
|
if (/(?:^|\n)(?:false|fail)\.\s*$/.test(framedOutput)) {
|
|
412
420
|
resolve({
|
|
@@ -438,8 +446,30 @@ export class PrologProcess {
|
|
|
438
446
|
resolve(result);
|
|
439
447
|
return;
|
|
440
448
|
}
|
|
441
|
-
|
|
449
|
+
// The poll still owns every state an output wake does not decide:
|
|
450
|
+
// a diagnostic without its answer frame, or a process that died.
|
|
451
|
+
if (pollTimer === null) {
|
|
452
|
+
pollTimer = setTimeout(() => {
|
|
453
|
+
pollTimer = null;
|
|
454
|
+
checkResult();
|
|
455
|
+
}, 50);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
// Output wakes act only once the answer frame (or an overflow) has
|
|
459
|
+
// arrived. SWI writes a query's stderr report before its stdout
|
|
460
|
+
// frame, so the frame proves both buffers are complete; anything
|
|
461
|
+
// earlier is left to the poll, keeping classification unchanged
|
|
462
|
+
// while a finished query no longer waits out a 50 ms poll interval.
|
|
463
|
+
let frameScanFrom = 0;
|
|
464
|
+
const wake = () => {
|
|
465
|
+
if (settled)
|
|
466
|
+
return;
|
|
467
|
+
const found = this.outputBuffer.indexOf(INTERACTIVE_QUERY_FRAME_END, frameScanFrom) >= 0;
|
|
468
|
+
frameScanFrom = Math.max(0, this.outputBuffer.length - INTERACTIVE_QUERY_FRAME_END.length);
|
|
469
|
+
if (found || this.outputOverflowed)
|
|
470
|
+
checkResult();
|
|
442
471
|
};
|
|
472
|
+
this.outputWaiter = wake;
|
|
443
473
|
checkResult();
|
|
444
474
|
});
|
|
445
475
|
};
|
|
@@ -738,6 +768,7 @@ export class PrologProcess {
|
|
|
738
768
|
}
|
|
739
769
|
this.outputBuffer += chunk.toString();
|
|
740
770
|
this.outputBufferBytes += chunk.byteLength;
|
|
771
|
+
this.wakeOutputWaiter();
|
|
741
772
|
}
|
|
742
773
|
appendErrorChunk(chunk) {
|
|
743
774
|
if (this.outputOverflowed)
|
|
@@ -751,6 +782,21 @@ export class PrologProcess {
|
|
|
751
782
|
}
|
|
752
783
|
this.errorBuffer += chunk.toString();
|
|
753
784
|
this.errorBufferBytes += chunk.byteLength;
|
|
785
|
+
this.wakeOutputWaiter();
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Notify the in-flight query that output arrived. Deferred to the event
|
|
789
|
+
* loop's check phase so every pipe that became readable in this turn
|
|
790
|
+
* (stderr diagnostics precede the stdout answer frame) is drained first.
|
|
791
|
+
*/
|
|
792
|
+
wakeOutputWaiter() {
|
|
793
|
+
if (this.outputWaiter === null || this.outputWakeScheduled)
|
|
794
|
+
return;
|
|
795
|
+
this.outputWakeScheduled = true;
|
|
796
|
+
setImmediate(() => {
|
|
797
|
+
this.outputWakeScheduled = false;
|
|
798
|
+
this.outputWaiter?.();
|
|
799
|
+
});
|
|
754
800
|
}
|
|
755
801
|
goalLabel(goal) {
|
|
756
802
|
const match = goal
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-test attribution for `command` proof integrations.
|
|
3
|
+
*
|
|
4
|
+
* A command integration is one process that runs the steps of every selected
|
|
5
|
+
* test. Its exit code alone cannot say which test a failure belongs to, so a
|
|
6
|
+
* single unrelated failing step used to fail every receipt of the run. The
|
|
7
|
+
* command may instead write a kibi.proof-test-report.v1 file to the path in
|
|
8
|
+
* KIBI_PROOF_TEST_REPORT, naming each selected test's own step outcomes. Kibi
|
|
9
|
+
* then evaluates every test against the slice of the run its own steps
|
|
10
|
+
* produced. Attribution fails closed: a missing, malformed or incomplete
|
|
11
|
+
* report, or a failed process whose report blames no test, keeps the whole
|
|
12
|
+
* run failed exactly as before.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PROOF_TEST_REPORT_VERSION: "kibi.proof-test-report.v1";
|
|
15
|
+
/** Environment variable carrying the report path to a command integration. */
|
|
16
|
+
export declare const PROOF_TEST_REPORT_ENV: "KIBI_PROOF_TEST_REPORT";
|
|
17
|
+
export declare const PROOF_TEST_REPORT_OUTCOMES: readonly ["passed", "failed", "timed_out", "errored", "interrupted"];
|
|
18
|
+
export type ProofTestReportOutcome = (typeof PROOF_TEST_REPORT_OUTCOMES)[number];
|
|
19
|
+
export type ProofTestReportStep = Readonly<{
|
|
20
|
+
step_index: number;
|
|
21
|
+
command: readonly string[];
|
|
22
|
+
outcome: string;
|
|
23
|
+
exit_code: number | null;
|
|
24
|
+
}>;
|
|
25
|
+
export type ProofTestReportEntry = Readonly<{
|
|
26
|
+
test_id: string;
|
|
27
|
+
outcome: ProofTestReportOutcome;
|
|
28
|
+
steps: readonly ProofTestReportStep[];
|
|
29
|
+
}>;
|
|
30
|
+
/** One failing step, as the `kibi prove` run summary lists it. */
|
|
31
|
+
export type FailedProofStep = Readonly<{
|
|
32
|
+
testId: string;
|
|
33
|
+
stepIndex: number;
|
|
34
|
+
command: readonly string[];
|
|
35
|
+
outcome: string;
|
|
36
|
+
exitCode: number | null;
|
|
37
|
+
}>;
|
|
38
|
+
/** Tests whose own steps ended with the same outcome, evaluated together. */
|
|
39
|
+
export type ProofRunPartition = Readonly<{
|
|
40
|
+
outcome: ProofTestReportOutcome;
|
|
41
|
+
testIds: readonly string[];
|
|
42
|
+
exitCode: number;
|
|
43
|
+
failedSteps: readonly FailedProofStep[];
|
|
44
|
+
}>;
|
|
45
|
+
export type ProofRunAttribution = Readonly<{
|
|
46
|
+
attribution: "per_test";
|
|
47
|
+
partitions: readonly ProofRunPartition[];
|
|
48
|
+
failedSteps: readonly FailedProofStep[];
|
|
49
|
+
}> | Readonly<{
|
|
50
|
+
attribution: "aggregate";
|
|
51
|
+
reason: string;
|
|
52
|
+
failedSteps: readonly FailedProofStep[];
|
|
53
|
+
}>;
|
|
54
|
+
/** The report path written next to an integration's run artifact. */
|
|
55
|
+
export declare function proofTestReportPath(artifactPath: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Validate a kibi.proof-test-report.v1 against the exact selection. Every
|
|
58
|
+
* selected test must appear once with at least one step, and a test may only
|
|
59
|
+
* be reported `passed` when every one of its steps passed.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseProofTestReport(value: unknown, selectedTestIds: readonly string[]): ReadonlyMap<string, ProofTestReportEntry>;
|
|
62
|
+
/**
|
|
63
|
+
* Decide how a finished command run is attributed. `per_test` partitions the
|
|
64
|
+
* selected tests by their own outcome; `aggregate` keeps the historical
|
|
65
|
+
* whole-run semantics (and is always the answer for a passing process
|
|
66
|
+
* without a report, so a fully green run stays byte-identical).
|
|
67
|
+
*/
|
|
68
|
+
export declare function attributeCommandRun(input: {
|
|
69
|
+
readonly selectedTestIds: readonly string[];
|
|
70
|
+
readonly exitCode: number;
|
|
71
|
+
/** Parsed report JSON, or undefined when the command wrote none. */
|
|
72
|
+
readonly report: unknown;
|
|
73
|
+
}): ProofRunAttribution;
|
|
74
|
+
//# sourceMappingURL=command-test-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-test-report.d.ts","sourceRoot":"","sources":["../../src/proof/command-test-report.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;GAYG;AAGH,eAA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S,eAAe,EAAE,CAAC;CACzC,CAAC,GACF,QAAQ,CAAC;IACP,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;CACzC,CAAC,CAAC;AAEP,qEAAqE;AAErE,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAIhE;AA+BD;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAoD3C;AAqBD;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B,GAAG,mBAAmB,CA+DtB"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Per-test attribution for `command` proof integrations.
|
|
20
|
+
*
|
|
21
|
+
* A command integration is one process that runs the steps of every selected
|
|
22
|
+
* test. Its exit code alone cannot say which test a failure belongs to, so a
|
|
23
|
+
* single unrelated failing step used to fail every receipt of the run. The
|
|
24
|
+
* command may instead write a kibi.proof-test-report.v1 file to the path in
|
|
25
|
+
* KIBI_PROOF_TEST_REPORT, naming each selected test's own step outcomes. Kibi
|
|
26
|
+
* then evaluates every test against the slice of the run its own steps
|
|
27
|
+
* produced. Attribution fails closed: a missing, malformed or incomplete
|
|
28
|
+
* report, or a failed process whose report blames no test, keeps the whole
|
|
29
|
+
* run failed exactly as before.
|
|
30
|
+
*/
|
|
31
|
+
// implements REQ-kibi-fresh-verification-receipts-v2
|
|
32
|
+
export const PROOF_TEST_REPORT_VERSION = "kibi.proof-test-report.v1";
|
|
33
|
+
/** Environment variable carrying the report path to a command integration. */
|
|
34
|
+
// implements REQ-kibi-fresh-verification-receipts-v2
|
|
35
|
+
export const PROOF_TEST_REPORT_ENV = "KIBI_PROOF_TEST_REPORT";
|
|
36
|
+
// implements REQ-kibi-fresh-verification-receipts-v2
|
|
37
|
+
export const PROOF_TEST_REPORT_OUTCOMES = [
|
|
38
|
+
"passed",
|
|
39
|
+
"failed",
|
|
40
|
+
"timed_out",
|
|
41
|
+
"errored",
|
|
42
|
+
"interrupted",
|
|
43
|
+
];
|
|
44
|
+
/** The report path written next to an integration's run artifact. */
|
|
45
|
+
// implements REQ-kibi-fresh-verification-receipts-v2
|
|
46
|
+
export function proofTestReportPath(artifactPath) {
|
|
47
|
+
return artifactPath.endsWith(".json")
|
|
48
|
+
? `${artifactPath.slice(0, -".json".length)}.tests.json`
|
|
49
|
+
: `${artifactPath}.tests.json`;
|
|
50
|
+
}
|
|
51
|
+
function record(value) {
|
|
52
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
53
|
+
? value
|
|
54
|
+
: null;
|
|
55
|
+
}
|
|
56
|
+
function parseStep(value, label) {
|
|
57
|
+
const row = record(value);
|
|
58
|
+
if (!row)
|
|
59
|
+
throw new Error(`${label} must be an object`);
|
|
60
|
+
if (!Number.isSafeInteger(row.step_index) || Number(row.step_index) < 1)
|
|
61
|
+
throw new Error(`${label}.step_index must be a positive integer`);
|
|
62
|
+
if (!Array.isArray(row.command) ||
|
|
63
|
+
row.command.length === 0 ||
|
|
64
|
+
!row.command.every((part) => typeof part === "string"))
|
|
65
|
+
throw new Error(`${label}.command must be a non-empty string argv array`);
|
|
66
|
+
if (typeof row.outcome !== "string" || row.outcome.trim() === "")
|
|
67
|
+
throw new Error(`${label}.outcome must be a non-empty string`);
|
|
68
|
+
if (row.exit_code !== null && !Number.isSafeInteger(row.exit_code))
|
|
69
|
+
throw new Error(`${label}.exit_code must be an integer or null`);
|
|
70
|
+
return {
|
|
71
|
+
step_index: Number(row.step_index),
|
|
72
|
+
command: [...row.command],
|
|
73
|
+
outcome: row.outcome,
|
|
74
|
+
exit_code: row.exit_code === null ? null : Number(row.exit_code),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate a kibi.proof-test-report.v1 against the exact selection. Every
|
|
79
|
+
* selected test must appear once with at least one step, and a test may only
|
|
80
|
+
* be reported `passed` when every one of its steps passed.
|
|
81
|
+
*/
|
|
82
|
+
// implements REQ-kibi-fresh-verification-receipts-v2
|
|
83
|
+
export function parseProofTestReport(value, selectedTestIds) {
|
|
84
|
+
const report = record(value);
|
|
85
|
+
if (!report)
|
|
86
|
+
throw new Error("report must be an object");
|
|
87
|
+
if (report.version !== PROOF_TEST_REPORT_VERSION)
|
|
88
|
+
throw new Error(`report version must be ${PROOF_TEST_REPORT_VERSION}`);
|
|
89
|
+
if (!Array.isArray(report.tests))
|
|
90
|
+
throw new Error("report tests must be an array");
|
|
91
|
+
const selected = new Set(selectedTestIds);
|
|
92
|
+
const entries = new Map();
|
|
93
|
+
report.tests.forEach((raw, index) => {
|
|
94
|
+
const label = `tests[${index}]`;
|
|
95
|
+
const row = record(raw);
|
|
96
|
+
if (!row)
|
|
97
|
+
throw new Error(`${label} must be an object`);
|
|
98
|
+
const testId = typeof row.test_id === "string" ? row.test_id.trim() : "";
|
|
99
|
+
if (!selected.has(testId))
|
|
100
|
+
throw new Error(`${label}.test_id '${testId}' was not selected`);
|
|
101
|
+
if (entries.has(testId))
|
|
102
|
+
throw new Error(`${label}.test_id '${testId}' is reported twice`);
|
|
103
|
+
if (!PROOF_TEST_REPORT_OUTCOMES.includes(String(row.outcome)))
|
|
104
|
+
throw new Error(`${label}.outcome must be one of ${PROOF_TEST_REPORT_OUTCOMES.join(", ")}`);
|
|
105
|
+
if (!Array.isArray(row.steps) || row.steps.length === 0)
|
|
106
|
+
throw new Error(`${label}.steps must be a non-empty array`);
|
|
107
|
+
const steps = row.steps.map((step, stepIndex) => parseStep(step, `${label}.steps[${stepIndex}]`));
|
|
108
|
+
const outcome = row.outcome;
|
|
109
|
+
if (outcome === "passed" &&
|
|
110
|
+
steps.some((step) => step.outcome !== "passed" || step.exit_code !== 0))
|
|
111
|
+
throw new Error(`${label} is reported passed but one of its steps did not pass`);
|
|
112
|
+
if (outcome !== "passed" &&
|
|
113
|
+
steps.every((step) => step.outcome === "passed"))
|
|
114
|
+
throw new Error(`${label} is reported ${outcome} but every one of its steps passed`);
|
|
115
|
+
entries.set(testId, { test_id: testId, outcome, steps });
|
|
116
|
+
});
|
|
117
|
+
const missing = selectedTestIds.filter((testId) => !entries.has(testId));
|
|
118
|
+
if (missing.length > 0)
|
|
119
|
+
throw new Error(`report omits selected test(s): ${missing.join(", ")}`);
|
|
120
|
+
return entries;
|
|
121
|
+
}
|
|
122
|
+
function failedStepsOf(entries) {
|
|
123
|
+
const failed = [];
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
for (const step of entry.steps) {
|
|
126
|
+
if (step.outcome === "passed")
|
|
127
|
+
continue;
|
|
128
|
+
failed.push({
|
|
129
|
+
testId: entry.test_id,
|
|
130
|
+
stepIndex: step.step_index,
|
|
131
|
+
command: step.command,
|
|
132
|
+
outcome: step.outcome,
|
|
133
|
+
exitCode: step.exit_code,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return failed;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Decide how a finished command run is attributed. `per_test` partitions the
|
|
141
|
+
* selected tests by their own outcome; `aggregate` keeps the historical
|
|
142
|
+
* whole-run semantics (and is always the answer for a passing process
|
|
143
|
+
* without a report, so a fully green run stays byte-identical).
|
|
144
|
+
*/
|
|
145
|
+
// implements REQ-kibi-fresh-verification-receipts-v2
|
|
146
|
+
export function attributeCommandRun(input) {
|
|
147
|
+
const { selectedTestIds, exitCode, report } = input;
|
|
148
|
+
if (report === undefined) {
|
|
149
|
+
return {
|
|
150
|
+
attribution: "aggregate",
|
|
151
|
+
reason: exitCode === 0
|
|
152
|
+
? "the integration passed"
|
|
153
|
+
: `the integration exited ${exitCode} without a ${PROOF_TEST_REPORT_VERSION}, so the failure cannot be attributed to a test`,
|
|
154
|
+
failedSteps: [],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
let entries;
|
|
158
|
+
try {
|
|
159
|
+
entries = parseProofTestReport(report, selectedTestIds);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
return {
|
|
163
|
+
attribution: "aggregate",
|
|
164
|
+
reason: `the ${PROOF_TEST_REPORT_VERSION} was rejected (${error instanceof Error ? error.message : String(error)}), so the run is evaluated as one unit`,
|
|
165
|
+
failedSteps: [],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const failedSteps = failedStepsOf(entries.values());
|
|
169
|
+
const failing = [...entries.values()].filter((entry) => entry.outcome !== "passed");
|
|
170
|
+
if (exitCode !== 0 && failing.length === 0) {
|
|
171
|
+
return {
|
|
172
|
+
attribution: "aggregate",
|
|
173
|
+
reason: `the integration exited ${exitCode} but its ${PROOF_TEST_REPORT_VERSION} attributes the failure to no test`,
|
|
174
|
+
failedSteps,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
if (failing.length === 0) {
|
|
178
|
+
return {
|
|
179
|
+
attribution: "aggregate",
|
|
180
|
+
reason: "the integration passed",
|
|
181
|
+
failedSteps,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const groups = new Map();
|
|
185
|
+
for (const testId of selectedTestIds) {
|
|
186
|
+
const entry = entries.get(testId);
|
|
187
|
+
const group = groups.get(entry.outcome) ?? [];
|
|
188
|
+
group.push(entry);
|
|
189
|
+
groups.set(entry.outcome, group);
|
|
190
|
+
}
|
|
191
|
+
const partitions = [];
|
|
192
|
+
for (const outcome of PROOF_TEST_REPORT_OUTCOMES) {
|
|
193
|
+
const group = groups.get(outcome);
|
|
194
|
+
if (!group)
|
|
195
|
+
continue;
|
|
196
|
+
const groupFailedSteps = failedStepsOf(group);
|
|
197
|
+
const firstNonZero = groupFailedSteps.find((step) => step.exitCode !== null && step.exitCode !== 0)?.exitCode;
|
|
198
|
+
partitions.push({
|
|
199
|
+
outcome,
|
|
200
|
+
testIds: group.map((entry) => entry.test_id),
|
|
201
|
+
exitCode: outcome === "passed" ? 0 : (firstNonZero ?? (exitCode || 1)),
|
|
202
|
+
failedSteps: groupFailedSteps,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return { attribution: "per_test", partitions, failedSteps };
|
|
206
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-resolver.d.ts","sourceRoot":"","sources":["../../src/public/branch-resolver.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"branch-resolver.d.ts","sourceRoot":"","sources":["../../src/public/branch-resolver.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC"}
|
|
@@ -13,5 +13,19 @@ export interface DiagnosticUsageInput {
|
|
|
13
13
|
}
|
|
14
14
|
export declare function diagnosticMutationFingerprint(args: Readonly<Record<string, unknown>>): string;
|
|
15
15
|
export declare function deriveDiagnosticUsageFields(tool: string, args: Readonly<Record<string, unknown>>, telemetry: Readonly<Record<string, unknown>> | null, result: unknown): Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the operator opted into usage telemetry through the environment.
|
|
18
|
+
*
|
|
19
|
+
* `KIBI_DIAGNOSTIC_MODE` is the one opt-in shared with the MCP server, so a
|
|
20
|
+
* single setting covers both peer surfaces. `KIBI_CLI_DIAGNOSTIC_MODE` is the
|
|
21
|
+
* older CLI-only spelling and keeps working.
|
|
22
|
+
*/
|
|
23
|
+
export declare function diagnosticEnvOptIn(env?: NodeJS.ProcessEnv): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The host that ran this CLI call. Hosts that launch Kibi set `KIBI_HOST`;
|
|
26
|
+
* Claude Code marks every shell it runs with `CLAUDECODE=1`, which is the
|
|
27
|
+
* only ambient signal trusted here. Anything else stays `unknown`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function diagnosticCliHost(env?: NodeJS.ProcessEnv): string;
|
|
16
30
|
export declare function appendCliDiagnosticUsage(input: DiagnosticUsageInput): void;
|
|
17
31
|
//# sourceMappingURL=diagnostic-usage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-usage.d.ts","sourceRoot":"","sources":["../../src/public/diagnostic-usage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnostic-usage.d.ts","sourceRoot":"","sources":["../../src/public/diagnostic-usage.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,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from "node:fs";
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { appendPayloadCountField, normalizeResultPayload, } from "./operations/result-envelope.js";
|
|
5
6
|
function isRecord(value) {
|
|
6
7
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -177,6 +178,56 @@ export function deriveDiagnosticUsageFields(tool, args, telemetry, result) {
|
|
|
177
178
|
fields.result_summary = `${tool} completed`;
|
|
178
179
|
return fields;
|
|
179
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Whether the operator opted into usage telemetry through the environment.
|
|
183
|
+
*
|
|
184
|
+
* `KIBI_DIAGNOSTIC_MODE` is the one opt-in shared with the MCP server, so a
|
|
185
|
+
* single setting covers both peer surfaces. `KIBI_CLI_DIAGNOSTIC_MODE` is the
|
|
186
|
+
* older CLI-only spelling and keeps working.
|
|
187
|
+
*/
|
|
188
|
+
export function diagnosticEnvOptIn(env = process.env) {
|
|
189
|
+
return ["KIBI_DIAGNOSTIC_MODE", "KIBI_CLI_DIAGNOSTIC_MODE"].some((key) => {
|
|
190
|
+
const value = env[key]?.trim().toLowerCase();
|
|
191
|
+
return value === "1" || value === "true";
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The host that ran this CLI call. Hosts that launch Kibi set `KIBI_HOST`;
|
|
196
|
+
* Claude Code marks every shell it runs with `CLAUDECODE=1`, which is the
|
|
197
|
+
* only ambient signal trusted here. Anything else stays `unknown`.
|
|
198
|
+
*/
|
|
199
|
+
export function diagnosticCliHost(env = process.env) {
|
|
200
|
+
const explicit = env.KIBI_HOST?.trim() || env.KIBI_MCP_HOST?.trim();
|
|
201
|
+
if (explicit)
|
|
202
|
+
return explicit;
|
|
203
|
+
return env.CLAUDECODE === "1" ? "claude-code" : "unknown";
|
|
204
|
+
}
|
|
205
|
+
let cachedCliPackageVersion;
|
|
206
|
+
function cliPackageVersion() {
|
|
207
|
+
if (cachedCliPackageVersion !== undefined)
|
|
208
|
+
return cachedCliPackageVersion;
|
|
209
|
+
cachedCliPackageVersion = null;
|
|
210
|
+
let current = path.dirname(fileURLToPath(import.meta.url));
|
|
211
|
+
while (true) {
|
|
212
|
+
const candidate = path.join(current, "package.json");
|
|
213
|
+
if (existsSync(candidate)) {
|
|
214
|
+
try {
|
|
215
|
+
const parsed = JSON.parse(readFileSync(candidate, "utf8"));
|
|
216
|
+
if (isRecord(parsed) && typeof parsed.version === "string") {
|
|
217
|
+
cachedCliPackageVersion = parsed.version;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
// An unreadable manifest leaves the version unknown.
|
|
222
|
+
}
|
|
223
|
+
return cachedCliPackageVersion;
|
|
224
|
+
}
|
|
225
|
+
const parent = path.dirname(current);
|
|
226
|
+
if (parent === current)
|
|
227
|
+
return null;
|
|
228
|
+
current = parent;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
180
231
|
export function appendCliDiagnosticUsage(input) {
|
|
181
232
|
const finishedAt = input.finishedAt ?? new Date();
|
|
182
233
|
const requestId = input.requestId ?? `cli-${randomUUID()}`;
|
|
@@ -189,6 +240,9 @@ export function appendCliDiagnosticUsage(input) {
|
|
|
189
240
|
request_id: requestId,
|
|
190
241
|
tool: input.tool,
|
|
191
242
|
interface: "cli_json",
|
|
243
|
+
host: diagnosticCliHost(),
|
|
244
|
+
package_version: cliPackageVersion(),
|
|
245
|
+
workspace_root: input.workspaceRoot,
|
|
192
246
|
telemetry: input.telemetry,
|
|
193
247
|
business_args: input.businessArgs,
|
|
194
248
|
status: input.status,
|